audio buffering and timing discrepancies

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: audio buffering and timing discrepancies

Post by Dwedit »

If you're looking for a good MMC3 test program that breaks a lot of emulators, try my Chu Chu Rocket homebrew game.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
James
Posts: 431
Joined: Sat Jan 22, 2005 8:51 am
Location: Chicago, IL
Contact:

Re: audio buffering and timing discrepancies

Post by James »

koitsu wrote:When firing Megaman's gun, there is what sounds like a bass-y "fart" noise at the end of the effect.
miker00lz wrote:Yeah, you're right I can hear the fart noise.
Did you ever find the cause of this? I'm currently writing my APU emulation code (moving off of Blargg's nes_snd_emu library) and have run into the same issue. Here's what's being output from the square2 channel when Mega Man jumps off of the title screen. The fart noise is the low frequency wave between the higher frequency chunks.

Image

Here's a log of writes to the channel. The first column is the sample number (multiply by 37 to get CPU cycle). The writes are time (s.ms): address - value, and the interspersed lines represent changes in square channel output (envelope volume, output yes/no, sweep unit output, timer period, and length counter value).

Code: Select all

00146109: 0009 0001 0001 0114 0254
00146115: 0009 0000 0001 0114 0254
00146159: 0009 0001 0001 0114 0254
00146165: 0009 0000 0001 0114 0254
00146208: 0009 0001 0001 0114 0254
00146215: 0009 0000 0001 0114 0254
00146258: 0009 0001 0001 0114 0254
00146264: 0009 0000 0001 0114 0254
00146308: 0009 0001 0001 0114 0254
00146314: 0009 0000 0001 0114 0254
00146358: 0009 0001 0001 0114 0254
00146364: 0009 0000 0001 0114 0254
00146407: 0009 0001 0001 0114 0254
00146414: 0009 0000 0001 0114 0254
00146457: 0009 0001 0001 0114 0254
00146463: 0009 0000 0001 0114 0254
00146507: 0009 0001 0001 0114 0254
00146513: 0009 0000 0001 0114 0254
00146540 57.877: 4004 - 39
00146544 57.877: 4006 - 33
00146554 57.877: 4015 - 07
00147344 57.888: 4004 - 39
00147348 57.888: 4006 - F4
00147349 57.888: 4007 - FF
00147358 57.888: 4015 - 07
00148011: 0009 0001 0001 2036 0030
00148122: 0009 0000 0001 2036 0030
00148149 57.898: 4004 - 39
00148153 57.898: 4006 - B5
00148163 57.898: 4015 - 07
00148872: 0009 0001 0001 1973 0030
00148954 57.908: 4004 - 39
00148958 57.908: 4006 - 76
00148968 57.908: 4015 - 07
00148979: 0009 0000 0001 1910 0030
00149702: 0009 0001 0001 1910 0030
00149759 57.919: 4004 - 39
00149763 57.919: 4006 - 37
00149773 57.919: 4015 - 07
00149805: 0009 0000 0001 1847 0030
00150504: 0009 0001 0001 1847 0030
As far as I can tell, I'm correctly outputting sound based on the values being written to $40xx. And when comparing my code to other emulators, everything looks ok. I'm stumped.
get nemulator
http://nemulator.com
User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Re: audio buffering and timing discrepancies

Post by blargg »

James wrote:moving off of Blargg's nes_snd_emu library
At first I was going to ask what motivated this, then I saw it was off my APU code, not the resampling library. Your own APU code; more power to you! It's fun to implement.

As for the problem sound, I bet you aren't implementing the sweep's silencing of a channel when its frequency gets too low. Remember that this occurs even when sweep is disabled. I haven't looked over your log, just taking a guess.
User avatar
James
Posts: 431
Joined: Sat Jan 22, 2005 8:51 am
Location: Chicago, IL
Contact:

Re: audio buffering and timing discrepancies

Post by James »

blargg wrote:
James wrote:moving off of Blargg's nes_snd_emu library
At first I was going to ask what motivated this, then I saw it was off my APU code, not the resampling library. Your own APU code; more power to you! It's fun to implement.
It was fun -- then I ran into this issue :lol:. Thanks, by the way, for the library and all the documentation!
As for the problem sound, I bet you aren't implementing the sweep's silencing of a channel when its frequency gets too low. Remember that this occurs even when sweep is disabled. I haven't looked over your log, just taking a guess.
Unfortunately, that's not it.
get nemulator
http://nemulator.com
User avatar
James
Posts: 431
Joined: Sat Jan 22, 2005 8:51 am
Location: Chicago, IL
Contact:

Re: audio buffering and timing discrepancies

Post by James »

James wrote:
blargg wrote:As for the problem sound, I bet you aren't implementing the sweep's silencing of a channel when its frequency gets too low. Remember that this occurs even when sweep is disabled. I haven't looked over your log, just taking a guess.
Unfortunately, that's not it.
Actually, that's exactly what it is :oops:. I completely misunderstood what was going on there...

Thanks!!!
get nemulator
http://nemulator.com
Post Reply