[Ardour-Users] 4-channel stereo
Ralf Mardorf
ralf.mardorf at alice-dsl.net
Sat May 21 04:08:17 PDT 2016
On Sat, 21 May 2016 12:15:42 +0200, Alex Rodriguez Lopez wrote:
>The way I do it, I split them before hand using sox (very handy command
>line utility), so then you would have 4mono files you can use one per
>channel in ardour. Its even fairly easy to write a script that will
>split to mono all files of a certain extension in a folder using Sox.
I'm using a script to split stereo files based on ffmpeg and added it as
tool to spacefm, so just selecting a file and a shortcut is needed. This
could be done using sox or ffmpeg with any number of channels.
Perhaps not a beautiful script, but it does the job ;).
$ cat /usr/local/bin/s2m
#!/bin/dash
version="2016-04-28"
usage()
{
cat<<EOF
s2m version $version rocketmouse
stereo.wav > mono.wav:
s2m input_file.wav
stereo.wav > left.wav:
s2l input_file.wav
stereo.wav > right.wav:
s2r input_file.wav
stereo.wav > dual {left,right}.wav:
s2d input_file.wav
stereo.wav > all {mono,left,right}.wav:
s2a input_file.wav
EOF
exit $1
}
outfile()
{
outfile="$(echo "$infile" | sed 's/\(.*\).wav/\1_'$1.$suffix/I)"
if [ -f "$outfile" ]; then
echo "$outfile already exists"
usage 1
fi
}
ex2file()
{
outfile $1
echo "Export to $outfile"
case $1 in
mono)
ffmpeg -i "$infile" -ac 1 "$outfile"
;;
left)
ffmpeg -i "$infile" -map_channel 0.0.0 "$outfile"
;;
right)
ffmpeg -i "$infile" -map_channel 0.0.1 "$outfile"
;;
esac
}
case $1 in
-h|--help)
usage 0
;;
esac
infile="$1"
if [ ! -f "$infile" ]; then
echo "No file $infile"
usage 1
fi
num_ch=$(exiftool "$infile" | grep -v "File Name" | grep -v "Directory" | grep "Num Channels" | cut -d: -f2 | sed s/\ //)
plural=""
if [ "$num_ch" = "" ]; then
num_ch="No"
else
if [ "$num_ch" -ge "2" ]; then
plural="s"
fi
fi
if [ "$num_ch" != "2" ]; then
echo "$num_ch channel$plural, not a stereo file"
usage 1
fi
suffix=$(echo "$infile" | rev | cut -d. -f1 | rev)
if [ "$(echo "$suffix" | tr [:upper:] [:lower:])" != "wav" ]; then
echo "Suffix is \"$suffix\", must be \"wav\", case sensitivity is not required"
usage 1
fi
case $(basename $0) in
s2m)
ex2file mono
;;
s2l)
ex2file left
;;
s2r)
ex2file right
;;
s2d)
outfile right
ex2file left
ex2file right
;;
s2a)
outfile left
outfile right
ex2file mono
ex2file left
ex2file right
;;
esac
exit
More information about the Ardour-Users
mailing list