Can I load audio with SDL and then play it with OpenAL?

Started by
4 comments, last by Servant of the Lord 12 years, 11 months ago
Basically the title says it all, can I load audio with SDL and then play it with OpenAL? Currently using Libogg but SDL also offers features for loading images so I'm hoping I can use SDL as an all encompassing cross platform general media library.
Advertisement

Basically the title says it all, can I load audio with SDL and then play it with OpenAL? Currently using Libogg but SDL also offers features for loading images so I'm hoping I can use SDL as an all encompassing cross platform general media library.


I can't answer your question directly, but maybe this sound library will help? I've never used it, but it's LGPL license, works with OpenAL, but based on SDL_mixer in concept (but not dependency), and uses SDL_Sound to load different audio formats, and even allows you to do things like play multiple music files over one another (which SDL itself doesn't like).
Also, you can intermix OpenAL function calls and this library's function calls freely and safely.


[color=#333333][font=Helvetica, Arial, sans-serif]ALmixer (which I sometimes call "SDL-OpenAL-Mixer" or "SDL_ALmixer") is a cross-platform audio library built on top of OpenAL to make playing and managing sounds easier.[/font][color=#333333][font=Helvetica, Arial, sans-serif]

ALmixer provides a simple API inspired by SDL_mixer (http://www.libsdl.org/projects/SDL_mixer) to make playing sounds easy with having to worry about directly dealing with OpenAL sources, buffers, and buffer queuing directly.

ALmixer currently utilizes SDL_sound (http://icculus.org/SDL_sound) behind the scenes to decode various audio formats such as WAV, MP3, AAC, MP4, OGG, etc.

This library is targeted towards two major groups:<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">

- People who just want an easy, high performance, way to play audio (don't care if it's OpenAL or not)<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">

- People who want to an easy way to play audio in OpenAL but still want access to OpenAL directly for effects.

ALmixer is under the LGPL license.[/quote]

[/font]

[quote name='SteveDeFacto' timestamp='1304949445' post='4808538']
Basically the title says it all, can I load audio with SDL and then play it with OpenAL? Currently using Libogg but SDL also offers features for loading images so I'm hoping I can use SDL as an all encompassing cross platform general media library.


I can't answer your question directly, but maybe this sound library will help? I've never used it, but it's LGPL license, works with OpenAL, but based on SDL_mixer in concept (but not dependency), and uses SDL_Sound to load different audio formats, and even allows you to do things like play multiple music files over one another (which SDL itself doesn't like).
Also, you can intermix OpenAL function calls and this library's function calls freely and safely.


[color="#333333"][font="Helvetica, Arial, sans-serif"]ALmixer (which I sometimes call "SDL-OpenAL-Mixer" or "SDL_ALmixer") is a cross-platform audio library built on top of OpenAL to make playing and managing sounds easier.[/font][color="#333333"][font="Helvetica, Arial, sans-serif"]

ALmixer provides a simple API inspired by SDL_mixer (http://www.libsdl.or...jects/SDL_mixer) to make playing sounds easy with having to worry about directly dealing with OpenAL sources, buffers, and buffer queuing directly.

ALmixer currently utilizes SDL_sound (http://icculus.org/SDL_sound) behind the scenes to decode various audio formats such as WAV, MP3, AAC, MP4, OGG, etc.

This library is targeted towards two major groups:<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">

- People who just want an easy, high performance, way to play audio (don't care if it's OpenAL or not)<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">

- People who want to an easy way to play audio in OpenAL but still want access to OpenAL directly for effects.

ALmixer is under the LGPL license.[/quote]

[/font]
[/quote]

Well I guess that proves it in practice. SDL can be used to load audio files and then they can be played with OpenAL.
Perhaps, I don't know if they do any internal converting. Since it's LGPL, you could download the source and see how they handle it.

Perhaps, I don't know if they do any internal converting. Since it's LGPL, you could download the source and see how they handle it.



Hmm... Yeah, I'm not really sure how to get the format and raw audio data from the Mix_Music class. I downloaded the source of SDL_mixer and from what I can tell the information stored in the Mix_Music class can be one of many other sub classes which means a simple cast is out of the question. However, perhaps there are some SDL functions to get the information I seek from the Mix_Music class. I'm going to try to download the source from the library you linked and hope it sheds some light on how I could do this.

EDIT: Now that I've read over the description again I see it uses SDL_sound but was inspired by SDL_mixer. I've looked at SDL_sound but I'm not sure where to download it and all of the download links I've found have not been updated since 2008...

EDIT: Now that I've read over the description again I see it uses SDL_sound but was inspired by SDL_mixer. I've looked at SDL_sound but I'm not sure where to download it and all of the download links I've found have not been updated since 2008...


http://icculus.org/SDL_sound/
http://icculus.org/SDL_sound/downloads/

You're right, it hasn't been updated since late 2008 it looks like. However, recently updated does not mean it's of greater quality.
I never used SDL_sound, but I'd go ahead and download it, and see what you can make of it. If it works, it works. If not, then go back to the drawing board. You're only really using it for loading, after all. You were wanting to do the actual playing with OpenAL.
If ALmixer still functions properly (and as of a [url="http://playcontrol.net/opensource/ALmixer/backstory.html"]2010 post[/url], that seems to be the case), then go ahead and use it.

This topic is closed to new replies.

Advertisement