DPCM Best Practices?

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
DPCM Best Practices?
by on (#90707)
I keep getting that annoying 57% volume effect on the Triangle and Noise channels when a 1-bit DPCM sample cuts off its predecessor. Manually writing #00 to $4011 fixes that, but also causes a distinct popping sound when over-utilized. Adv. of Bayou Billy writes #00 to $4011 at the same time it loads the other three DPCM registers with new sample data... yet when I tried replicating that in SMB1, I got substandard sample quality with popping... >:-( Not to mention that wonderful A9-0F-8D-15-40 / A9-1F-8D-15-40 juggling act that seems to produce different results in different games... What's the best order of operations here?


My second question is probably dumb, so I saved it for last. There's no chance whatsoever that MMC5's 8-bit PCM channel can also play 1-bit DPCM samples...... right?

by on (#90708)
Maybe modify the sample to make it return to 00 at the end.
And the MMC5's PCM channel is completely worthless. It doesn't do DMC.

by on (#90711)
Writing $0F/$1F to the sound channel enable register ($4015) works as long as a game isn't using these enable registers to turn off channels. It'd work with my music player, which uses the envelope registers ($4000/$4004/$4008/$400C) to turn off channels, but music players like SMB1 that make heavy use of the length counter might use $4015 instead.

If you try to add samples to a game not designed with DPCM in mind, you might get garbage button presses while a sample is playing due to clock noise generated by the DMA unit. There are DPCM-safe controller reading routines, and there are DPCM-unsafe controller reading routines. The latter are simpler and faster, and they're actually required for peripherals where rereading has side effects (such as the Super NES Mouse and, if I remember correctly, the Vaus controller for Arkanoid).
Re: DPCM Best Practices?
by on (#90717)
Dr. Floppy wrote:
I keep getting that annoying 57% volume effect on the Triangle and Noise channels when a 1-bit DPCM sample cuts off its predecessor. Manually writing #00 to $4011 fixes that, but also causes a distinct popping sound when over-utilized. Adv. of Bayou Billy writes #00 to $4011 at the same time it loads the other three DPCM registers with new sample data... yet when I tried replicating that in SMB1, I got substandard sample quality with popping... >:-( Not to mention that wonderful A9-0F-8D-15-40 / A9-1F-8D-15-40 juggling act that seems to produce different results in different games... What's the best order of operations here?

Try to understand where the popping comes from. It comes from sudden changes in volume, so if the DPCM counter is at a value other than zero when you write zero to it, it will pop. How loud the pop is depends on the previous value (going 127->0 or vice versa will produce the biggest pop).

Then it's just a matter of trying to work around the issue, by doing stuff like what Dwedit suggested.