Stereo "tone-generator" for linux?

It sounds like you're looking for Audacity which is a cross-platform open source audio editor. One of its features is to allow you to generate tones. It's a multi-track audio editor, so you can easily create a stereo tone.

Under the Generate menu, you're able to create Sine, Sawtooth, and Square waveform tones of arbitrary frequency, amplitude, and length without the need for recording or needing additional input files.


You might look at speaker-test, which (on an Arch machine) I find in alsa-utils package.

speaker-test -c2 -t sine run from an xterm, gave me a 440 Hz sine wave for about 6 seconds each, alternating left and right speakers. In the xterm, it gave some information about which speaker it thought it was using.

According to the man page, it can do sine waves of arbitrary frequency and pink noise.


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 with -ac 2:

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:

  • https://ffmpeg.org/ffmpeg-filters.html#sine
  • https://www.ffmpeg.org/ffmpeg-devices.html#lavfi

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

  • anoisesrc: noises of several colors, e.g. white, pink, brown
  • aevalsrc takes arbitrary mathematical expressions, and should therefore be able to produce triangular waveforms (TODO expression)

Bibliography:

  • https://superuser.com/questions/724391/how-to-generate-a-sine-wave-with-ffmpeg
  • https://stackoverflow.com/questions/11831214/how-to-run-ffplay-as-a-window-less-process/53295994#53295994

Tested in Ubuntu 18.04, ffmpeg 3.4.6.

Minimal C audio generation example without extra libraries

Just for fun: https://stackoverflow.com/questions/732699/how-is-audio-represented-with-numbers-in-computers/36510894#36510894