DMC bias?

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

Post Reply
gravelstudios
Posts: 70
Joined: Mon Mar 13, 2017 5:21 pm
Contact:

DMC bias?

Post by gravelstudios » Sun Jan 27, 2019 11:18 am

I want to thank everybody for the help I've been given so far. It's really appreciated. I have a question about how the DMC channel works that I can't find anywhere online.

the DMC channel has a 7 bit output, so that's a range of 0 - 127. a 1 in the data stream means the next sample is one higher, and a 0 means it's one lower, correct? if no sample is playing, where is the 'neutral' position? if you look at a waveform in an editor like audacity, some of the samples are positive and some are negative, oscillating back and forth around 0. for DMC samples, is it correct to think of 64 as being the neutral '0' position and the waveform oscillating higher and lower than that? If that's the case, when the channel goes from silent to playing a sample, what position does it start from? if it starts from 0, then wouldn't that mean the sample would have to begin at it's lowest point rather than a neutral point? or does it start at some middle value (such as 64-ish) and then oscillate from there (as if it had something like DC bias applied to it)?

gravelstudios
Posts: 70
Joined: Mon Mar 13, 2017 5:21 pm
Contact:

Re: DMC bias?

Post by gravelstudios » Sun Jan 27, 2019 11:29 am

OK, so I saw this on the Wiki:
It is loaded with 0 on power-up, and can be updated by $4011 writes and delta-encoded sample playback.
Is there a standard way to get from 0 to a nice neutral spot for the waveform to begin at? Should every sample begin with 8 bytes of $FF to get the output to the center? Or am I completely misunderstanding what is going on?

User avatar
dougeff
Posts: 2599
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: DMC bias?

Post by dougeff » Sun Jan 27, 2019 11:41 am

Sound waves, usually, go up and down.

If you start at 0, full bottom, and the signal goes down...the output just stays put at zero until it gets an up signal. Thus it self corrects to a medial position (perhaps with some clipping at the very start of the tone)

You could intentionally set a middle point, just before each DMC sample play, but you get a slightly popping sound.

(edited)
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
rainwarrior
Posts: 7640
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: DMC bias?

Post by rainwarrior » Sun Jan 27, 2019 11:53 am

gravelstudios wrote:Is there a standard way to get from 0 to a nice neutral spot for the waveform to begin at? Should every sample begin with 8 bytes of $FF to get the output to the center? Or am I completely misunderstanding what is going on?
If you want this, just write 64 to $4011 at the start of your program. The sudden pop from 0 to 64 should be acceptable during reset/startup.

After that, it's just a matter of playing samples that are balanced so they'll stay in the middle. As dougeff said, there's a self-balancing aspect to it, since any sample that ends up pushing against the wall will end up pushing itself off back toward the centre.

As for the other idea, to pop to a starting position for every sample, Famitracker has that as an option too. Some people like the pops, esp. to add some kick to a bass drum sample. (I don't like it personally, and some emulators have an option to suppress this popping sound, too.)

There's another disadvantage of DPCM, because it shares a nonlinear DAC with the noise and triangle channels, the higher the DMC output value, the noise and triangle will get a bit attenuated. Nintendo actually used this to deliberately attenuate the triangle channel in Super Mario Bros. and Startropics, it seems. SMB seems to have a device will write incrementing values to $4011 each frame to "smoothly" reach the setting for that stage's music (produces a quiet 60hz buzz), and Startropics uses it to help fade out the music during transitions.

gravelstudios
Posts: 70
Joined: Mon Mar 13, 2017 5:21 pm
Contact:

Re: DMC bias?

Post by gravelstudios » Sun Jan 27, 2019 12:46 pm

thank you both! this is exactly what I needed to know.

Post Reply