The chip doesn't use ADPCM. It uses the little used simple sign bit format. Rather than using two's complement for positive and negative values it instead has a 7-bits of magnitude and a simple sign bit. Sound Forge supports this format.
So 0xFF is -127 instead of -1. Charles MacDonald dug up a PDF datasheet of a compatible chip and I've got it on my site (www.retrodev.com) in the Sega CD section. It goes into fairly good detail, but you'll have to adjust all the frequency calculations they give as the chip in the Sega CD runs at 12.5MHz and I believe the examples in the datasheet use 8MHz or so.
Originally posted by Mask of Destiny@Tue, 2005-07-26 @ 11:33 AM
The chip doesn't use ADPCM.Â It uses the little used simple sign bit format.Â Rather than using two's complement for positive and negative values it instead has a 7-bits of magnitude and a simple sign bit.Â Sound Forge supports this format.
So 0xFF is -127 instead of -1.Â Charles MacDonald dug up a PDF datasheet of a compatible chip and I've got it on my site (www.retrodev.com) in the Sega CD section.Â It goes into fairly good detail, but you'll have to adjust all the frequency calculations they give as the chip in the Sega CD runs at 12.5MHz and I believe the examples in the datasheet use 8MHz or so.
PCM samples have to start on a 256byte boundary in PCM RAM as the start address register is only 8-bits wide so it only provides the upper 8-bits of the start address. The repeat address has full 16-bit resolution however.
I happened across this thread and felt a little extra info is necessary in case someone else comes across this while trying to use the SCD PCM.
First, the format of the PCM audio is 8-bit sign-magnitude. Bit 7 is the sign, where 1 stands for positive values, and 0 stands for negative values. So yes, there is +/- zero on the SCD PCM. 1 to 127 represent -1 to -127. 1+128 to 126+128 stand for positive 1 to 126. 127+128 is a special marker value - fetching 255 tells the PCM chip to load the loop pointer registers and fetch another sample. This is how looping in the SCD PCM chip works. Your sample plays forwards from start offset << 8 until it runs across a 255 byte. It then plays from the loop registers until it again finds a 255 byte. This does mean than +127 is NOT a legal sample for the audio. Any PCM audio loader must clamp positive samples to +126.
The natural sample rate is 32552 Hz. This is the master clock (12.5 MHz) divided by 384. To sound their best, sample should be resampled to this rate. However, you might want to resample to lower rates to use less memory... you've only got 64KB after all. The PCM chip uses a fixed point increment to determine where the next sample is fetched from. This is a 5.11 fixed point number, where 2048 is 1.0, 1024 is 0.5, etc. This means the sample increment can go up to 31.something. Because of this, samples MUST be followed by 32 loop markers (255) in order for the loop marker to be picked up no matter the increment. This is another thing your audio loader must keep in mind - once the sample is clamped and loaded into PCM ram, follow it with 32 loop markers.
So while you can play samples at a rate higher than 32kHz, it does so by skipping samples, which introduces aliasing into the output. If you intended to play samples/notes at increments higher than 1.0, you should filter the sample accordingly. Setting the increment of a pcm channel to 1.0 (2048) plays the sample at 32552 Hz. Suppose you sampled the audio at 16276 Hz to use half the memory? In that case, play the sample with an increment of 0.5 (1024) to play back at 16276 Hz. Remember, the channel ALWAYS plays at 32552 Hz, but the increment chooses where the next sample comes from. An increment of 0.5 means it takes two sample periods to advance one sample, which means the sample plays at half the natural channel rate, or 32552/2 Hz = 16276 Hz.
This is the key to playing music with the PCM chip - setting the proper increment to reflect the frequency you wish to play the sample at. You might check out my SCD MOD player example to see how you do that in a practical setting. I wrote a library to help in using the PCM chip that is used by the mod player. I note the exact frequencies of the PCM chip here because the difference DOES make a difference in playing music. The difference between 16kHz and 16276 Hz is almost two percent, which doesn't seem like much, but this IS audible if you're familiar with the score playing at the right rates. For sound effects, you might neglect the difference - an explosion played two percent faster is probably going to slip past most people.