Accurate apu_mixer timing?

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
Rahsennor
Posts: 479
Joined: Thu Aug 20, 2015 3:09 am

Accurate apu_mixer timing?

Post by Rahsennor »

I'm trying to make my NSF player pass blargg's apu_mixer tests, starting with the square wave. The section of output that is meant to be silent is quiet, but certainly not silent. Visual inspection of the waveform shows a train of alternating positive and negative spikes, leading me to believe it's a phase issue, and logging the exact cycle of each transition shows that each channel is exactly four cycles out of phase: first the PCM, then Pulse 1, then Pulse 2.

But looking at the test source, I see this:

Code: Select all

	ldx #$6F        ; period = 896*2
	ldy #$00
	stx $4002
	stx $4006
	sty $4003
	sty $4007
The phase-resetting writes occur exactly four cycles apart. Does this mean the output I'm hearing is an artifact of the test, or is there an obscure timing issue in the APU I'm not emulating properly?
ap9
Posts: 43
Joined: Sat Jun 01, 2013 11:55 am
Location: Maine, U.S.A.
Contact:

Re: Accurate apu_mixer timing?

Post by ap9 »

First of all, the test wave isn’t silent, it’s mostly silent with close-cancelation artifacting (includes spikes), and grows more audible toward the end. There are recordings of these tests currently available on github.

As far as timing goes, the synth channels have a slight clocking delay, whereas the DMC 4011 write is a direct setting of the DA output, with immediate effect. It’s easiest to render a sample before clocking the period to simulate this delay.

Be sure to account for all of the CPU cycles when updating the sound results; the actual write occurs on the last instruction cycle.
User avatar
nothingtosay
Posts: 39
Joined: Mon May 19, 2014 11:46 pm

Re: Accurate apu_mixer timing?

Post by nothingtosay »

I just want to say that it makes me happy that you're trying to make a perfectly accurate NSF player and I look forward to you reaching your goal!
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Accurate apu_mixer timing?

Post by zeroone »

nothingtosay wrote:I just want to say that it makes me happy that you're trying to make a perfectly accurate NSF player and I look forward to you reaching your goal!
Given that user name, I can't tell if this comment is a joke or not.
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Accurate apu_mixer timing?

Post by Zepper »

User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: Accurate apu_mixer timing?

Post by thefox »

Why would you try to draw any conclusions based on a username? It's not like he can change it for every single post he makes.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
nothingtosay
Posts: 39
Joined: Mon May 19, 2014 11:46 pm

Re: Accurate apu_mixer timing?

Post by nothingtosay »

I was being sincere, I assure everyone.
Rahsennor
Posts: 479
Joined: Thu Aug 20, 2015 3:09 am

Re: Accurate apu_mixer timing?

Post by Rahsennor »

ap9 wrote:First of all, the test wave isn’t silent, it’s mostly silent with close-cancelation artifacting (includes spikes), and grows more audible toward the end. There are recordings of these tests currently available on github.
Thanks for the information, and links. My NSF player sounds almost exactly like the recording on the square test, so I guess I'm on target.

Sorry for not noticing your reply sooner; I haven't checked in for a while due to being very busy with other stuff.
Post Reply