Thread: Trying to play a beep

  1. #1
    Registered User Eielef's Avatar
    Join Date
    Apr 2012
    Posts
    9

    Question Trying to play a beep

    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?

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    You could try this code. It uses ioctl with the request field as KIOCSOUND.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  3. #3
    Registered User Eielef's Avatar
    Join Date
    Apr 2012
    Posts
    9
    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??

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. beep when even?
    By Ahmed29 in forum C++ Programming
    Replies: 7
    Last Post: 11-07-2008, 05:14 AM
  2. Beep
    By misterowakka in forum C++ Programming
    Replies: 3
    Last Post: 01-29-2008, 05:19 PM
  3. how to play play and stop wav files
    By cnu_sree in forum Linux Programming
    Replies: 4
    Last Post: 08-14-2006, 11:11 PM
  4. Something Like beep()
    By Trauts in forum C++ Programming
    Replies: 3
    Last Post: 02-02-2003, 02:51 PM
  5. Beep
    By Stan100 in forum C++ Programming
    Replies: 19
    Last Post: 01-30-2003, 12:13 PM