c++ playing a sound

Hello,
I am trying to create a program wich, when executed, does nothing but play's a sound. I have tried searching the web and the forum, although I found a lot of information I did not find the information I was looking for.
I would really appreciate if someone could help me out!

Thank you,
Jindra
You'll need to either use an audio lib... or use platform specific code.

If you are on Windows, there's the PlaySound() WinAPI function that you can use to load and play a wav file.

http://msdn.microsoft.com/en-us/library/windows/desktop/dd743680(v=vs.85).aspx
Or, you can just cout << '\a' (or printf it or whatever), which plays a single beep. Not sure if you'll find it very useful though (unless you want to annoy people).
@jindros

Here's another option..

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;
}
Topic archived. No new replies allowed.