Editing 100’s of sound files

I’ve mentioned in a previous post that my latest app has 100’s of images. Well, it also needs almost the same number of sound files. And, as an independent developer, I don’t have the resources to get the sounds professionally made. So my friend and co-designer coached his girlfriend through reading all the words. She did an excellent job. But we could not figure out how to record them without extra silence at the end of each file. The extra silence caused strange delays in the app, so it had to be fixed. And it had to happen in a batch. Because I’m not doing 500+ files by hand.

Normally, when I need sound editing, I turn to Audacity. Thankfully, they added .m4a support just before I needed it. So I was able to take the Garage Band files, and use Audacity’s truncate silence effect. But repeating an effect over several files was a new trick for me. It turns out Audacity has a feature known as an Chain, which can be used on a group of files. Using “Edit Chains”, I was able to create a chain that removed silence, and removed an unneeded stereo channel at the same time:

Edit Chain showing remove silence.

But can you see the problem? Audacity does not support exporting as .m4a in a chain, so I had to export them all as .wav’s. This makes them too large, and hurts my chances for keeping the app under the 3G limit of 20M. So I needed another tool, preferably a free one.

If you have a UNIX background like I do, afconvert is the perfect tool. It’s a command line utility, included for free on a Mac, that converts sound files to any format with tons of options. I just needed it to convert back to a proper m4a. It turns out, I needed 2 options to do it, -f m4af to set the file format, and -d aac to set the correct data format inside the file. So I wrote the following script to convert all the files in a directory:

find . -name '* *.wav' | while read i
 afconvert -f m4af -d aac "$i"

If you are not familiar with BASH, the first line finds all the files with a space in the name, and .wav at the end. The filenames are then read into a loop variable, i, which I then use to run afconvert on the proper files. Don’t ask me why all the sounds had a space in the filename, they just came to me that way.

With these tools, I was able to remove silence from over 500 sounds in a very short time. While I doubt you’ll ever face exactly this problem, maybe one of these tools will help in your project.


Leave a comment

Filed under Audio

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s