11

I am trying to merge 2 wave files into one file. The 2 files should start playing at the beginning of the new file. Independently of sound length. Running the following command does not give me this result.

  sox -M new_input.wav myrecording.wav output_test.aiff

Are there other ways of achieving this through sox or other command line libraries?

Ellen S
  • 1,047
  • 1
  • 13
  • 18

4 Answers4

9

just change -M with -m

-M = merge
-m = mix
Community
  • 1
  • 1
Giuseppe
  • 1,079
  • 13
  • 31
7

For cases like Calmarius is asking:

sox -m in1.wav in2.wav out.wav trim 0 `soxi -D in1.wav`

this stops at the length of in1.wav, for cases you know the shorter. Otherwise just add a comparator.

Johan Ehnberg
  • 71
  • 1
  • 2
  • what is the function of ``soxi -D in1.wav``? – kc ochibili Jun 25 '15 at 05:39
  • `soxi -D in1.wav` outputs the length in seconds of in1.wav. However, to run this command within the mix command you'd need to use: `sox -m in1.wav in2.wav out.wav trim 0 "$(soxi -D in1.wav)"` – WebSpanner Feb 07 '16 at 02:36
  • 1
    Is there a way to make it _repeat_ the shorter file for the duration of the longer? – bcattle Apr 01 '17 at 06:32
2

Heythere. Sorry for late response =) Command should look like this

sox file1 file2 file3

Above will merge first two files and name it after 3rd.

You also might wanna check the docs http://sox.sourceforge.net/sox.html

get8p
  • 709
  • 2
  • 8
  • 12
1

'soxi -D in1.wav' gets the length of the file (in1.wav)

ralphosky
  • 11
  • 2