SDL_audiolib: an audio decoding, resampling and mixing library

Hi folks.

I uploaded a very early version of an audio library I’ve been tinkering
with lately. I started it because I wanted something to replace
SDL_mixer and SDL_sound with. It’s LGPL licensed.

It only outputs mono and stereo right now. Hopefully we’ll get to 7.1
surround later on (for upmixing and playing surround sources.) This is a
2D audio library though; there’s no intent to introduce 3D positioning
of sounds.

It uses three different resamplers: Speex (the Opus version), SoxR and
SRC (libsamplerate). The Speex one is integrated. The others need their
respective external libraries. Resampling only happens when the source
signal’s sample rate doesn’t match the output rate.

It does floating-point mixing of any amount of audio sources. I hope to
add some features like dithering and a limiter in the future, for the
audiophiles :slight_smile:

The audio sources come from decoders. The included decoders rely on
libvorbis, libmpg123, libsndfile, libmodplug and libfluidsynth to play
many different sound formats (Ogg/Vorbis, MP3, FLAC, MOD-based files,
MIDI, WAV, AIFF, etc.)

There is only a C++ API at the moment, and it will break and change on a
daily basis. This is version 0.0.0 :slight_smile:

I’m hoping to add a C API too in the future, which emulates SDL_mixer
(with some added functions) which would server as an API and ABI
compatible drop-in replacement for programs using SDL_mixer. (There’s a
bit of that already, but it’s mostly just stub functions; not really
useful yet.)

There’s no support yet for fade-in and fade-out. Seeking works fine
though (except for MIDI, which doesn’t support it.)

The only platform I’m using this at the moment is Linux. I have not even
considered other platforms yet. This will come later.

If you’re interested in this, it’s on GitHub:

https://github.com/realnc/SDL_audiolib

and the API documentation (always in flux, maybe some parts missing):

http://realnc.github.io/SDL_audiolib

The docs show a quick “hello world” program on the main page.

Cool. Don’t forget to include consistent error reporting (SDL returns
-1 or NULL for most errors). And add opus playback!On Tue, Jun 17, 2014 at 3:52 AM, Nikos Chantziaras wrote:

Hi folks.

I uploaded a very early version of an audio library I’ve been tinkering with
lately. I started it because I wanted something to replace SDL_mixer and
SDL_sound with. It’s LGPL licensed.

It only outputs mono and stereo right now. Hopefully we’ll get to 7.1
surround later on (for upmixing and playing surround sources.) This is a 2D
audio library though; there’s no intent to introduce 3D positioning of
sounds.

It uses three different resamplers: Speex (the Opus version), SoxR and SRC
(libsamplerate). The Speex one is integrated. The others need their
respective external libraries. Resampling only happens when the source
signal’s sample rate doesn’t match the output rate.

It does floating-point mixing of any amount of audio sources. I hope to add
some features like dithering and a limiter in the future, for the
audiophiles :slight_smile:

The audio sources come from decoders. The included decoders rely on
libvorbis, libmpg123, libsndfile, libmodplug and libfluidsynth to play many
different sound formats (Ogg/Vorbis, MP3, FLAC, MOD-based files, MIDI, WAV,
AIFF, etc.)

There is only a C++ API at the moment, and it will break and change on a
daily basis. This is version 0.0.0 :slight_smile:

I’m hoping to add a C API too in the future, which emulates SDL_mixer (with
some added functions) which would server as an API and ABI compatible
drop-in replacement for programs using SDL_mixer. (There’s a bit of that
already, but it’s mostly just stub functions; not really useful yet.)

There’s no support yet for fade-in and fade-out. Seeking works fine though
(except for MIDI, which doesn’t support it.)

The only platform I’m using this at the moment is Linux. I have not even
considered other platforms yet. This will come later.

If you’re interested in this, it’s on GitHub:

https://github.com/realnc/SDL_audiolib

and the API documentation (always in flux, maybe some parts missing):

http://realnc.github.io/SDL_audiolib

The docs show a quick “hello world” program on the main page.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I just added Opus support :slight_smile:

The error reporting is based on the more idiomatic C++ use of boolean
true vs false returns. Actual error strings will still need to be added
though.On 17/06/14 21:28, Daniel Holth wrote:

On Tue, Jun 17, 2014 at 3:52 AM, Nikos Chantziaras <@Nikos_Chantziaras> wrote:

I uploaded a very early version of an audio library I’ve been tinkering with
lately. I started it because I wanted something to replace SDL_mixer and
SDL_sound with. It’s LGPL licensed.
[…]

Cool. Don’t forget to include consistent error reporting (SDL returns
-1 or NULL for most errors). And add opus playback!

It’s 7 years later and we’re using it in DevilutionX because SDL_audiolib supports multiple streams (unlike SDL_mixer)