Thread: Beep

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    49

    Beep

    I'm trying to make my computer play sounds. I know there are old DOS functions called sound(); delay(); nosound(); that don't work on visual c++.

    I tried using Beep(). This one doesn't play sounds either. I think the problem is that I just don't have an internal speaker.

    Do you hear anything?
    Code:
    #include <windows.h>
    
    int main()
    {
    	Beep(216, 2000);
    	return 0;
    }

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Yes, loud and clear.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Here's an annoying program. It'll make your windows computer sound like...well... a "TV" computer.

    Todd

    Code:
    #include <stdlib.h>
    #include <windows.h>
     
    int main(int argc, char* argv[])
    {
                int frequency, duration ; 
               
                while(1) { 
                            duration = rand() % 250 ; 
                            duration = duration ? duration : 1 ;
                            frequency = (rand()+1) % 6000 ;
                            Beep(frequency, duration ) ; 
                }
                return 0;
    }

  4. #4
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    The Beep() function is kind-of screwy. The results depend on if you have a soundcard, and your operating system. On some systems, the frequency parameter will be ignored. On some systems, both paramaters will be ignored and it will play the "Windows default sound" from your soundcard and external speakers.

    But, I couldn't find the reference to all of that on MSDN just now...

    You might want to use Playsound() or one of the MIDI functions.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. linux beep function
    By Calef13 in forum C++ Programming
    Replies: 7
    Last Post: 07-14-2007, 01:39 AM
  2. I need to play a pre recorded vox file using C
    By m.sudhakar in forum C Programming
    Replies: 4
    Last Post: 11-17-2006, 06:59 PM
  3. alert beep sound
    By bazzano in forum C Programming
    Replies: 3
    Last Post: 02-14-2006, 02:24 PM
  4. Beep();
    By SirCrono6 in forum C++ Programming
    Replies: 7
    Last Post: 02-22-2004, 04:47 PM
  5. Something Like beep()
    By Trauts in forum C++ Programming
    Replies: 3
    Last Post: 02-02-2003, 02:51 PM