How do you incorperate sound files into a C++ program?

I dont know if it matters or not but im using microsoft visual studio 2005 for my compiler and my OS is Windows Xp home

I've always thought about this too....but if you need different colour text..i think you could use "
#define yl system("color 0e");".

It can be tricky, there is a playSound function in C++ but it's not all that powerful so you may be best suited to look for a library to do that, or feel free to get your hands dirty with some DirectX.

:)

http://msdn2.microsoft.com/en-us/library/ms712879.aspx

Ok the site you gave me had this code one it.
BOOL PlaySound(
LPCSTR pszSound,
HMODULE hmod,
DWORD fdwSound
);

but I dont see where I insert the name of my sound file.

I've always thought about this too....but if you need different colour text..i think you could use "
#define yl system("color 0e");".

um ok you lost me here why would I have to change the text color to add a sound file? Although I would like to know how to change the text color also with this code do I just change ("color 0e ") to the color I want?

If so does C++ have built in colors that can be defined just by their name like in HTML or is there another method for defining colors? Hexidecimal codes or something.

In case you guys cant tell I'm fairly new to C++ :).

ok thx pls do talk to the guy that you mentioned :) id really appreciate it thx

What effort have you given this?

Can you post any code?

Some great tutorials have been posted that should get you started.

If you want to try it out the command is

Beep (fequency in cycles, duration in milliseconds); // The capital letter 'B' is mandatory

An additional compiler directive is needed:
#include <windows.h>

Beep(1000, 2000); will make a sound of 1000 cycles for 2 seconds

Well, I've heared about it, try this code! but it think it works on
old compiler such as Turbo C++ V3.

#include <stdio.h> #include <conio.h> #include <stdlib.h> #include <dos.h>

int main() { clrscr(); sound(100); delay(100); //or you can use pause nosound(); // for stopping sound return 0; }[code=c++]
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <dos.h>

int main()
{
clrscr();
sound(100);
delay(100); //or you can use pause
nosound(); // for stopping sound
return 0;
}

Well, I've heard about it, try this code! but it think it works on
old compiler such as Turbo C++ V3.

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <dos.h>

int main()
{
clrscr();
sound(100);
delay(100); //or you can use pause
nosound(); // for stopping sound
return 0;
}
This article has been dead for over six months. Start a new discussion instead.