Jump to content
  • Advertisement
Sign in to follow this  
ablaye

How to play MP3? OpenGL and DirectX

This topic is 4530 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

Hi! I like to know how i can play MP3 sound with directX and/or openGL. A solution without using OpenGL and DirectX would be also useful. PS: I can decode MPEG2 videos but then there is no sound. The video is already rendered into a texture. But now I need the matching sound in background! Thanks for advance!

Share this post


Link to post
Share on other sites
Advertisement
MP3s can not be played using OpenGL. Use DirectShow to play an MP3 file. Use Google and you should find a bunch of tutorials on the subject. There are other libraries that also play MP3s but I don't know of any specific ones off the top of my head.

Share this post


Link to post
Share on other sites
FMOD has the capability to decode and play mp3s, though you're on your own when it comes to licensing.

Share this post


Link to post
Share on other sites
If you are already using OpenGL for rendering, you'd probably want the similar interface for sound named OpenAL.

Share this post


Link to post
Share on other sites
The GL in OpenGL stands for Graphics Library. You can't play sounds with it.

Share this post


Link to post
Share on other sites
Quote:
Original post by nife
If you are already using OpenGL for rendering, you'd probably want the similar interface for sound named OpenAL.


You can't use AL to load MP3. You need a decoder lib, then you pass the raw PCM data to AL... or whatever sound API you use.
FMOD has a built in MP3 decoder but for commercial projects, you have to buy it.

Share this post


Link to post
Share on other sites
Writing a basic Ogg Vorbis decoder and coupling that with OpenAL is a free surefire way to have audio - and work on platforms that don't have directX. Considering, you are supporting OpenAL, you should also strive be be platform independent.

If you can't be bothered to write your own (I have, and is pretty simple), then, I strongly suggest Fmod. It is a great sound engine, and you can use it for free for free projects, and it works on Win32, Linux, Mac, etc. And, for small free apps, you can generally avoid paying any MP3 royalties either - but I still suggest ogg vorbis, Fmod can handle that fine.. And you will be supporting a superior coded :)

Share this post


Link to post
Share on other sites
Quote:
Original post by V-man
Quote:
Original post by nife
If you are already using OpenGL for rendering, you'd probably want the similar interface for sound named OpenAL.


You can't use AL to load MP3. You need a decoder lib, then you pass the raw PCM data to AL... or whatever sound API you use.
FMOD has a built in MP3 decoder but for commercial projects, you have to buy it.


This really isn't an issue. There are plenty of tutorials/examples on how to do this with OpenAL and you don't have to buy anything and it has a near identical API as OpenGL. DevMaster has great articles at the bottom of that link about how to load/play .ogg files. You can always convert .mp3 to .ogg (I think .ogg is a better format anyways but that's just me).

Best of luck.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!