This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Weird Audio Bug on Triangle Voice

Weird Audio Bug on Triangle Voice
by on (#47593)
Looking for some pointers on this one.

It seems to only affect Nestopia (OSX and XP) and doesn't happen in Audio Overload (for example).

I'm getting a "pop" sound on the triangle voice which seems to occur at the same time after a hard reset and there is activity on the voice. It occurs after approximately $240 frames @ 60fps (so about 12 seconds).

In my code, I'm using a write of $81 to $4008 when I want the voice on and $01 to $4008 when I want the voice off. I don't use any of the automatic counters, everything is done with my own counters.

I'm wondering if it's to do with one of the counters automatically trying to turn off the voice? Does 12 seconds correspond to anything in this respect?

Any help/advice is much appreciated. :)

by on (#47598)
Are you sure this is coming from the Triangle and not another channel? Try silencing all other channels and see if it goes away. Square/DMC are much more likely to be causing pops than the triangle.

Can you provide a recording of the audio?

The only way I know of that you can make a pop with the triangle is if you zero it's F-value (0 to $400A, $400B) -- or set the F-value to something else crazy low. All other ways of silencing the tri do so "cleanly" in that they don't cause a pop.

by on (#47599)
At 60 frames per second, $240 frames = 576 frames = 9.58 seconds.

The 240 Hz frame counter clocks the hardware envelopes (e.g. the linear counter) once every 7457.5 cycles, and it clocks the length counter and sweep units every other time (once every 14915 cycles). It completes one "frame" every 29830 cycles. But most music engines are triggered by vertical blank, and this happens once every (341*261.5+340*0.5)/3 = 29780.5 cycles on an NTSC or RGB[1] PPU. How long will it take for this 49.5 cycle discrepancy to add up? 29830/49.5 = 603 frames.

What happens if you use $4008 = $88 on and $00 off, or other combinations?


[1] I think. Does the RGB PPU really have the same behavior of skipping a dot on the pre-render scanline every other frame that the NTSC PPU has?

by on (#47601)
Quick typo correction : it should've been $2d0 not $240.

Sorry :)

by on (#47602)
Tried using $88/$00 as on/off and it's the same.

I even tried just writing $88 and instead of writing a $00 to turn the voice off, I disabled it in $4015.

No different.

by on (#47603)
In a bid to eliminate a possible Nijuu bug, I removed the calls to Nijuu and in the reset code just did this;


Code:
   lda #$88
   sta $4008
   lda #$ff
   sta $4009
   lda #$00
   sta #$400a
   lda #%00000010
   sta $400b


And at approximate $2d0 frames in, you get a click.

Can some people try it and see if you get the same? Also can someone try it on a cart?

by on (#47604)
Disch wrote:
Are you sure this is coming from the Triangle and not another channel? Try silencing all other channels and see if it goes away. Square/DMC are much more likely to be causing pops than the triangle.

Can you provide a recording of the audio?

The only way I know of that you can make a pop with the triangle is if you zero it's F-value (0 to $400A, $400B) -- or set the F-value to something else crazy low. All other ways of silencing the tri do so "cleanly" in that they don't cause a pop.


Sorry I missed this reply.

Its definitely the triangle - see example code. It also seems to be nothing to do with my audio engine (see code again).

:?

by on (#47607)
Code:
sta #$400a   ;  <-- I'm assuming that '#' is a typo


This sounds like a problem with NEStopia. Nothing in the code you posted would cause a pop/click/whatever.

by on (#47611)
Disch wrote:
Code:
sta #$400a   ;  <-- I'm assuming that '#' is a typo


This sounds like a problem with NEStopia. Nothing in the code you posted would cause a pop/click/whatever.


Oops, yeah, typo. Strangely it compiled OK :)

I'm hoping it's a Nestopia issue. It doesn't happening in Audio Overload, as I said, but it's a matter of deciding which one to trust :)

Are you in a position to test it yourself? Or on a a cart?

by on (#47614)
Sadly, no. Sorry. All I could do is test it on other emulators, which doesn't help any for a definitive response.

by on (#47615)
Disch wrote:
Sadly, no. Sorry. All I could do is test it on other emulators, which doesn't help any for a definitive response.


No worries, man. Thanks for trying the other emulators. So can you report that you had it happen in Nestopia but not in any other?

by on (#47616)
I'd try it on an NES, but all I have is a PowerPak, and PowerPak has its own menu that would screw with the timing.

by on (#47617)
Err, well, I could test in other emus, but I didn't mean to make it sound like I would. Honestly I switched to Ubuntu semi-recently and haven't gotten around to getting any NES emus yet. Assembling a ROM and then testing it on a myriad of emulators that I'd have to find and download is more work than I'm willing to do (especially since this is nothing you couldn't try out on your own)
:oops: :P

by on (#47620)
It is a bug with Nestopias sound code. Try to pause emulation to stop the sound and then start it again, it causes the same pop for me after the same amount of time.

by on (#47626)
I noticed that when I pause Nestopia emulation, it recenters the DC killer. That caused problems when I tried to record my volume test program.

by on (#47629)
I don't know if it is related to this, but the game Blaster Master / Meta Fight exhibits a similar problem with "popping" occurring every several seconds. Throughout every (?) music track, even when music tracks have stopped, there is a popping that you can hear (on a real system, of course.)

by on (#47638)
tepples wrote:
I noticed that when I pause Nestopia emulation, it recenters the DC killer. That caused problems when I tried to record my volume test program.


Ah, that would explain the waveform I saw when I recorded the output of Nestopia. You see a short positive DC offset that normalises itself over a few frames.

Thanks everyone for your input - I can put that one to bed now :)