13

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.

lCapp
  • 892
  • 9
  • 18
user2526619
  • 145
  • 1
  • 1
  • 5

1 Answers1

27

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
lCapp
  • 892
  • 9
  • 18
  • Thanks! This helped me a lot, and I forgot to specify this: Any way to make it output directly into your speakers? I'm thinking something like redirection to /dev/audio, but not sure how I would use SoX like this. – user2526619 Jun 16 '14 at 13:31
  • Ah! Thanks. This is precisely what I needed! – user2526619 Jun 16 '14 at 21:43