Preparing samples for PCM/DPCM

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Preparing samples for PCM/DPCM
by on (#42337)
I've been experimentating with NES msuic tracking a lot lately, and I try to understand the workings of the DPCM algoroithm. I read skrasms blog which helped me a bit.

I work with Famitracker, which includes a Wave PCM to DPCM converter. The higher frequencies tend to get heavily distorted within the encoding process. So I edited the samples I want to use with an equalizer and toned down the higher frequencies. The samples became a bit better, still they don't really meet the quality of those samples used by Konami / Sunsoft / etc.

I guess that I need to encode my edited samples to another PCM format, before I load them as DPCM. However I have no clue which one is advised.

by on (#42340)
My personal experience has been that to get highish fidelity you need to limit the input samples to about 1/4 of full scale (or about -12dB). This unfortunately means that the output was only (practically) 4bit, but I at least didn't hear noticeable attenuation in the high frequencies

by on (#42361)
I remember cutting samples down to about 1/8th of the original volume before converting. But that was using an old tool with nerdtracker2 (ft could handle it different).

What helped me a bit was taking DPCM samples and coverting them to PCM, to see how they looked compared to what I was converting. Which made the low volume apparent, because they turn out extremely quiet after conversion back to 8-bit PCM.

by on (#42374)
Channel 5 on the NES uses effective values 0-63, while 8-bit wav files use 0-255. That's part of why I built a volume control into my converter.

by on (#42376)
The first thing that I have to ask is what qualities you hear in the samples that you like. The samples I've heard in games tend to be all over the place in terms of quality. Sometimes they're layered with noise to fake better high frequencies (like the sweeeet snare drum in the first track of Ninja Gaiden 2).

Another detail that is harder to know is how the PCM -> DPCM converter you are using actually works internally. Since this is a lossy kind of compression, there can be multiple possible results from the same starting point. The previous posts about needing to lower the volume of the .wav file going in make me wonder if the converter algorithm is unstable. Can you post a .wav example before and after the converter you're using?

by on (#42380)
My converter outputs a decompressed copy in 'decomp.wav' as it compresses. This was originally a debugging tool, but I found it useful for tracker prototypes of NES music and demonstrations on nesdev.com/bbs, so I kept it.

I took a measure (1.75 s) of the Amen break, looped it, converted it to 33488 Hz (close to rate $F), set it to fade at 3 dB per repetition, ran it through my converter at no oversampling (100% rate) and full volume (±32), and compared the original wave with the 'decomp.wav' that my converter writes.
Code:
81 amen_break_fade.wav nul 100 32

(On Linux, substitute "/dev/null" for "nul". Or change it to "amen_break_fade.dmc" to save the output.)

You can hear in the before and after waves (375 KiB zip file) that individual hits on the ride cymbal get lost in the slope overload until the sixth time through.

by on (#42386)
Here is a NSF with 2 DPCM samples, a kick with and without a layered clap. I have slightly cut the higher frequencies at a range of 1kHz to 16kHZ (I have deleted the EQ's presets so I can't look it up to give exact values), and I also cut the kick at 50Hz and lowered it a bit at 150Hz. Note, that I've taken those samples from a sample CD, where the wave files are already mastered. Also I didn't change the volume of the samples while editing. I think they sound OK, but I am still not satisfied.

Download


Sample Pack

by on (#42387)
Found out something that s*cks a lot.

Seems like the volume slider in FamiTracker is kind of linked with the one for the general audio output. That's awesome... not.

I'll try it again, till then this question shall be put off. Thanks for your advices.