How to convert headerless ima-adpcm raw file to wav using sox

8.6k views Asked by At

I am trying to convert a raw file (header-less) to wav

It is in ADPCM 16 rate 8000

I have tried three console commands

sox -e ima-adpcm -r 8000 input.raw output.wav
sox -e ima-adpcm -r 8000 -b 16 input.raw output.wav

These trigger the same error:

sox FAIL formats: bad input format for file `input.raw': data encoding or sample size was not specified

and last attempt

sox -t raw -t wav -e ima-adpcm -r 8000 -b 16 input.raw output.wav

which triggers another error

sox FAIL formats: can't open input file `input.raw': WAVE: RIFF header not found

Do you know why I get these errors?

Thanks

EDIT

An hex dump of the first 48 bytes FYI

C0 0C 00 03 00 00 37 C0 34 0C D0 30 37 C0 30 C7 CD D3 C0 03 CD 00 37 03
C0 00 0D 0C CD 00 C0 10 0F 00 03 55 0B 4B 0F 0F 0C 0F 34 0F 0D C3 0D 03
00 C0 31 00 00 D0 C0 00 F4 4C 03 33 34 33 31 33 0D 33 D0 03 C0 4C C0 43
2

There are 2 answers

2
mtrw On

Can you change the filename from input.raw to input.ima ? If you can, then

 sox input.ima -r 8000 -b 16 output.wav

ought to work. .raw seems to be a magic extension for sox and it assumes certain possibilities for the data. See this man page.

0
Malvineous On

Looks like using -t raw -e ima-adpcm doesn't work, but rather you have to use -t ima -e ima-adpcm.

I guess -t raw means raw PCM, whereas -t ima means raw ADPCM?

This worked for me to convert an ADPCM file into .wav:

sox -t ima -r 44100 -e ima-adpcm in.raw -e signed-integer -b 16 out.wav

The file extension doesn't seem to matter as long as you indicate ADPCM with -t ima.