questions on the dpcm channel

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
questions on the dpcm channel
by on (#51122)
Hi,
I am quite a newbe at this, so please forgive me if I am asking stupid questions.
I have been playing with MCK, which is a nice little program to write instructions to an .nsf file, using a .mml file.
Using a nice little tutorial I found, I am able to program the two pulse, triangle and noise channels. While I can get the DPCM channel to work, I have three questions about its limitations and how to program it more than I already have, and one question about a playback problem that I am having.
First, suppose I sampled a short sound, a synth bass G. In the mml file, is it easy enough to say "okay, this nsf is a g," and then tell it to play an f, c, etc as needed? If so can you give me an example of how this would be done?
Second, I read that after using 8 kilobytes of memory, the bank is full so you have to switch banks. So if I had a dcm file that was 100 bytes, every time I used it I would be adding 1000 bytes to the bank?
Third, Let's say I have two wav files: a kick, and snare and have converted them to dcm. The dcm files have a sampling rate of 33.4KHZ. The kick sample is 353 bytes and the snare is 1153 bytes. They work fine, but are they too big? Something tells me they should not be this big and I should probably shorten the wavs and use a lower sample rate in DMCconv. Any guidelines on what I should and should not be doing?
Fourth a little off topic, but when playing my snf files with DPCM using the not so fat so plugin in Winamp, there is a lod of DC offset, which fortunately not so fat so is able to elliminate. I've heard that sometimes clicking problems come up with DPCM, I am having none of those at the moment. Are these circumstances normal? Should I try other players?
Any help you can give is greatly appreciated!
Re: questions on the dpcm channel
by on (#51124)
I know very little about MCK, but I do know about sequencers and trackers in general.
raygrote wrote:
First, suppose I sampled a short sound, a synth bass G. In the mml file, is it easy enough to say "okay, this nsf is a g," and then tell it to play an f, c, etc as needed?

Yes, but you have to be careful. There are sixteen different valid sample playback rates, from 4.2 kHz to 33.5 kHz or so, and these represent various intervals relative to the original sample rate.
Say you have a C sampled at 4.2 kHz. You can play it as C, D, E, F, G, A, B in one octave, C, D, F, G, A in the next octave, C, E, G in the third octave, and finally C.
But if you record a B♭ sample, you can play it as B♭, C, D, E♭, F, G, A, then B♭, C, E♭, F, G, then B♭, D, F, B♭.
Sunsoft games use five bass samples to be able to play all notes.

Quote:
I read that after using 8 kilobytes of memory, the bank is full so you have to switch banks. So if I had a dcm file that was 100 bytes, every time I used it I would be adding 1000 bytes to the bank?

For each sample that you use, the NSF contains one copy of each sample and then a couple bytes in the sequence every time you play it back.

Quote:
Let's say I have two wav files: a kick, and snare and have converted them to dcm. The dcm files have a sampling rate of 33.4KHZ. The kick sample is 353 bytes and the snare is 1153 bytes. They work fine, but are they too big?

The formula is one byte for each 8 samples. A 1153-byte snare has 9224 samples and thus 275 ms. Unless that snare sample has Phil Collins style gated reverb, it probably has quite a bit of decay that won't translate well to DPCM; you usually want to cut the original wave about when it hits -36 dB.

Quote:
Fourth a little off topic, but when playing my snf files with DPCM using the not so fat so plugin in Winamp, there is a lod of DC offset, which fortunately not so fat so is able to elliminate.

I wrote this program and ran it on a PowerPak to demonstrate that either my NES or my sound card also has a high-pass filter that kills DC. If your favorite NSF player doesn't, you can apply a high-pass filter in Audacity with a corner frequency around 30 Hz.

Quote:
I've heard that sometimes clicking problems come up with DPCM, I am having none of those at the moment. Are these circumstances normal?

DPCM clicks happen when you abruptly change the DAC's center point. It only happens in those music engines that reset the DAC to center (like lda #$40 sta $4011) before each sample, and happens more often if
  1. you play different samples with different center points,
  2. you cut samples off before letting them go back to center, or
  3. your music engine sets the center point back to the negative rail when NoteOff-ing a sample, like Famitracker.
Without specific experience in MCK, I can't help you much there.

by on (#51125)
Thank you for the reply. However I still have a problem having to do with the converters.
I was using DMCconv, but when I try to change the sample rate, it goes down to 4.4KHZ, which is not what I want. Since the 81.exe thing looked promising, I was going to use it. I downloaded the converter from nesdev.com. In the zip file there were two files, 8to1bit.exe and 1to8bit.exe. so I copied 8to1bit to my C drive, renamed it to 81.exe to make it shorter. Then I downsampled my shorrtened snare to 11186HZ. Then I went into command prompt and typed:
"C:\81.exe" "C:\snare.wav" "C:\snare.dcm"
In other words I did it the same way I did dMCconv.
And got the following error
Stub exec failed:
dos4gw.exe
No such file or directory
I tried it with a 16bit and 8bit wav, results are the same for both. What is wrong?

by on (#51126)
Try the 81.exe from pineight.com instead, listed under "DPCM ripper" here. It's compiled as a Windows command line tool, so it doesn't need any sort of dos4gw extender.

Can you put snare.wav on mediafire or something so I can look at it?

by on (#51130)
Thanks it worked!
The only thing is when I decompressed it to a wav file it gave it with wrong sample rate, but I didn't use any options. I'll try those later. Besides I really don't think it matters just so long as I tell the mml file what the correct sample rate should be for it to sound at the right pitch.

by on (#51199)
@DPCM0 = {"name of sample.dmc",15}

will make the frequency the top frequency, the C that tepples was talking about. Change the number "15" to whatever frequency you want to change its pitch.

@DPCM0 = {"sample.dmc",15}
@DPCM1 = {"sample.dmc",14}
@DPCM2 = {"sample.dmc",13}
@DPCM3 = {"sample.dmc",12}
@DPCM4 = {"sample.dmc",11}

the program only copies the sample once but plays it back at different rates this way.

In your MML, executing those would look like this:

E o0 c c+ d d+ e

by on (#51203)
raygrote wrote:
The only thing is when I decompressed it to a wav file it gave it with wrong sample rate, but I didn't use any options.

The compressor outputs a 'decomp.wav' at the same sample rate you recorded. The decompressor always uses a rate close to rate 12* because that's what a tracker happened to want at the time I wrote it.


* 18.exe writes 16800 Hz to the output wav file's header. On NTSC, the actual rate 12 is exactly one sample per 106 cycles, or 39375000/(22*106) = 16884 Hz; on PAL it's one sample per 98 cycles, or 53203425/(32*98) = 16965 Hz.