Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use SoX to generate audio?

Tags:

sox

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.

like image 864
user2526619 Avatar asked Jun 16 '14 04:06

user2526619


People also ask

How do I use SoX audio?

Audio recorder SoX includes a very handy way of recording audio using the rec command. The simplest use is to type rec filename which will start recording from the default input until you stop it by pressing ctrl-c in the terminal window.

What does SoX command do?

SoX is a cross-platform (Windows, Linux, MacOS X, etc.) command line utility that can convert various formats of computer audio files in to other formats. It can also apply various effects to these sound files, and, as an added bonus, SoX can play and record audio files on most platforms.

What are SoX effects?

SoX reads and writes audio files in most popular formats and can optionally apply effects to them. It can combine multiple input sources, synthesise audio, and, on many systems, act as a general purpose audio player or a multi-track audio recorder.


1 Answers

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
like image 107
lCapp Avatar answered Sep 23 '22 02:09

lCapp