wait function and sound

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • memyselfandmiah
    New Member
    • Sep 2007
    • 2

    wait function and sound

    I am in a cpp class, but i am messing around the program on my own, and I am looking for some commands. or at least a place that i can go to find commands that i want.

    There are 2 questions that I currently have. When i started with coding (way back on QBASIC) there were 2 commands that it seems like should be somewhat universal. one was a wait function. IE, in a loop function a command that makes the program wait for time N before it continues.

    The other is a sound function. not the beep function, but where you could play freaquency x for time y. Is there a command like that for cpp?

    thanks in advance.
  • rajaguru
    New Member
    • Jul 2008
    • 2

    #2
    for(i=0;i<=3000 ;i+=100)
    {
    sound(i);//producing sound with the frequency of i
    sleep(3)// wait for 3 seconds... u can also use the delay functions// delay(300) means, it'll wait for 300 milliseconds
    }

    Comment

    • arnaudk
      Contributor
      • Sep 2007
      • 425

      #3
      Originally posted by rajaguru
      sound(i);//producing sound with the frequency of i
      sleep(3)// wait for 3 seconds... u can also use the delay functions// delay(300) means, it'll wait for 300 milliseconds
      Now in which library are these functions defined, because they're not part of the standard library... ?

      You could write wait functions using the ctime library. Sounds are more OS specific, I think that in windows there is a Beep() function defined in the windows API.

      Comment

      • oler1s
        Recognized Expert Contributor
        • Aug 2007
        • 671

        #4
        I am in a cpp class, but i am messing around the program on my own, and I am looking for some commands. or at least a place that i can go to find commands that i want.
        You have shell commands. You do not have C++ "commands".

        there were 2 commands that it seems like should be somewhat universal
        You are mistaken, then.

        The simplest "wait" functionality is to use a busy loop. But if you want to pause a program's functionality, almost always a busy loop is undesirable. It depends on the system to do this, but look for "sleep" and see how to implement it on your operating system.

        The other is a sound function. not the beep function, but where you could play freaquency x for time y.
        Beeping is simpler, but if you want actual input through the sound card, etc. that's more involved. Again, OS specific. So look it up for your respective platform.

        Comment

        Working...