CVSD Compressed audio example
Moderator: Mask of Destiny
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
As far as commenting goes, "Real programmers never comment - if it was hard to write, it should be harder to read, and impossible to change."
Yeah, the computer side compressor code can be more "fun" to write... thankfully the cvsd compressor was pretty easy.
By the way, here's the same game music demo, but compressed at 22kHz instead of 11kHz. I think you're right... I think it's better.
GameMusic-2.7z
Yeah, the computer side compressor code can be more "fun" to write... thankfully the cvsd compressor was pretty easy.
By the way, here's the same game music demo, but compressed at 22kHz instead of 11kHz. I think you're right... I think it's better.
GameMusic-2.7z
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
hehe, spot onChilly Willy wrote:As far as commenting goes, "Real programmers never comment - if it was hard to write, it should be harder to read, and impossible to change."
the new demo sounds better, but quite minimally :/ So yea, voice samples is what its best at I suppose...
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Okay, here's another full archive: musicdemo-3.7z
This has "Eye of Time" compressed at 22kHz as well as the game music at 22kHz. Includes source.
This has "Eye of Time" compressed at 22kHz as well as the game music at 22kHz. Includes source.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
And yet another full archive.
musicdemo2-1.7z
This is a modification on the code - where the previous code did 16:1 compression (eqv 8:1), this does 8:1 (eqv 4:1). Basically, 2 bits per sample instead of 1. This is the game music. See what you think. For more info on this compression, go to my CVSD thread linked in the first post.
musicdemo2-1.7z
This is a modification on the code - where the previous code did 16:1 compression (eqv 8:1), this does 8:1 (eqv 4:1). Basically, 2 bits per sample instead of 1. This is the game music. See what you think. For more info on this compression, go to my CVSD thread linked in the first post.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Okay, I wanted to see how this works with more typical game music, so I made up a test with the Sonic CD present level CDDA tracks.
musicdemo2-2.7z
This one can play up to 8 songs. Press the directions for songs 1 to 4, and hold B while pressing a direction for songs 5 to 8. I only had room for seven songs in the rom, so song 8 is just the same as song 1.
musicdemo2-2.7z
This one can play up to 8 songs. Press the directions for songs 1 to 4, and hold B while pressing a direction for songs 5 to 8. I only had room for seven songs in the rom, so song 8 is just the same as song 1.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Me guesses not everyone has access to it. It's probably a "devs-only" page or something. Of course, if you don't have access, YOU should considering you're one of those devs.
Maybe one of the mods can add you to the list. In the meantime, lemme make a brief explanation here, and the code is in the arcs, of course.
CVSD normally compresses the samples to just a sign bit. That tells the decompressor whether to add or subtract the delta from the derived sample. If delta was a constant, clearly you would only ever have slow saw-tooth representations of the original wave. The way CVSD works is to change delta after every sample depending on some criteria. The "normal" algorithm changes delta if you have three or four 1s or 0s in a row. In my code, I changed delta larger if the current bit matched the previous bit, and smaller if they differed. That was the original code. One bit per sample means it was equivalent to 8:1 compression compared to what you would store in the Genesis to playback. Of course, it really isn't suitable for music.
So my latest experiment decided to bump the samples to two bits instead of one. We still have the sign bit, but now an extra bit is used to tell the decompressor which way to shift delta. Instead of implicitly shifting based on matching previous bits, we now shift according to which will give less noise. That's what the last two arcs have used, and at two bits per sample, you get four to one compression. It can be suitable for music - some songs seem to encode very well at 4:1, while others show a little more noise than you'd like in your music. So this may or may not be suitable for people to use, depending on specific circumstances.
Again, remember that this is compressing 16 bit audio. While the code decompresses to 16 bits, only the top 8 bits are used with the YM2612 DAC. I may make another example of using 10 to 12 bits with the 32X audio.
Maybe one of the mods can add you to the list. In the meantime, lemme make a brief explanation here, and the code is in the arcs, of course.
CVSD normally compresses the samples to just a sign bit. That tells the decompressor whether to add or subtract the delta from the derived sample. If delta was a constant, clearly you would only ever have slow saw-tooth representations of the original wave. The way CVSD works is to change delta after every sample depending on some criteria. The "normal" algorithm changes delta if you have three or four 1s or 0s in a row. In my code, I changed delta larger if the current bit matched the previous bit, and smaller if they differed. That was the original code. One bit per sample means it was equivalent to 8:1 compression compared to what you would store in the Genesis to playback. Of course, it really isn't suitable for music.
So my latest experiment decided to bump the samples to two bits instead of one. We still have the sign bit, but now an extra bit is used to tell the decompressor which way to shift delta. Instead of implicitly shifting based on matching previous bits, we now shift according to which will give less noise. That's what the last two arcs have used, and at two bits per sample, you get four to one compression. It can be suitable for music - some songs seem to encode very well at 4:1, while others show a little more noise than you'd like in your music. So this may or may not be suitable for people to use, depending on specific circumstances.
Again, remember that this is compressing 16 bit audio. While the code decompresses to 16 bits, only the top 8 bits are used with the YM2612 DAC. I may make another example of using 10 to 12 bits with the 32X audio.
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
2bit files sound much nicer
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Yeah, the difference was really amazing. It also gave me an idea for modifying the 1 bit encoder to maybe make that sound better. Going to try that this weekend.TmEE co.(TM) wrote:2bit files sound much nicer
I've been looking around for a 2 bit ADPCM routine so I could compare that to the 2 bit CVSD. All the ADPCM I've come across is all 4 bit. Anyone know of any 2 bit ones?
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
I have an implementation of a 2bit flavor of ADPCM made for 8bit stuff in my notebook.....
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Okay, here's demo 3.
musicdemo3.7z
This is just a change in the 8:1 compressor (I did change maxDelta, so everything is technically new). Before, the compressor simply chose the sign based on whether the next input value was greater than or less than the current derived sample. This compressor first calculates the error if you chosen the sign one way or the other, and then adds the minimum error for the NEXT sample after this one based on the same criteria. So this compressor chooses the sign based on what minimizes the error over the next two samples. The idea is to try to minimize the error (noise) rather than blindly using the current sign.
The rom image in this is like in demo 2 - the Sonic CD present levels. This is still noisy, just not quite as noisy as the last demo 1 release. I'd use this for music only in extreme circumstances - the music MUST be digitized and you NEED 8:1 compression. Otherwise, use the 4:1 compression. Note - I can do this same kind of error minimizing in the 4:1 compressor. It currently only tries to minimize the noise based on the next sample, not the next two samples.
musicdemo3.7z
This is just a change in the 8:1 compressor (I did change maxDelta, so everything is technically new). Before, the compressor simply chose the sign based on whether the next input value was greater than or less than the current derived sample. This compressor first calculates the error if you chosen the sign one way or the other, and then adds the minimum error for the NEXT sample after this one based on the same criteria. So this compressor chooses the sign based on what minimizes the error over the next two samples. The idea is to try to minimize the error (noise) rather than blindly using the current sign.
The rom image in this is like in demo 2 - the Sonic CD present levels. This is still noisy, just not quite as noisy as the last demo 1 release. I'd use this for music only in extreme circumstances - the music MUST be digitized and you NEED 8:1 compression. Otherwise, use the 4:1 compression. Note - I can do this same kind of error minimizing in the 4:1 compressor. It currently only tries to minimize the noise based on the next sample, not the next two samples.
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
Chilly Willy wrote:Well, if it's not "secret", maybe you could post some code? Or if the code is secret, but the compression isn't, post some pseudo code on how it works.
That's all existing info about it...
The last demo has quite little noise, but it sounds like its 4bit audio, hehe
EDIT: it seems you're not really using your ICQ account ?
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Hahahaha! I've worked from worse.TmEE co.(TM) wrote:Chilly Willy wrote:Well, if it's not "secret", maybe you could post some code? Or if the code is secret, but the compression isn't, post some pseudo code on how it works.
That's all existing info about it...
I don't use any of my IM accounts unless someone arranges to meet first. I dislike IM - I much prefer email since IM tends to make people linger when they could be doing something else. I generally check my email twice a day, so it's not a big deal in my opinion.The last demo has quite little noise, but it sounds like its 4bit audio, hehe
EDIT: it seems you're not really using your ICQ account ?
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm