post  Playing Sounds

NerdyOgre254 (17)   Link to this post
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.
Mal Reynolds (103)   Link to this post
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.
Return 0 (510)   Link to this post
Google SDL_mixer. The API provides a very clear interface for playing audio files.
computerquip (618)   Link to this post
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
george135 (209)   Link to this post
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
Return 0 (510)   Link to this post
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.
george135 (209)   Link to this post
???
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
computerquip (618)   Link to this post
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.
kbw (1101)   Link to this post
It's unlikely that a generic cross-platform library will be more efficient than a native one.
computerquip (618)   Link to this post
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
Grey Wolf (1407)   Link to this post
the benefit of being cross-platform is a great advantage.

Surly, only if you are interested in cross-platform.
chrisname (1342)   Link to this post
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/
Return 0 (510)   Link to this post
I've played around with Dark GDK before... it is easy to use, but nothing to be excited about...
NGen (160)   Link to this post
I like how they say that the DarkGDK is made for use with C++ when they only give a C interface.
chrisname (1342)   Link to this post
LOL; I thought it was primarily written in C++?
Oh well. I was going to try it and see for myself, but oh well.
NGen (160)   Link to this post
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.

Registered users can post in this forum.