Archived

This topic is now archived and is closed to further replies.

How do I use .wav? plzz anser...

This topic is 6079 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, I''m almost done with my first game written in cpp, but while playing it I get bored so I really need to chear this thing up. So I got some really great wav files for the music and sound effects. The thing is I cannot get them to work, I''m using Bc++5 and doing fully 16bit dos. Please help me out! --------------------------- MasterBlaster(CodeFighters) ---------------------------

Share this post


Link to post
Share on other sites
That''s really tough. Not only do you have to support certain sound cards--you access each one differently, so if you want it to work on lots of different machines, you''ll need to handle lots of different cards (but at least Sound Blaster).

Once you know how to communicate with the sound card, it gets easy. Go to www.wotsit.org and look for info on the WAV format. What you''ll need to do is parse the header in order to grab important information such as the samling rate, number of channels, etc. After that header is just raw sample data, so you''ll basically just send that to the sound card.

But it''s not that easy at all...which is why many people use something like Allegro for such things.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
yes, merlin is right. back in the day, game programmers had to write software to work with the many types of sound cards, and video cards on the market. directX bypasses this all together now days and the card vendors supply the device drivers that interface with the DirectX api. The only way to play a wav is to first make sure you know where your card is located, irq,etc. After that, you need to understand how to load a wav file. Get the file format like merlin said. Once you know how to get the data from the file, then you need to learn how to send that data through the sound card. In order to do this, you use the driver functions supplied with the sound card to play them. You allocate memory for the driver, then load the wav into a buffer. After you load the wav into a buffer, you call the appropriate driver function with the address of the buffer you just loaded, and the driver will handle the sound output. this type of output is most easily done using assembly language, but you need to write all the sound playing supporting functions. These include initializing the drivers, loading the wav buffer, yadda yadda. Its a lot of work, but, hey..you wanted to know.

Share this post


Link to post
Share on other sites
Yeah, I strongly recommend you use Allegro or a similar library. That is unless, of course, you want to spend 5 months writing, testing, and debugging your own stuff--something that will keep you from working on your actual application.

Share this post


Link to post
Share on other sites