13

I want to use my laptop as sinus generator under linux. But I have not found a program that can generate sound. Can someone tell me the right program or script for it. Thank you.

PS: I don't want use wine for it. PS2: I found this: "aoss siggen" and "speaker_test". But first ncurses based and second can not generate a continuous signal. May be you know more?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
smex
  • 131
  • 1
  • 1
  • 5

5 Answers5

12

If you want to generate sound files under linux, I recommend Sox

Throwback1986
  • 5,887
  • 1
  • 30
  • 22
12

Pulseaudio has a module for generating sine waves:

$ pactl load-module module-sine frequency=1000

And to make it stop:

$ pactl unload-module module-sine
chris
  • 3,986
  • 1
  • 26
  • 32
  • 1
    +1 That's a fun thing... – Alba Mendez Mar 30 '13 at 13:25
  • I was going to add the most important part of the page in the answer because the link might die in the future, but it's ironically already dead. This is why we have this guideline for answers: https://meta.stackexchange.com/help/how-to-answer – Luc Feb 19 '16 at 19:07
  • Use `pactl load-module module-sine frequency=440; read; pactl unload-module module-sine` to make it stop after you press a key. – kralyk Dec 17 '18 at 18:25
10

ffmpeg

ffmpeg can do it, as usual.

Create a 5 seconds mono 1000Hz sinusoidal out.wav sound file:

sudo apt-get install ffmpeg
ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" out.wav

Stereo instead:

ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" -ac 2 out.wav

The file will be 2x as large, and ffprobe will say it has 2 channels instead of 1 channel.

Play the audio for 5 seconds without creating a file:

ffplay -f lavfi -i "sine=frequency=1000:duration=5" -autoexit -nodisp

Play forever until you go mad:

ffplay -f lavfi -i "sine=frequency=1000" -nodisp

Documentation:

The other section sunder Audio sources document other useful sound generation algorithms in addition to sine, e.g.:

Bibliography:

Tested in Ubuntu 18.04, ffmpeg 3.4.6.

Minimal C audio generation example without extra libraries

Just for fun: How is audio represented with numbers in computers?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
  • 1
    You could use `-v warning` to disable logging to stderr, if there are no warnings or some more serious problems. – jarno Feb 28 '20 at 02:50
  • 2
    ffplay -f lavfi -i "sine=frequency=1000:duration='0.1'" -autoexit -nodisp # if you want duration less than a second. – xerostomus Feb 08 '21 at 15:04
1

Today Linux uses the Alsa infrastructure for sound. Check out Alsa documentation and tutorials (for instance this one).

ChrisJ
  • 5,161
  • 25
  • 20
  • And in particular see the sine wave generator example in the ALSA docs: http://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2pcm_8c-example.html – nos Feb 24 '11 at 18:55
0

Looking around on google I found this software, not sure if it is what you are looking for.

http://www.softpedia.com/get/Multimedia/Audio/Other-AUDIO-Tools/Multisine.shtml

You could run it under wine.

Oh... before the additional note in the original post, sorry.

Edit: Woohoo, found one!

http://www.comp.leeds.ac.uk/jj/linux/siggen.html

Apparently the software Audacity can do it also.

Referencing http://ubuntuforums.org/showthread.php?t=308065

Brandon Frohbieter
  • 17,563
  • 3
  • 40
  • 62