montage/merge/combine audio/sfx in bash using sox

OpenGameArt currently requires a preview to be uploaded for audio submissions that consist of more than one audio file. I have been using

sox *wav preview.mp3

but this does not work when the input files have different channel amounts or rates. I wrote a simple bash script to handle ‘complicated’ cases:

#!/bin/sh

DATE="$(date +%Y%m%d@%H%M%S)"
NAME="./montageAudio-${DATE}.mp3"

# Unify!
for i in $*
do
sox "$i" -c 2 -r 44100 "$i-tmp.wav" pad .1@0
done

# Montage!
sox *-tmp.wav $NAME pad 0 .1

# Delete!
for i in $*
do
rm "$i-tmp.wav"
done

I call it montage-audio in honor of imagemagick’s montage, which makes making image preview fun! :D

Download the .sh and use it like this:

./montage-audio.sh *wav

Advertisements
This entry was posted in qubodup and tagged , , , , , . Bookmark the permalink.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s