7

I use this command to merge two audio files into one using sox:

sox end.mp3 -p pad 6 0 | sox - -m start.mp3 output.mp3

I was wondering how can I merge 3 or 4 audio files using only one command instead of using the "output.mp3" as the input to the next command and so on?

I will really appreciate any help

Yngwie Pompas
  • 71
  • 1
  • 1
  • 2

2 Answers2

9

You can do it with one invocation of sox like this:

sox -m in1.mp3 in2.mp3 in3.mp3 out.mp3

If you want to combine this with the pad effect you need to be clearer about what you want.

Thor
  • 45,082
  • 11
  • 119
  • 130
  • are you sure this works? I tried to mix 5 mp3's into 1 wav and I hear only 3 audios. Any ideas? – trainoasis Jul 21 '14 at 10:59
  • 1
    @trainoasis: Yes I am sure. As sox attenuates each file by 1/n before mixing (to avoid clipping) you might have some files that become inaudible in the resulting file. In that case you may want to normalize each file prior to mixing, e.g.: `sox in.mp3 out.wav gain -n` (don't reencode to mp3 yet as that would add unnecessary encoding/decoding steps). I think you can achieve all these steps with the `remix` effect, but I don't have time to experiment at the moment. – Thor Aug 11 '14 at 21:09
7

To combine mix and effects (pad, trim etc) use the following:

sox -m "|sox end.mp3 -p pad 6 0" start.mp3 output.mp3

The general pattern is:

sox -m input1 input2 ... inputN output

where inputX can be either a filename or a pipe in quotes

"|sox end.mp3 -p pad 6"
idrosid
  • 7,983
  • 5
  • 44
  • 41