Search code examples
audiomergedelaysoxpad

Sox : merge two audio files with a pad


I'm using the sox tool and I would like to merge two audio files, let's say long.ogg and short.ogg to output a file output.ogg. This is very easy using $ sox -m long.ogg short.ogg output.ogg.

Thing is, I would like the short.ogg to be played after n seconds (while long.ogg should start right from the beginning). To do so, I've found the pad effect. But I don't understand the syntax to delay only the short.ogg input file, not the long.ogg one.

I found a (dirty) way of doing so (with n=6):

$ sox short.ogg delayed.ogg pad 6
$ sox -m long.ogg delayed.ogg output.ogg

I would like not to have to create an intermediate file. Thanks in advance for your help.


Solution

  • Thanks to icyrock, I managed to find a solution. I'm using:

    $ sox short.ogg -p pad 6 0 | sox - -m long.ogg output.ogg
    

    For multi tracks (credits to Orlando):

    $ sox starts-last.mp3 -p pad 2 0 | sox - -m starts-second.mp3 -p pad 2 0 | sox - -m starts-first.mp3 combined.mp3