gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > ms-adpcm decoder

#166791 - eKid - Wed Feb 18, 2009 7:57 am

Here is something that was sitting on my disk for awhile, it's an MS-Adpcm decoder class that reads a WAV file and outputs PCM data. I didn't want this to go to waste so I cleaned it up a bit and made another small player class that handles simple playback commands like play, pause, and stop, so you can just do 'player.play( "file.wav" )' to play a wav file using the maxmod streaming stuff.

The decoder only supports stereo 'MS-ADPCM' compressed WAV files (any sample rate). The CPU load is around 8 scanlines for 32KHz playback plus another ~8 scanlines when it reads from the file. Sample loops are supported too (actually it looks like maybe i forgot to support samples that don't have loops hehe).

Source code is included, for whatever purpose.

http://ekid.nintendev.com/ms_adpcm_ds.zip

#166794 - DiscoStew - Wed Feb 18, 2009 9:42 am

Some people may call this competition......



....but I call it development, and everyone wins. At 16 scanlines max for 32kHz stereo playback, you can't go wrong. Even if I tried getting back into assembly, I probably couldn't even match this speed with my IMA-ADPCM decoder.

Works great, but for people wanting to use the source, there is a little problem with the "on_stream_request" function, as it returns an mm_word type rather than a void type (a future change to Maxmod?). Made the simple change to that, making it void instead, and removing the return from the call to the "i_stream_request" function. Compiles fine after that, and plays fine.
_________________
DS - It's all about DiscoStew

#166795 - eKid - Wed Feb 18, 2009 10:02 am

oh, forgot to mention that it uses the svn version of maxmod. There's a small feature added for the next release that makes it where you can return how many samples you satisfied in your streaming callback.

oh and not to compete or anything :P, im just throwing this out because i dont see myself working on it any more. maybe sometime we could combine both of our decoders, along with a few more formats and make a cool wav decoding lib.

#166801 - Odorules - Wed Feb 18, 2009 3:01 pm

I tried this code to compare with the DiscoStew's one but I didn't get it to work. I have errors with asm files. I think it's because my makefile is very old.

#166860 - DiscoStew - Sat Feb 21, 2009 8:13 am

Hey eKid, you mind if I use your current decoding template for redoing my own ima-adpcm decoder? I figure that if the code setup (not actual decoding) is similar, it'll be easier to mix them together (as I will also attempt to convert the decoding to assembly). The only difference would be the structure for holding the data such as the predictors, but that can be figured out later.
_________________
DS - It's all about DiscoStew

#166862 - eKid - Sat Feb 21, 2009 9:27 am

Sure, go ahead. I was trying to come up with some abstract code to handle multiple decoding methods, but I couldn't come up with anything great.. :S