CVSD Compressed Audio

Chilly Willy

Established Member
In case folks don't check out SpritesMind, I've been working on CVSD compression. I just posted an example of using the Z80 to decompress the audio. Comes with source.

musicdemo-1.7z

A slight overview: CVSD takes 16 bit samples at one frequency, then compresses them down to 1 bit per sample at twice the frequency (that helps suppress noise). Compared to the original sample, you get 8 to 1 compression. Compared to how you'd store it in the Genesis (8 bit PCM at the original frequency), that's an effective compression of 4 to 1. The demo is capable of playing up to 24 minutes of audio at that compression level, using just the Z80. The code isn't your "standard" CVSD, but my own variation.
 
Slight update to the demo - the original is about 9.5% faster than the target sample rate of 22050 Hz. This update is dead on. It's just the rom binary and the Z80 driver source since that was the only thing to change.

musicdemo-2.7z

In case someone was wondering, the music is Cassiopeia's "Eye of Time" found here.
 
Chilly Willy said:
Slight update to the demo - the original is about 9.5% faster than the target sample rate of 22050 Hz.


Did you miss some syncho ?
 
No, there is no synchronization on the Z80 + YM2612. All digital audio on the Genesis must use carefully written loops where the author sums the times of all opcodes between successive sample writes to meet the rate they wish to play samples at.

Anywho, my first code was simply getting it to work. I knew from my first calculations I'd be close, but off a little. I went ahead and put it out because I wasn't sure if or when I'd tighten up the timing. I did the calculation the other day and saw it was a simple fix (four NOPs per sample write in 7 of the 8 unrolled decompressor stages) to make it nearly perfect, so I went ahead and updated the Z80 code and recompiled for the second release of the demo. By the way, "dead on" means the new code is 0.47% fast instead of 9.5% fast like the previous code. I can live with that. :)
 
After talking with TmEE today, we decided that compressing at 22kHz instead of 11kHz makes the sound better, so here's a new archive: musicdemo-3.7z

You get two roms and the source. The first rom is the "Eye of Time" compressed at 22kHz. You might compare it to the earlier release. The other is a smaller 2MB rom with some game-type music sampled at 22kHz.
 
And yet another experiment. This one is very similar to the above, but uses two bits per sample instead of one. This has the game music in the rom image.

musicdemo2-1.7z

The original code only had a sign bit for each sample. It would double the delta if the last sample sign matched the current one, and halve it if the signs didn't match. This new code makes the shift bit separate from the sign bit, hence two bits per sample, but because you can pick on every sample whether to double or halve the delta depending on which gives less noise, the sound is much better.
 
Here's demo 3. It changes the 1 bit compressor to try to minimize noise over the next two samples rather than blindly using the current sign. It's still noisy, but slightly less noisy than the original compressor. I'd still use the 2 bit compressor for music, but this is better if you NEED it.

musicdemo3.7z
 
Back
Top