Teen Programmers Unite  
 

 

Return to forum top

How to play wave files using C++??

Posted by realnewbie [send private reply] at March 25, 2002, 10:03:29 AM

as above!!

Posted by RedX [send private reply] at March 25, 2002, 12:36:39 PM

Simple: write the code to load a .wav-file, then write the code to use a sound card followed by writting the code to have a wav-file played on the sound card. Which you don't want to do, since this is time-consuming and very difficult to do unless you only want to use the program on one particular PC.

OR you could use one of the standard APIs to load and play the wav. (DirectX for example) Which one depends on what OS you target.

RedX

Posted by AREM [send private reply] at March 25, 2002, 08:19:12 PM

One API call that will do it is PlaySound. To use this API you need mmsystem.h included and you need to link winmm.lib to the project. If you use VC++ this can be done by clicking Project and Settings from the menu bar.

Posted by Psion [send private reply] at March 25, 2002, 09:26:38 PM

It's interesting that you assume he is writing this code for Windows.

Posted by realnewbie [send private reply] at March 26, 2002, 07:49:43 AM

Thnks for all the help!!

actually i'm creating a game! using C++ (Win32 App)

but i dun know the codings on how to load the sounds??
like when i press space bar, a bullet will come out but with the sound!!

pls help!!

Posted by realnewbie [send private reply] at March 26, 2002, 07:55:51 AM

there are certain codings on loading sounds..but i have no ideal..

Posted by Psion [send private reply] at March 26, 2002, 08:01:05 AM

realnewbie, did you see that AREM told you about the PlaySound function? If you don't know how to look up help on a function, then you should learn now.

Posted by realnewbie [send private reply] at March 26, 2002, 08:26:29 AM

Psion..ok..no problem i will try it ..thanks

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.