-
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;
}
-
-
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;
}
-
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.