ADPCM sample

Mysoft
Posts: 20
Joined: Thu Jun 09, 2011 11:56 am

ADPCM sample

Post by Mysoft » Sun Jun 26, 2011 9:15 pm

so i was trying to play an ADPCM sample... but without success...

according to gbatek it's IMA-ADPCM, but so i converted a 44khz 16bit mono sample, to IMA-ADPCM (i tried using the ACM functions from winapi, and i tried generating an IMA-APDCM.wav and stripping the header out)

both are sounding poorly on DS.... so what i'm missing? the DS ima-adpcm is different? and if so there's some tool or code (code would be better, but a program that can convert a raw sample to adpcm would be nice enough)....

or i need to modify something related to the header in order to get it working on DS?

Mysoft
Posts: 20
Joined: Thu Jun 09, 2011 11:56 am

Re: ADPCM sample

Post by Mysoft » Sun Jun 26, 2011 11:49 pm

ok, it seems that SOX, got the thing done
http://sourceforge.net/projects/sox/

so, i will try to check it's source and understand the differences :)

WinterMute
Site Admin
Posts: 1859
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: ADPCM sample

Post by WinterMute » Mon Jun 27, 2011 11:03 am

Cool, what parameters did you use for sox to get the correct format out?

I've toyed with the idea of including sox with the toolchains for audio manipulation in the past but never really got up the time or motivation to do it properly.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Mysoft
Posts: 20
Joined: Thu Jun 09, 2011 11:56 am

Re: ADPCM sample

Post by Mysoft » Mon Jun 27, 2011 2:16 pm

WinterMute wrote:Cool, what parameters did you use for sox to get the correct format out?

I've toyed with the idea of including sox with the toolchains for audio manipulation in the past but never really got up the time or motivation to do it properly.
just

Code: Select all

sox Input.wav output.ima
and then added the .ima as data file to the project....
and it works..

but i used it to convert the samples of a .PAT file to generate a very optimized ".pDS" file that uses the minimum frequency/encoded in ADPCM to save space and so i can use some FreePAT patches on DS... then for that (i could had piped out) but i saved the RAW "16bit ??khz mono" wave into a ".s16" file and did

Code: Select all

sox.exe  -G -c 1 -r ????? RawSample.s16 -r 22050 AdpcmSample.ima
since the max frequency used on samples where never above 11khz...
and so i kinda liked the result.
http://jafile.com/uploads/mysoft/Freeba ... _rhyme.nds

User avatar
fincs
( ͡° ͜ʖ ͡°)
Posts: 94
Joined: Mon Jul 12, 2010 9:45 pm
Location: Seville, Spain
Contact:

Re: ADPCM sample

Post by fincs » Mon Jun 27, 2011 9:09 pm

I just downloaded sox and tried this with a longer sample (music) and it sounded pretty distorted on the DS, so perhaps there's still a setting to discover...
Donate to devkitPro - help us stay alive!

Mysoft
Posts: 20
Joined: Thu Jun 09, 2011 11:56 am

Re: ADPCM sample

Post by Mysoft » Mon Jun 27, 2011 9:53 pm

fincs wrote:I just downloaded sox and tried this with a longer sample (music) and it sounded pretty distorted on the DS, so perhaps there's still a setting to discover...
heh.... then i will do more tests later.. but be sure to set the output as MONO, because if you generate a stereo sound, it will interleave the Left/Right channels... and obviously that will not work for DS, since DS expect each channel isolated...

so perhaps the closest to correct setting is....

Code: Select all

sox -G Input.wav -b 16 -c 1 -r 32000 -t ima Output.ima
but i also noticed something wrong... but so, more study is needed...

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: ADPCM sample

Post by zeromus » Tue Jun 28, 2011 7:07 am

man, that sounds terrible and poppy in desmume.

be aware that if you have a looping sample, there is some kind of quirk where the loop point needs to be a multiple of 16 or something like that. pay close attention, and look it up on gbatek. you may need to resample the sound to a funny samplerate so that you can have the loop land on the right spot.

Mysoft
Posts: 20
Joined: Thu Jun 09, 2011 11:56 am

Re: ADPCM sample

Post by Mysoft » Tue Jun 28, 2011 8:53 am

zeromus wrote:man, that sounds terrible and poppy in desmume.

be aware that if you have a looping sample, there is some kind of quirk where the loop point needs to be a multiple of 16 or something like that. pay close attention, and look it up on gbatek. you may need to resample the sound to a funny samplerate so that you can have the loop land on the right spot.
if you're talking about my .NDS, yes it works crap on desmume for 2 reasons

1) i'm starting and stopping the adpcm sound several times between samples.... and desmume delays the ADPCM start too much, (not to mention it's using too much cpu i think) and so it doesnt do a good emulation of that...

2) i use the hblank timer to wait for the events, (to not waste a timer, because this code suppose to run silently in background, since it's part of the freebasic runtime lib, and so i decided that timer() function will be using hblank... but so it works fine in no$GBA and on the Real DS.. then it's fine :P (apparently unchecking the "Advanced Bus level" option, make the hblank runs better)

also yeah about the loop, it must be word aligned, and there's some constraints on the size that is something i didnt really got the purpose of that.... but i did it right like was mentioned on gbatek...

and anyway, many people playing ADPCM sounds were using 22khz, probabily to save space... but turns out that for now with SOX only a sound playing at 22khz is sounding reasonable good (depend on the sound), this rhyme is one example of a sound that plays exact like the PCM version.. and i'm reasearching to make a proper ADPCM generator for DS, to fix all those issues yeah :P

User avatar
fincs
( ͡° ͜ʖ ͡°)
Posts: 94
Joined: Mon Jul 12, 2010 9:45 pm
Location: Seville, Spain
Contact:

Re: ADPCM sample

Post by fincs » Tue Jun 28, 2011 12:06 pm

My sample was Mono 16384Hz.
Donate to devkitPro - help us stay alive!

WinterMute
Site Admin
Posts: 1859
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: ADPCM sample

Post by WinterMute » Tue Jun 28, 2011 3:13 pm

For what it's worth, Damien Yerrick released a tool for creating compressed audio for GBA a few years ago. His source code for 8ad includes a tool which can convert wav files to the DS ima format although you'll need to do some editing and recompiling. There are instructions in the source archive.

http://www.pineight.com/gba/#8ad
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 71 guests