Skip to content

Instantly share code, notes, and snippets.

@leonidlezner
Created March 21, 2021 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonidlezner/0fee83b4c524e181a5b0f8a0bd40a718 to your computer and use it in GitHub Desktop.
Save leonidlezner/0fee83b4c524e181a5b0f8a0bd40a718 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Usage: ./rodecaster_conv.sh POD000131.WAV
# Tool sox is needed!
# Installation..
# ..under Debian/Ubuntu: sudo apt-get install sox
# ..under maxOS using Homebrew: brew install sox
function convert() {
filename=$1
suff=$2
channel=$3
dest=$4
basename=`echo $(basename $filename)`
filename_without_ext=`echo "${basename}"|sed "s/\(.*\)\.\(.*\)/\1/"`
mkdir -p "${dest}/${filename_without_ext}"
channel_frmt=`printf "%02d" $channel`
new_filename="${dest}/${filename_without_ext}/${filename_without_ext}-${channel_frmt}−$suff.flac"
echo "Extracting channel ${channel} to ${new_filename}..."
sox "$filename" "$new_filename" remix $channel
}
if [ ! -f "$1" ]; then
echo "File '$1' does not exist!"
exit
fi
dest=${2:-.}
convert $1 "Left" 1 "$dest"
#convert $1 "Right" 2 "$dest"
convert $1 "Mic-1" 3 "$dest"
#convert $1 "Mic-2" 4 "$dest"
#convert $1 "Mic-3" 5 "$dest"
#convert $1 "Mic-4" 6 "$dest"
convert $1 "USB-Left" 7 "$dest"
#convert $1 "USB-Right" 8 "$dest"
#convert $1 "TRRS-Left" 9 "$dest"
#convert $1 "TRRS-Right" 10 "$dest"
#convert $1 "Bluetooth-Left" 11 "$dest"
#convert $1 "Bluetooth-Right" 12 "$dest"
#convert $1 "Sounds-Left" 13 "$dest"
#convert $1 "Sounds-Right" 14 "$dest"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment