Search code examples
audioaudio-recordingaudacity

5 individual audio channels in 1 file


Not sure where to put this question, so I apologize in advance.

I have a test set up with 5 speakers in a room, surrounding a pair of mics. I'm testing the sensitivity of the mics from the different angles of the speakers. I have an amp/mixer connected to them and have control of individual channels.

I want to put 5 channels of audio in a single file. With appropriate delays, I want only one speaker to play at a time. So channel 1 goes to speaker 1, channel 2 to speaker 2 and so on.

I've been using Audacity to create the files. However channel 4 and 5 plays in two speakers instead of one. And channel 3 sounds very weak. I suppose this is because of the 5.1 standard where channel 4/5 has to address 'rear-left/right' and channel 3 is for subs.

Is there a file format that will allow me to have pure individual channels going into the speaker? I'm not limited to the file format, but I've tried wav,ogg and flac so far.


Solution

  • In Audacity you have to check the 'Use custom mix' radio button in the Import/Export section of the preferences. This will let you export multi-channel files, and manually assign tracks to channels.

    Other than that, plain old .wav works fine for this.

    But you can also use SoX to create the files in a more automated manner.

    Manually you can combine (or 'merge' as it's referred to in the documentation) five distinct files into a single five-channel file like this:

    sox -M chan1.wav chan2.wav chan3.wav chan4.wav chan5.wav multi.wav
    

    To automate the process I put together a short Bash routine for producing a multichannel file with staggered test tones:

    NUM=5    # Number of channels
    LEN=2    # Length of each test tone, in seconds
    OVL=0.5  # Overlap between test tones, in seconds
    
    # A one-channel base file containing simple white noise.
    # faded at both end with a quarter wave envelope to ensure 
    # smooth equal power transitions
    sox -n -b 24 -c 1 out.wav synth $LEN whitenoise fade q $OVL -0 $OVL
    
    # Instead of white noise you can for example make a 1kHz tone
    # like this:
    # sox -n -b 24 -c 1 out.wav synth $LEN sine 1k fade q $OVL -0 $OVL
    
    # Or a sweep from 10Hz to 10kHz like this:
    # sox -n -b 24 -c 1 out.wav synth $LEN sine 10-10k fade q $OVL -0 $OVL
    
    # Produces a sequence of the number of seconds each channel
    # shall be padded with
    SEQ=$(for ((i=1; i<=NUM; i++))
    do 
      echo "$i 1 - [$LEN $OVL -]x * p" | dc  # reverse-Polish arithmetic
    done)
    
    echo $SEQ
    
    # Padding the base file to various degrees and saving them separately
    for j in $SEQ
    do 
      sox -c 1 out.wav outpad${j}.wav pad $j
    done
    
    # Finding the just-produced individual files
    FIL=$(ls | grep ^outpad)
    
    # Merging the individual files into a single multi-channel file
    sox -M $FIL multi.wav
    
    rm $FIL  # removing the individual files
    
    # Producing a multi-channel waveform plot
    ffmpeg -i multi.wav -y -filter_complex "showwavespic=s=2400x900:split_channels=1" -frames:v 1 waveform.png
    
    # displaying the waveform plot
    open waveform.png
    

    As the waveform plot clearly shows, the result consists of a file with five channels, each with the same content, just moved about some in time:

    multichannel audio file with staggered and cross-faded test tones

    More on reverse-Polish arithmetic using dc: http://wiki.bash-hackers.org/howto/calculate-dc

    More on displaying waveforms using ffmpeg: https://trac.ffmpeg.org/wiki/Waveform