Repeating import/export on raw data

This section is now closed.
Forum rules
Audacity 1.3.x is now obsolete. Please use the current Audacity 2.1.x version.

The final version of Audacity for Windows 98/ME is the legacy 2.0.0 version.
Locked
3splash
Posts: 2
Joined: Sun Sep 18, 2011 8:41 pm
Operating System: Please select

Repeating import/export on raw data

Post by 3splash » Sun Sep 18, 2011 9:16 pm

I have 70 .PCM files I'm importing as raw data and exporting as WAV. Can Audacity automatically repeat the process on each file?

Import raw data
16-bit PCM
Little-endian
2-channel stereo
Start Offset: 0 bytes
Amount to import: 100%
22050 Hz
Export WAV

I dread having to do it all manually. :shock:

steve
Site Admin
Posts: 81653
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Repeating import/export on raw data

Post by steve » Sun Sep 18, 2011 9:31 pm

Unfortunately Audacity does not support batch processing of RAW files.

You could do it with a program called Sox, but it is a command line program (it does not have a graphical user interface).
If you have any experience of programming, or just writing .bat files, then this will be a good option. If your eyes have suddenly glazed over, then perhaps not.

The Sox command to convert your RAW file to a WAV file is:

Code: Select all

sox -s -2 -r 22050 -c 2 in-file out-file.wav
(where "infile" is the name of your RAW input file and out-file.wav is the name of your output file).

I don't use Windows, so I'm not sure of exactly what you would need to write for a .bat file.
I'll see if I can find some details for batch processing with Sox on Windows and post again if successful.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

steve
Site Admin
Posts: 81653
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Repeating import/export on raw data

Post by steve » Sun Sep 18, 2011 10:12 pm

OK, I've tried this on windows and it seems to work.

First you'll need to download Sox for Windows, which you can get here: http://sourceforge.net/projects/sox/fil ... e/download

To install it, run the downloaded file. Take care with the step where you choose to extract (install) it to. Ensure that you extract it somewhere that you can easily find it and get to it, for example in "My Documents".

Now open NotePad (text editor) and copy/paste this:

Code: Select all

cd %~dp0
mkdir converted
FOR %%A IN (%*) DO sox -t raw -s -2 -r 22050 -c 2 %%A "converted/%%~nxA.wav" 
pause
Save the file as "convert.bat" (without quotes). Check that Windows has saved it with exactly that name and has not added ".txt" to the end of the file name.

Copy or move the file convert.bat into the Sox folder (the same folder that contains the file sox.exe)

Now make a Desktop shortcut to convert.bat.

You are now ready to start converting.
Drag and drop one or more of your RAW files onto the Desktop shortcut to convert.bat
If successful the converted files will be written to a folder called converted which will be inside the Sox folder.

Good luck, let me know how it goes.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

3splash
Posts: 2
Joined: Sun Sep 18, 2011 8:41 pm
Operating System: Please select

Re: Repeating import/export on raw data

Post by 3splash » Sun Sep 18, 2011 10:40 pm

Wow, that was quick! It would have taken me forever to figure out those commands...

These WAVs are perfect too.The ones that Audacity made had a weird crackle in the first ten seconds of every song.
Thanks so much!

steve
Site Admin
Posts: 81653
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Repeating import/export on raw data

Post by steve » Sun Sep 18, 2011 10:58 pm

You didn't say if your RAW files have a file extension or not.
If they do (for example "test.raw") then the BAT script I posted will add ".wav" to the end of the full name to give "test.raw.wav"
It would probably be better to just have "test.raw" produce "test.wav", so here's a slight modification that will do that:

Code: Select all

cd %~dp0
mkdir converted
FOR %%A IN (%*) DO sox -t raw -s -2 -r 22050 -c 2 %%A "converted/%%~nA.wav"
pause
The only difference is that %~nxA.wav has been changed to %~nA.wav so that only the file name and not the extension is used in the new file name.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Locked