I am trying to overlay two files (merge them into one so they plat simultaneously).
The options for
sox --combine are sequence, concatenate, mix, mix-power, merge, and multiply. I've looked at the docs here and it's not entirely evident which I should use. sequence and concatenate do work when they have different sample rates but it does not overlay them.
I am trying to use mix, but it's not allowing me to set the sample rate to 41k (which from my understanding is the correct one for mp3):
To precaution against different sample rates, I'm looping through the input files and setting all their sample rates to 41k. I have the following code to do this:
sox -r 44.1k input1.mp3 output1.mp3 sox -r 44.1k input2.mp3 output2.mp3
I get this (it differs between files)
sox WARN formats: can't set sample rate 44100; using 24000 sox WARN formats: can't set sample rate 44100; using 48000
Then when I try and overlay them using the following command:
sox --combine mix output1.mp3 output2.mp3 output3.mp3
I see this:
sox FAIL sox: Input files must have the same sample-rate
I am on Ubuntu 16.04.
As a workaround I'm using the ffmpeg command shown here: https://stackoverflow.com/questions/14498539/how-to-overlay-two-audio-files-using-ffmpeg
This is actually fine for me and gets the job done though I would be curious to know why the sox didn't work.