I am experimenting with Beep function on Windows:
#include <windows.h>
...
Beep(frequency, duration);
The computer then beeps with some frequency for some duration. How would I do this on a Linux computer?
Edit: It IS important to output different frequencies.
Open a Python shell by typing the python command in your terminal. Import the os library using import os in your Python shell. Run the os. system() function and pass the "beep -f 2000 -l 1500" string command to run the beep command on your Linux system with 2000 Hz frequency and 1500 ms duration.
The cross-platform way to do this is to print('\a') . This will send the ASCII Bell character to stdout, and will hopefully generate a beep (a for 'alert'). Note that many modern terminal emulators provide the option to ignore bell characters.
This command causes the computer to generate a beep sound. It is often used to emphasize a customized message or warning dialog during data entry.
Check out the source code for beep available with Ubuntu (and probably other distros) or have a look at http://www.johnath.com/beep/beep.c for another source (it's the same code, I believe).
It allows you to control frequency, length and repetitions (among other things) with ease.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With