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++ :).

Um? sorry if im being impatent but are you guys still here?

Do you have the soun/clip in a WAV file?

Still here?

I'll check around, i know someone who did it recently. You may also want to check the following to see if they help you: http://www.codeguru.com/Cpp/G-M/multimedia...icle.php/c4739/

There is a playsound() function that will may sound files....but i think it has a limit of 100kb.

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;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.