Can I use SoX to generate audio?

sox
user2526619 picture user2526619 · Jun 16, 2014 · Viewed 10.5k times · Source

For a project I am working on, I need to use the SoX tool for audio generation. If there is a way to use SoX to generate certain notes/tones for a certain duration, please let me know! I have done quite some research on this to no avail.

Moreover, any way to make it output directly into your speakers? I'm thinking something like redirection to /dev/audio.

Answer

lCapp picture lCapp · Jun 16, 2014

You can synthesise sound effects using synth and the -n option. For instance, the following command creates a 3 seconds sine wav at 500 Hz:

sox -n -r 8000 output.wav synth 3 sine 500

You can set the sample frequancy using the option -r. Default value is 48kHz.

You can play audio directly to /dev/audio. If you just need to play the file, and not save it, you can use play utility (provided by sox) as follows:

play -n -c1 synth 3 sine 500