C++/sound

Advertisement


Question
hello sir,,,can u pls tell hw to play a wave/mp3 file in c++.
i am using turbo c++ ver 3.0.


Answer
To play a wav file you can use the windows multimedia API function
PlaySound


Here is a sample
#include <Windows.h>

int main(void)
{
   PlaySound("c:\\Windows\\Media\\chimes.wav", NULL, SND_FILENAME);
}

You will need to link in the Winmm.lib library. I don't know how this will fit in with Turbo C++. That is a very old compiler and may not be compatible with newer libraries, and I cannot give you help with it. All I know is that the above program worked for me, but I compiled with visual studio 2010. You can get a free visual studio C++ express edition from http://www.microsoft.com/express/Downloads/#2010-Visual-CPP

I don't know how to play mp3 files. Sorry, that is the best I can do.

Best regards
Zlatko

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Zlatko

Expertise

No longer taking questions.

Experience

No longer taking questions.

Education/Credentials
No longer taking questions.

©2012 About.com, a part of The New York Times Company. All rights reserved.