Play sound file

I need a way to play a sound file in the background when the C program is running.I'm using windows. How to play a midi file would be sufficient. And please I need a code snippet , not some link to a 10 page site that I won't understand.
Use this API Function in windows.h

 
PlaySound("C:\\SOUNDS\\BELLS.WAV", NULL, SND_ASYNC);


Source: http://www.dreamincode.net/forums/showtopic18352.htm

This may not play large .wav files. (more than about 1MB)

Edit: More on the PlaySound function
http://msdn.microsoft.com/en-us/library/ms712879.aspx
Last edited on
Okay, I suppose I could just convert all the sound files that I want to play int .wav format. Thanks for the help.
Do you know how to convert a midi file into a .wav file while keeping it less than 1MB?(I seem to have a problem in that my converter transforms a 10 KB midi file into .wav file larger than 1 MB even under the worst possible quality).
This might work:

http://manuals.opensound.com/developer/softsynth.c.html

but there's no percussion

You might also want to convert into another format ogg, mp3, etc. There are APIs for those
Last edited on
I read the entire page, I didn't understand a word, and I don't even know the purpose you gave the link for.
But how do you play other formats?(I mean what are the functions?)
Last edited on
The playsound function works(sorry for the stupid comment that I just deleted). But I still need either a way to convert my sound files to small sized .wav files, or the functions that can play ogg, mp3... .Thank you in advance.
Just use Win32 MM apis to play MP3, WMA, etc...
"Just use Win32 MM apis to play MP3, WMA, etc... "
A code snippet like the one in the first reply would be great.(I don't really know what the parameters mean or if there is a return value nor do I really care to know, I'll just copy the code snippet and paste it inside my code and also keep it for later use.)
If you are not willing to learn then forget programming.
"If you are not willing to learn then forget programming."
Understanding how to play sound files is the least important thing I can think of in C programming. I'm the first in my class in programming and I know everything essential to writing a c program, and playing sound files is merely decoration, that's why I said I didn't care to understand what the parameters mean. I guess I won't be expecting any help anymore.
Topic archived. No new replies allowed.