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 > Generating "proper" IMA ADPCM files

#160538 - M3d10n - Thu Jul 17, 2008 1:40 pm

Did anyone manage to create IMA ADPCM encoded audio files that the DS can play properly? I got code for loading wave files and can play PCM fine, but IMA ADPCM sounds distorted, but the sound is recognizable. I tried many different convertion tools, but I always get the same result.

I know there are looping issues, but I plan using ADPCM for non-looping sound effects.

#160580 - eKid - Fri Jul 18, 2008 12:14 am

My sound engine supports adpcm compression. :)
I'm just waiting on the next libnds before I release it. :)

Sample tune which uses IMA-ADPCM samples:
http://ekid.nintendev.com/adpcm.nds

#160584 - tepples - Fri Jul 18, 2008 4:04 am

I figured out ADPCM some time last year. My on-screen keyboard demo uses ADPCM compressed samples. Should I post source?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#160606 - M3d10n - Fri Jul 18, 2008 10:14 am

Are you guys feeding the ADPCM samples directly into the hardware or decoding them in software?

If you can post source, I only need to see the playback parameters and how you guys managed to encode them.

#160688 - tepples - Sun Jul 20, 2008 12:28 pm

M3d10n wrote:
Are you guys feeding the ADPCM samples directly into the hardware or decoding them in software?

On the GBA it was software, but on the DS it's hardware.

Quote:
If you can post source, I only need to see the playback parameters and how you guys managed to encode them.

My encoder is based on "myima.c" from my old 8ad project. I used it on the DS with these changes, based on how the DS uses IMA ADPCM:
  • Use the "ima" format, not "ima9".
  • When calling init_encode_ima(), always set min_index to 0.
  • You'll need to prepend a 4-byte header containing the initial values of last_sample and last_index after you init the encoder but before you encode anything:
Code:
fputc(last_sample, outfp);
fputc(last_sample >> 8, outfp);
fputc(last_index, outfp);
fputc(0, outfp);

At this point, because the code is so old, I'd be willing to change the license from GPL+exception to the same MIT license used for the example decoder.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.