SoX: How to Add a Delay to Audio

Updated

Learn how to add a delay, silence or an echo to audio using SoX

SoX: How to Add a Delay to Audio

Install SoX

Before we start, make sure you have Homebrew installed on your computer and an audio file ready in a folder. Install SoX with this command:

brew install sox

Add a Delay

First, open your terminal and navigate to the folder that has your audio file. To push your whole track back in time, run this command:

sox input.wav output.wav delay 2 2

Just remember to replace input.wav with your actual filename, and output.wav with the name you want for the new file. The delay effect needs one time in seconds for each channel, so a stereo file needs two numbers. Here, 2 2 delays both channels by two seconds.

This finishes almost instantly. To make sure everything worked, run soxi -d output.wav. The -d flag prints just the duration, which should be two seconds longer than your original file.

Pad and Echo

If you want silence added no matter how many channels the file has, use the pad effect instead:

sox input.wav output.wav pad 3

That adds three seconds of silence at the start. And if you want a real echo, where the sound repeats and fades out, use the echo effect:

sox input.wav output.wav echo 0.8 0.7 500 0.4

The echo effect takes the input gain, the output gain, a delay in milliseconds and a decay. So 500 0.4 gives you one echo, five hundred milliseconds after the original, at forty percent volume.

undefined

To layer more echoes, just add extra delay and decay pairs, like echo 0.8 0.7 300 0.4 600 0.2.