Lots of frowny faces in your flex machine sample folders? Here’s a quick script I wrote using the SoX audio processing library and Windows Powershell to copy an entire folder of wav files of any bit depth and sample rate, convert any non-16/44.1 or 24/44.1 to 16-bit 44.1 kHz wav, and paste all into a new folder that maintains the file naming and subfolder hierarchy.
First time setup
- Download and install SoX from http://sox.sourceforge.net/
- Find the folder where SoX is installed on your computer. For me it was: “C:\Program Files (x86)\sox-14-4-2”
- Hit Windows key and type “environment”. Click on “Edit environment variables for your account”.
- In the user variables list, highlight “Path”, then click “Edit…”
- Click “New”, and paste the path of your Sox folder. Then OK your way out of all this.
- Download the attached file, OTconvert.ps1. Save it anywhere.
OTconvert.ps1 (789 Bytes)
Usage
- In OTconvert.ps1, edit the $SRC and $DST lines to reflect your own existing source and desired destination folders. Your DST folder should not exist yet. Save the file.
WARNING: SRC and DST cannot be the same. Due to some less than ideal behavior in SoX, this will result in all of your original samples being overwritten with silence. DST also cannot be a subfolder of SRC. Make them completely separate.
- Inside the folder containing OTconvert.ps1, hold shift and right click, then click “Open Powershell window here”.
- Paste the following command and hit enter. That should be it!
powershell -ExecutionPolicy ByPass -File OTconvert.ps1
Notes
- This is my first time using any of this, so experts: please let me know if I got something wrong/stupid.
- This is non-destructive to your original samples. It creates an entirely new folder.
- The bit depth reduction (with dither) and sample rate conversion processes can result in clipping. The SoX flag “-G” is supposed to prevent this, but doesn’t always work completely. The next flag, “-v $gain”, reduces the sample volumes to $gain of the original as a further measure to prevent clipping. You can play around with this number or omit that part entirely. SoX will let you know if any of the samples clip.