Ffmpeg
ffmpeg can do this as usual.
Create a 5 second mono 1000 Hz sine wave out.wav sound file:
sudo apt-get install ffmpeg ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" out.wav
Instead of stereo:
ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" -ac 2 out.wav
The file will be 2 times larger, and ffprobe will say that it has 2 channels instead of 1 channel .
Play audio for 5 seconds without creating a file:
ffplay -f lavfi -i "sine=frequency=1000:duration=5" -autoexit -nodisp
Play forever until you lose your mind:
ffplay -f lavfi -i "sine=frequency=1000" -nodisp
Documentation:
Another section of sunder Sound Sources describes other useful sound generation algorithms in addition to sine , for example:
Bibliography:
Tested on Ubuntu 18.04, ffmpeg 3.4.6.
An example of creating audio on minimal C without additional libraries
Just for fun: How is the sound represented by numbers in computers?
Ciro Santilli ๆฐ็ ๆน้ ไธญๅฟ ๆณ่ฝฎๅ ๅ
ญๅ ไบไปถ
source share