Hi!
How can I play a beep in a program made in C++ in linux? What library do I have to use? It allows me to controle the duration and the frequency of the sound?
Printable View
Hi!
How can I play a beep in a program made in C++ in linux? What library do I have to use? It allows me to controle the duration and the frequency of the sound?
You could try this code. It uses ioctl with the request field as KIOCSOUND.
Thank you for the help, but I think I didn't explain propertly what I'm looking for. I'm writing a code in c++, in which I want to introduce a function to play a beep. Like, for example, when you press a key, a beep sounds. I tried to print "\a" and "\7". It works in windows, but not in linux, so I thought I could try to find some library with a function that could do that for me.
This code seems to be meant to be installed and used from the command line. I have been reading it, and my level of knowledge is not enough to make a function using it. So, I made a little of google search about printing "\a". But I don't know why it isn't working. I'm actually emulating ubuntu-11 in Oracle VM VirtualBox, so could be because of that, but I couldn't find why it doesn't work. Can anyone gave me some directions or a pointer to where pages should I look for to just be able to play a "beep", or at least to understand why a simple (cout<<"\a"; ) doesn´t work??