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

2

8

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
Koo answered 25/7, 2014 at 8:45 Comment(0)
O
9

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.

Oconnor answered 19/9, 2015 at 12:48 Comment(0)
K
2

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.

Knucklehead answered 7/8, 2014 at 1:13 Comment(2)
sox WARN raw: input.ima: sample rate not specified; trying 8kHz sox WARN adpcms: input.ima: ADPCM state errors: 286079Koo
@QuentinTanioartino I've never done anything with an .ima file so flying blind here. Maybe just try sox input.ima output.wav and let SoX pick the params itself?Knucklehead

© 2022 - 2024 — McMap. All rights reserved.