1

I used arecord in a larger script to capture each mic individually during a live sound gig:

# Start recording
echo Recording to "$REC_PATH"
arecord --device=hw:CARD=X18XR18,DEV=0 --channels=18 --file-type=wav --format=S32_LE --rate=48000 --buffer-time=20000000 --max-file-time 300 "$REC_PATH/all_tracks.wav" &

This works, but it gives me an 18-track WAV file that has to be split at regular intervals to keep the file size within spec. (5 minutes per above, resulting in 1GB per file)

My other question asks how to avoid this step in the future, but given that I already have the sequential 18-track files from this gig, is there a tool to concatenate each of those 18 tracks into its own single-track WAV file? (If it has to split that because of the file size, that's fine, but if one track of the entire gig fits into one file, it should do that.)

Technically, I could use Audacity, which I already have, but its procedure is entirely manual. So with ~50GB to sort through, I really want something that can be started and left alone.

3 Answers 3

1

The sox man page gives an example script for extracting each channel from a file into its own file. Basically it ends up doing (in reverse order)

sox all_tracks.wav all_tracks-01.wav remix 01
sox all_tracks.wav all_tracks-02.wav remix 02
sox all_tracks.wav all_tracks-03.wav remix 03
...

Here's the script from the man page. Pass it the name of the input file.

#!/bin/sh
chans=`soxi -c "$1"`
while [ $chans -ge 1 ]; do
   chans0=`printf %02i $chans`   # 2 digits hence up to 99 chans
   out=`echo "$1"|sed "s/\(.*\)\.\(.*\)/\1-$chans0.\2/"`
   sox "$1" "$out" remix $chans
   chans=`expr $chans - 1`
done

You could also convert your wav files to a lossless compressed format like flac and reduce them to about half their size.

1
  • I think that script from the man page is overly complicated for what it does (a different naming convention for the single-track files can delete 2 lines and make it much more readable), but it does work to split the 5-minute 18-track files into a bunch of 5-minute single-tracks. From there, reading the man page got me the other part of splicing together 18 full-length tracks. So I now have a script that does all of that, given the working directory as an argument. (it was easier to put a cd "$1" at the top of the script than to expect it to be set already) Thanks!
    – AaronD
    Nov 23, 2016 at 10:34
2

sox can append sequential multi channel wav while extracting a single channel. This is not mentioned in first answer and is not implemented in the example script (which accepts only one multi channel wav as argument).

sox multi1.wav multi2.wav multi3.wav  ch1.wav  remix 1
sox multi1.wav multi2.wav multi3.wav  ch2.wav  remix 2
sox multi1.wav multi2.wav multi3.wav  ch8.wav  remix 8

I find this very helpful for converting several sequential multi channel wav to single mono wav files for each channel.

1
  • This shojld be a comment on the previous answer. It isn't an anwer in its own right.
    – Chenmunka
    Mar 24, 2023 at 14:38
1

FFMPEG can split, merge (down mix) and concatenate audio, (and video), tracks including multi-track audio files from the command line or a batch/script file.

It can also convert between the majority of formats.

It is:

  • Free, gratis & open source
  • Cross Platform
  • Able to handle large files

Examples

There are some very good audio channel manipulation examples in the ffmpeg wiki here. They include:

To down mix a single file to stereo:

ffmpeg -i multi_channels.wav -ac 2 stereo.wav

Mixing selected channels to stereo, discarding some:

ffmpeg -i input.wav -af "pan=stereo|c0<c0+c1+c3+c4+c5+c9|c1<c6+c7+c8+c11" output.mp3

Splitting the channels of a 5.1 surround sound wav file out:

ffmpeg -i in.wav-filter_complex 'channelsplit=channel_layout=5.1[FL][FR][FC][LFE][SL][SR]' -map '[FL]' front_left.wav -map '[FR]' front_right.wav -map '[FC]' front_center.wav -map '[LFE]' lfe.wav -map '[SL]' side_left.wav -map '[SR]' side_right.wav

For your specific case and assuming that all of your files are sequentially numbered and you wish to generate one wav file per channel something like the following may give good results, (I would strongly suggest using a single file name rather than the %d notation for your first tests):

ffmpeg -i yourfilename_%d.wav -map 0:1 1.wav -map 0:2 2.wav -map 0:3 3.wav -map 0:4 4.wav -map 0:5 5.wav -map 0:6 6.wav -map 0:7 7.wav -map 0:8 8.wav -map 0:9 9.wav -map 0:10 10.wav -map 0:11 11.wav -map 0:12 12.wav -map 0:13 13.wav -map 0:14 14.wav -map 0:15 15.wav -map 0:16 16.wav -map 0:17 17.wav -map 0:18 18.wav

Note that I haven't been able to test the above examples.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.