
SoX: How to Mix Audio Files
Updated
Learn how to mix audio files together in the terminal using SoX

Before we start, make sure you have SoX installed on your computer and your audio files ready in a folder. On a Mac, you can install it with Homebrew:
brew install sox
Mix the Files
First, open your terminal and navigate to the folder with your audio files using cd. To mix two files so they play at the same time, run this command:
sox -m input1.wav input2.wav output.wav
Just remember to replace input1.wav and input2.wav with your actual file names and output.wav with the name you want for the new file. The -m flag tells SoX to mix the inputs together instead of playing them one after the other.
For short files, this finishes almost instantly, and don't worry if you don't see a success message. The new file is as long as your longest input. Also, both inputs need the same sample rate, otherwise SoX stops with Input files must have the same sample-rate. If that happens, convert one of them first with -r.
To make sure everything worked, run soxi -d output.wav to print just the duration of the new file.
If one file is a lot louder than the other, put -v and a number right before that file. For example, -v 0.5 cuts the second file to half its volume:
sox -m input1.wav -v 0.5 input2.wav output.wav
