Skip to content

Instantly share code, notes, and snippets.

@mcfadden
Last active January 8, 2022 01:40
Show Gist options
  • Save mcfadden/d0bcb10cb1c4ece4f4bc4faa1e19a0e0 to your computer and use it in GitHub Desktop.
Save mcfadden/d0bcb10cb1c4ece4f4bc4faa1e19a0e0 to your computer and use it in GitHub Desktop.
Convert multitrack WAV files generated by X-Live card into one file per track
#!/bin/bash
# Accepts a single argument, which is a path to the directory containing all the
# WAV files generated by a recordings from the X-Live card.
# Looks for files like 000000.WAV 000001.WAV 000002.WAV etc.
#
# Outputs files like Ch01.WAV Ch02.WAV Ch03.WAV etc.
#
# Requires sox
cd "$1"
shopt -s nullglob # Empty array when no matching files
wavFiles=(*.WAV)
echo ${#wavFiles[@]}
if [ ${#wavFiles[@]} -eq 0 ]; then
echo "No WAV files found in `pwd`"
exit
fi
echo "Found these wav files: ${wavFiles[@]}"
for run in {01..32}; do
echo "Splitting out channel ${run}"
channel=$(printf "%02d" $run)
`sox ${wavFiles[@]} Ch${channel}.wav remix ${run}`
done
echo "Done."
@mcfadden
Copy link
Author

mcfadden commented Jun 6, 2019

The WAV files provided by X-Live are 32 channel WAV files, each broken into ~11 minute chunks or so.

This essentially runs 32 sox commands, each of which are something like this example:

sox 00000001.WAV 00000002.WAV 00000003.WAV Ch01.wav remix 01

What that does, it it takes channel 01 (remix 01) of the input files (00000001.WAV 00000002.WAV 00000003.WAV) and concats them all into a single channel (but full duration) wav (Ch01.wav)

This takes some time, I'm sure there are more efficient approaches, but this also totally and reliably works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment