Batch Import of Raw Data for file conversion.

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
Advoc
Posts: 1
Joined: Fri Nov 25, 2011 5:43 pm
Operating System: Please select

Batch Import of Raw Data for file conversion.

Post by Advoc » Fri Nov 25, 2011 5:52 pm

I am building a Binaural Synthesis engine in Max/MSP for use with a 3D Virtual Audiory Space built in C++. To make this work I've created a convolution filter that takes impulse responses.

I'm using the MIT KEMAR library of HRIR measurements for the basis of my convolution, but I'm running into a problem.
The impulse responses are stored as 16bit headerless .dat files. Which is great because there's no extra unwanted information in there. but Max will not import .raw or .dat files. It cannot parse the file properly.

So I've resigned myself to having to convert all of my .dat impulse responses to .wav and read them in that way. Audacity can do this just fine, the problem is while there is a batch export, there is no batch import for raw data files. I'll have to import every file manually, and there are over 500 of them. Audacity won't let me shift-click or ctrl-click in the import raw data dialog.

Is there a way to write a script that will help me with this? or a workaround native to audacity? I could write a script that would do the conversions in supercollider for me, but the time it would take me to write, test, refactor, test again, and finalize a script there would probably take me longer than manually importing every file. I'm stuck....

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

Re: Batch Import of Raw Data for file conversion.

Post by steve » Fri Nov 25, 2011 6:07 pm

Audacity Chains do not currently support RAW import.

SoX is probably the best tool for the job.

I don't use Windows so I'm unsure of the necessary steps for a .BAT file but I believe there is a sample .BAT file included in the SoX download.
I can probably help with the necessary SoX command, so I'll get back to you on that point.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

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

Re: Batch Import of Raw Data for file conversion.

Post by steve » Fri Nov 25, 2011 6:28 pm

steve wrote:I can probably help with the necessary SoX command, so I'll get back to you on that point.

Code: Select all

sox -s -b 16 -c 1 -r 44100 infile.raw outfile.wav
where:
infile.raw is the file name of the input file
outfile.wav is the name of the output file
-s means that the input file is signed integer
-b 16 means that the input file is 16 bit
-c 1 means that the input file is 1 channel (mono)
-r 44100 means that the input file has a sample rate of 44100 Hz.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

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

Re: Batch Import of Raw Data for file conversion.

Post by steve » Fri Nov 25, 2011 7:28 pm

Ok, here's a batch script that should work with SoX

Code: Select all

cd %~dp0
mkdir converted
FOR %%A IN (%*) DO sox -t raw -s -b 16 -c 1 -r 44100 %%A "converted/%%~nA.wav"
pause
To use this,
Install SoX
Open NotePad and copy and paste the above code.
Save the file inside the SoX folder and call it "import-raw.bat" (the name is not important but it needs the .bat file extension)
Make a shortcut to this file on your desktop
Now just drag and drop your raw files onto the shortcut.

The converted files should appear in a folder called "converted" inside the Sox folder.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Locked