Playing Sounds

Hey all,
Can anyone give me a quick runthrough of how I correctly code to play an audio file? I need to dynamically link it as well, as writing the full file path isn't good practice.
Thanks.
it depends what format the audio file is in. if the audio file is a .wav file, you can use the PlaySound() function from the windows API. if it is not a .wav file, the only way that I know of to play sound files is to use a library that supports the type of file you are working with.
Google SDL_mixer. The API provides a very clear interface for playing audio files.
closed account (S6k9GNh0)
You could also use basic parts of the OpenAL API and decode the music you want with seperate libraries yourself. This is the standard way. :D
the only way that I know of to play sound files is to use a library

No, you don't need any external library (never in Windows)
You can play any sound (MP3, WMA, ..) with standard and native Win32 api (MM apis, DS, etc... and others, see SDK samples)
Last edited on
george135... I'm really confused about you. You've never posted a single line of code in any post I have ever seen you make... I would swear you are some kind of AI Microsoft Marketing bot and not a real person.
???
Why do you want that I copy-paste the code from MS ?
Can't you download and look at MS SDK samples ?
Each Win32 C or C++ sample has several source files with hundreds of lines of code !
Last edited on
closed account (S6k9GNh0)
george135, why the hell would you use Microsoft's WinAPI when you could just as easily use a cross-platform and possibly even more effecient library. What you just said is literally the WORST advice I've EVER seen anyone give.
It's unlikely that a generic cross-platform library will be more efficient than a native one.
closed account (S6k9GNh0)
For audio decoding and encoding, the likelyhood that there was much effort going into making it cross-platform is unlikely. There aren't many components that the audio decoding and encoding library needs to rely on to make them cross-platform. Even if it wasn't more effecient, the benefit of being cross-platform is a great advantage.
Last edited on
closed account (z05DSL3A)
the benefit of being cross-platform is a great advantage.

Surly, only if you are interested in cross-platform.
I thought someone would have suggested the "Dark GDK".

I'm glad they didn't, because it looks bad. Like it's meant to be easy to use.

http://gdk.thegamecreators.com/
I've played around with Dark GDK before... it is easy to use, but nothing to be excited about...
I like how they say that the DarkGDK is made for use with C++ when they only give a C interface.
LOL; I thought it was primarily written in C++?
Oh well. I was going to try it and see for myself, but oh well.
If you look in the headers, you can see some classes (or structs) being used internally, so I guess you can say that it uses C++, but for some strange reason they thought that they should give functions to do everything. They have you use id's to indicate specific models. While you can build your own set of classes to manage these objects for you, it would probably be faster if they actually gave an OO interface themselves.
Topic archived. No new replies allowed.