Convert RAW to WAV

Status
Not open for further replies.

derwt

New member
Hi everyone!

I'm in the process of making a low latency audio project. It's my understanding (thanks to the wonderful paul's AudioPlaySdRaw library doc) that using RAW files is a little more efficient, so I've been sticking to RAW.

The problem is I want to be able to convert RAW files on the SD card into WAV on the teensy itself (not in Audacity) and I have no clue how to do that. I'd like to preserve the original file and just create a new file to copy data into.

I haven't tried this out, but I wish it would be as simple as:

File rawFile = SD.open("AUDIO.RAW", FILE_READ);
File wavFile = SD.open("AUDIO.WAV", FILE_WRITE);

with a little buffer action to transfer data.

Another question I have.. what kind of delay, if any, would just writing and playing audio in WAV format create? I just want to be able to plug in the SD card to a computer and be able to play the audio without any third-party software.

Thank you so much for everybodys' questions and help on this forum, it is such an amazing resource.
And thank you to the great Paul Stoffregen for the coolest hardware/software/knowledge.
 
Convert command in Linux with Sox

Hi everyone!

I'm in the process of making a low latency audio project. It's my understanding (thanks to the wonderful paul's AudioPlaySdRaw library doc) that using RAW files is a little more efficient, so I've been sticking to RAW.

The problem is I want to be able to convert RAW files on the SD card into WAV on the teensy itself (not in Audacity) and I have no clue how to do that. I'd like to preserve the original file and just create a new file to copy data into.

I haven't tried this out, but I wish it would be as simple as:

File rawFile = SD.open("AUDIO.RAW", FILE_READ);
File wavFile = SD.open("AUDIO.WAV", FILE_WRITE);

with a little buffer action to transfer data.

Another question I have.. what kind of delay, if any, would just writing and playing audio in WAV format create? I just want to be able to plug in the SD card to a computer and be able to play the audio without any third-party software.

Thank you so much for everybodys' questions and help on this forum, it is such an amazing resource.
And thank you to the great Paul Stoffregen for the coolest hardware/software/knowledge.

This command works fine in Linux Mint and should work on all Linux versions. It is command-line, but that makes it more universal...

sox -t raw -b 16 -e signed-integer -r 44100 -c 1 source.RAW destination.WAV

If you want to convert all files named *.RAW in a directory, use the shell command:

for f in *.RAW
do
sox -t raw -b 16 -e signed-integer -r 44100 -c 1 ./"$f" ./"${f%}.wav"
done

This command is extremely fast, so it may look like it did not work. Works on mine.

It does leave a residual ".RAW." in the filename. I'm not that good at shell commands.
 
Last edited:
Status
Not open for further replies.
Back
Top