Playing Sounds

Oct 27, 2009 at 1:06pm
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.
Oct 27, 2009 at 2:24pm
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.
Oct 27, 2009 at 2:29pm
Google SDL_mixer. The API provides a very clear interface for playing audio files.
Oct 27, 2009 at 5:04pm
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
Oct 28, 2009 at 7:54am
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 Oct 28, 2009 at 7:57am
Oct 28, 2009 at 6:22pm
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.
Oct 29, 2009 at 10:56am
???
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 Oct 29, 2009 at 10:58am
Oct 29, 2009 at 4:05pm
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.
Oct 29, 2009 at 4:27pm
It's unlikely that a generic cross-platform library will be more efficient than a native one.
Oct 29, 2009 at 5:01pm
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 Oct 29, 2009 at 5:02pm
Oct 29, 2009 at 6:01pm
closed account (z05DSL3A)
the benefit of being cross-platform is a great advantage.

Surly, only if you are interested in cross-platform.
Nov 11, 2009 at 7:04pm
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/
Nov 11, 2009 at 7:35pm
I've played around with Dark GDK before... it is easy to use, but nothing to be excited about...
Nov 12, 2009 at 12:05am
I like how they say that the DarkGDK is made for use with C++ when they only give a C interface.
Nov 12, 2009 at 1:05pm
LOL; I thought it was primarily written in C++?
Oh well. I was going to try it and see for myself, but oh well.
Nov 12, 2009 at 8:01pm
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.