How the *beep* do I make this work?

Great. So I have a simple question about making "beeping" sounds in the console. I have tried the Beep() function in the Windows API, but the sound was nonexistent since Microsoft decided to drop support for that function in Windows Vista (I have Vista Home Premium.) So is there any other way (without going to external libraries) to make this sound?

Please respond as fast as you beeping can.
Last edited on
1
2
3
4
5
6
7
#include <iostream>

int main()
{
    std::cout << "\a" << std::endl;
    return 0;
}
Haha, function puns should be a requirement for OPs....
Windows-Only Solution: MessageBeep()
https://msdn.microsoft.com/en-us/library/windows/desktop/ms680356(v=vs.85).aspx
Cross-Platform Solution: "\a"
Try this program, and see if you get results. If not, I don't know what the *beep* to tell you..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Beeping Sounds.cpp : main project file.

#include <iostream>
#include <Windows.h>


int main()
{
	std::cout << "You can use the 'Beep' command, in the windows header" << std::endl;
	std::cout << "to create sounds, as well.." << std::endl;
	Beep(1000, 1000);// Beep(pitch, length in milli-seconds)
	Beep(1521, 400);
	Beep(2521, 500);
	Beep(3521, 600);
	Beep(4521, 700);
	Beep(3521, 600);
	Beep(2521, 500);
	Beep(1521, 400);
	return 0;
}
So is there any other way ...

Another Windows specific solution:

You could use PlaySound
https://msdn.microsoft.com/en-us/library/windows/desktop/dd743680%28v=vs.85%29.aspx

with a .WAV of the beep?

Andy

PS The remarks section of the MSDN entry for the Beep function does mention MessageBeep() !!
https://msdn.microsoft.com/en-us/library/windows/desktop/ms679277%28v=vs.85%29.aspx
Last edited on
Topic archived. No new replies allowed.