I have been using SDL_Mixer for some time now, and I’m quite impressed
with it’s simplicity and stability. The one problem I have with it, is
it’s just one huge black box while in use; if I want to add filters,
visualizations etc. I either have to jam them into the callback or
rewrite the library entirely. So for those who want a more complex and
versatile system, I propose SDL_AudioWidgets.
My idea is a C++ “component-model” sound system for SDL, using 3 kinds
of objects: sources, drains, and links. A source can be a WAV file,
MikMod, etc. A drain can be a sound card, an .ogg saver, etc. Links
are custom filters and/or mixers that are placed between the source and
the drain. It works in a linked-list or tree fashion, where the drain
calls the next object in line, be it a source or a link to a source or
sources. If the drain isn’t driven by a callback, something has to
drive it externally.
They work through the passing of AudioChunks, which contain info about
the # of channels, bits per sample, # of samples etc. and a pointer to
raw data. Some of these packets are dynamically allocated and need to
be deleted when used, others not; the readOnly flag keeps track of
this.
I’ve managed to encapsulate SDL’s sound output and Vorbis’ VorbisFile
decoder into a drain object and a source object, and it works. Next,
MikMod, then maybye some reverb filters. Any thoughts?