Jun 5, 2017 at 4:45am Jun 5, 2017 at 4:45am UTC
Does anybody remember how to make the default PC speaker to beep? I'm not looking for a library, I'm looking for a line or two of code for Windows, or standard C/C++
A link would be cool too!
Thank you in advance!
Jun 5, 2017 at 5:07am Jun 5, 2017 at 5:07am UTC
Windows Beep function:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms679277(v=vs.85).aspx
C/C++ Escape sequences:
http://en.cppreference.com/w/cpp/language/escape
Jun 5, 2017 at 6:04am Jun 5, 2017 at 6:04am UTC
Oh perfect ....
Beep( int hertz, int duration);
Beep( 750, 100);
but now I'm looking to change the volume of that beep and all I can find is system volume control.
Any suggestion?
Jun 5, 2017 at 4:13pm Jun 5, 2017 at 4:13pm UTC
You can't change the volume. Reread the Remarks section of the Beep function.
Most, if not all, new computers don't have a built-in PC speaker any more. A PC makes sound now by a sound card.
Jun 5, 2017 at 6:41pm Jun 5, 2017 at 6:41pm UTC
if it still works, you can do this in a console program on windows..
cout << (char)7; //I think char(7) and static cast also work, as you will.
You can't do much with it... volume and sound and all are pre-programmed.
Last edited on Jun 5, 2017 at 6:42pm Jun 5, 2017 at 6:42pm UTC
Jun 6, 2017 at 12:48am Jun 6, 2017 at 12:48am UTC
Thank you.
I'm working on a DOS Terminal/Text game, and hoping to have some "music" with it, but from the sounds it made, was just painful to listen too.
Thank you for all the great advice!
Jun 6, 2017 at 2:34am Jun 6, 2017 at 2:34am UTC
oh, that's doable, but significantly more work. you can just cheat and have your program tell windows media player to play something in the background or the like, for a simple solution.