Can anyone recommend an audio decoding library?

Started by
6 comments, last by mmakrzem 10 years, 8 months ago

I'm looking for a cross platform library for decoding audio. Up until recently my game used SDL_Mixer for both decoding and playback but then I switched to OpenAL for playback and kept decoding with SDL_Mixer. SDL_Mixer has a few problems that make it non ideal for my project, it doesn't support many formats and it's strengths seem to be more with playback. What I need is a simple library that can load audio file and place them in a buffer for OpenAL to access. Does anyone have any experience with good libraries that they would recommend? I need support for at least the following formats:

FLAC

OGG

MIDI

WAV

Thanks.

EDIT: Forgot to mention I was using C++, C libraries are acceptable too though

Advertisement

It seems like BASS may do what you want.

http://www.un4seen.com/bass.html

Decode without playback

Streams and MOD musics can be outputted in any way you want (encoded, written to disk, streamed across a network, etc...)

It seems like BASS may do what you want.

http://www.un4seen.com/bass.html

Decode without playback

Streams and MOD musics can be outputted in any way you want (encoded, written to disk, streamed across a network, etc...)

Yeah BASS seems pretty cool and it seems to do what I need but the license could get a little restrictive in case I wanted to sell.

BASS is free for non-commercial use. If you are a non-commercial entity (eg. an individual) and you are not making any money from your product (through sales, advertising, etc), then you can use BASS in it for free. Otherwise, one of the following licences will be required.

To be honest, you're going to have a hard time finding a library that can do all of those (with a permissive license). The biggest problem will be MIDI. Most of the audio decoding libraries I know of don't support MIDI, and the ones I know of that do are commercial. If you're okay with the LGPL, there are FFmpeg and sndfile that can be used to decode FLAC, OGG (Vorbis), and WAV. As for MIDI support, you may have to use another library that only supports MIDI, and then write a common wrapper around your two audio decoding libraries (which will choose the right decoder for the specified format).

[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

To be honest, you're going to have a hard time finding a library that can do all of those (with a permissive license). The biggest problem will be MIDI. Most of the audio decoding libraries I know of don't support MIDI, and the ones I know of that do are commercial. If you're okay with the LGPL, there are FFmpeg and sndfile that can be used to decode FLAC, OGG (Vorbis), and WAV. As for MIDI support, you may have to use another library that only supports MIDI, and then write a common wrapper around your two audio decoding libraries (which will choose the right decoder for the specified format).

Yeah I suppose I could live without MIDI

If you really like to load only sound files, either use wave for simple/short ones and this ogg-vobis loader (public domain, single header file !) for music streaming and larger files. You can convert audio files with audacity (open source tool).

Check SFML: http://stackoverflow.com/questions/3636715/cross-platform-sound-api-for-games

https://github.com/LaurentGomila/SFML/wiki/FAQ#wiki-audio-formats

EDIT: IrrKLang is commercial, but doesn't cost that much and supports MOD and XM, to which MIDI can be easily converted.

I use Vorbis for sounds: http://www.vorbis.com/

This topic is closed to new replies.

Advertisement