Thread: Beep command help

  1. #1
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Location
    Lehi, UT
    Posts
    121

    Beep command help

    ok i am very confused on how the beep command works. Can anyone help me. I have just seen it w/ out syntax to look at so here is wat i have

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
        Beep(534, 500);
    }
    can i plx get some syntax for the command and the header file plx.

  2. #2
    For Narnia! Sentral's Avatar
    Join Date
    May 2005
    Location
    Narnia
    Posts
    719
    You must:
    Code:
    #include <windows.h>
    The Beep() function is setup like this:
    Code:
    Beep(Frequency,Length of Beep(in miliseconds);

  3. #3
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Location
    Lehi, UT
    Posts
    121
    THANK YOU very much, honestly there is no sarcasm in that i promise

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Read the documentaion as well as you can.

    http://msdn.microsoft.com/library/de.../base/beep.asp

  5. #5
    Registered User
    Join Date
    Sep 2005
    Posts
    196
    whats this beep thing do?
    Last edited by lilhawk2892; 09-05-2006 at 09:50 PM.

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Read the link posted. It's a windows-specific function that lets you specify the time etc of the beep (but it may be ignored).

    It might be simpler to print a '\a', in my opinion.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    I can't believe what you said before yuor edit, lilhawk, wasn't in jest.

  8. #8
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    >> whats this beep thing do?

    Hmmm, thats a tough one ... maybe it makes the PC speaker beep?

  9. #9
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Beep() is mainly used in windows programs to dectect an error

    Code:
    MessageBox(NULL, "Beep", "Listen to me rock",
              MB_OK | MB_ICONINFORMATION);
    Ever wondered how the above program makes the beep? well now you know!

  10. #10
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Well, actually it calls MessageBeep(), which first tries to look up a configured sound file, if a sound card is present, and only resorts to the PC speaker as a last resort.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  11. #11
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Location
    Lehi, UT
    Posts
    121
    ok how come i did it and it came out of my pc speaker not my sound card, so now for another quesiton how to i pass sound to my sound card.


    and with "\a" it is one tone, there is not changing the tone and length of it.

  12. #12
    Registered User
    Join Date
    Sep 2005
    Posts
    196
    yes i know thats why i edited my post...and why the hell would i ask what this did if i didnt try it myself....everybodys a genius i guess

  13. #13
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    and with "\a" it is one tone, there is not changing the tone and length of it.
    Same as with Beep() on earlier versions of Windows. Why do you really need to control the length and volume and pitch of the beep? It's just a beep. If you do need to control the length etc, then it isn't a beep.

    ok how come i did it and it came out of my pc speaker not my sound card, so now for another quesiton how to i pass sound to my sound card.
    What version of Windows do you have?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  14. #14
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    ok how come i did it and it came out of my pc speaker not my sound card, so now for another quesiton how to i pass sound to my sound card.
    You can't.

    Use PlaySound(), or one of the other sound related functions.


    There are lots of "ifs" with Beep()... It's kinda flakey! Read the MSDN link again. With Win2K and newer, the specified beep (frequency/duration) comes out of the internal speaker.

    With Win98 and older, you get the "Windows default sound" out of the soundcard-speakers, not your specified frequency/duration "beep". If you don't have a soundcard, you get the default beep, again ignoring the frequency/duration.

    None of the conditions are supposed to send your specified frequency/duration beep to the soundcard.
    Last edited by DougDbug; 09-06-2006 at 05:17 PM.

  15. #15
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Location
    Lehi, UT
    Posts
    121
    can you give me syntax for play sound, is it another windows command?
    -- Will you show me how to c++?

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