Tuesday, July 14, 2009

Including audio in a C++ file??

can any1 write me a simple code for including(importing or watever) a .wav or any odr format sound file and play it on d running of d program automatically??? pls help urgently

Including audio in a C++ file??
What you can do is issue a call to MCI to handle the audio file.
Reply:Uh, for which operating system? If it's DOS, then you have to search for pre-built libraries for sound and music, then run your program in DOS BOX (DOS emulator program). Back then, you had to program sound cards directly and build you own sound/music engines if you didn't want to purchase one.





For Windows, if you're using a framework like Borland's VCL or Microsoft's MFC, then you'll have to look in your framework's reference files to find the sound/music playing functions.


If you're programming with the Windows API, you can use different multimedia functions. For playing .wav files, you can use the sndPlaySound() function. For simple playback of .wav %26amp; other types of sound/music files, you can either use the MCI or DirectShow functions. MCI is older and most people use DirectShow nowadays, but MCI is simpler to use.





Example of mciSendString() function to play a MIDI file:


mciSendString( "play c:\midi\myfile.mid",0 ,0, 0);


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


No comments:

Post a Comment