-2

How can I use sox to generate an N-channel audio file with silence in all but one channels? For instance, I'd like to create an 8-channel audio file with a tone in channel 3, and silence in all the others.

Daniel Griscom
  • 1,834
  • 2
  • 26
  • 50

1 Answers1

2

Use the remix command. This takes an M-channel input, and generates an N-channel output, where for each output channel you specify the input source channel(s).

For example:

sox -n output.aif synth 1 sine 300 remix 0 0 1 0 0 0 0 0

does the following:

  • -n: no input file
  • output.aif: the output file where the results will be written
  • synth 1 sine 300: generate a 1-second 1-channel sine wave at 300Hz
  • remix 0 0 1 0 0 0 0 0: convert this to an 8-channel file, where output channel 3 comes input channel 1 (the generated sine), and the others come from channel 0 (which is silence)

remix can specify more complex source functions for each output channel. Some examples of these specs:

  • 2: copy input channel 2 to output channel
  • 0: copy silence to output channel
  • 2,3: mix input channels 2 and 3 to output channel
  • 1-4: mix input channels 1 through 4 to output channel
  • -: mix all input channels to output channel
  • 1,2v0.5: mix input channels 1 and 2, with 2 at half the volume of channel 1

(When mixing multiple input channels to an output channel, there are various rules for the mixed signal levels; consult the documentation.)

Daniel Griscom
  • 1,834
  • 2
  • 26
  • 50