SDL_Sound (improvements?) (fwd)

Ryan C. Gordon icculus at
Thu Apr 4 08:42:36 EST 2002

I haven't looked at the code at all, yet, but here's something that was
sent to me.


---------- Forwarded message ----------
Date: 30 Mar 2002 20:40:59 +0100
From: Matej Knopp <knopp at>
To: Ryan C. Gordon <icculus at>
Subject: SDL_Sound (improvements?)


Some time ago I wrote you about a bug in SDL_Sound 0.1.4 (As far as I
remember) and asked you whether you were planning to add support for
custom loaders. Your answer was negative and I needed some layer
similiar to SDL_Sound with support for custom loaders and slightly
different design (mostly concerning the difference between streamed and
not streamed samples). This has lead me to writing it on my own (I know
that the code duplicating is not a good thing to do). It wasn't meant to
be another library I just wanted to make it a part of my wrapper (SEL).
The problem is that I've no time to finish the release. The code has
been lying on my hdd for some time without doing any good so I decided
to bother you a bit sending you the code (LGPL) to look whether it
(perhaps) does contain something usefull for SDL_Sound.

Last release of SDL_Sound I've seen was ~ 0.1.5 so some notes below may
be inacurrate.

The design of Sound Interface (SI) differs from SDL_Sound a bit. It has
support for adding user loaders and changing the priority of loaders, so
you can for example give the ModPlug loader higher prority than the
MikMod loader and automatically play all the modules with ModPlug. Also
there is a difference between streamable sounds (music) and "one shot"
samples. SI also support parameters for loaders, so for instance you can
set the audio format for the raw files (see loader-raw.c) or maybe the
flags for modules. (The loader for modules does not exist yet and
probably it will never exist, because of the lack of time)

Now what the files contain:

gem-list.[ch] - The double linked list similiar to the one from GLib.
              - Perhaps the copyright of glib should be added?
loader-raw.c  - The RAW file loader.
loader-wav.c  - The WAVE file loader. Supports _both_ MS ADPCM and
                IMA_ADPMC. It's in fact your wave loader cleaned,
                extended and optimized. AFAIK in SDL_Sound 0.1.5 you
                were loading the MS ADPCM wavs byte by byte and that
                was slower than playing MP3's on some computers.
                This loader buffers the MS ADPCM blocks.
si-audiocvt.c - Fixed SDL Audio Converter. I've contacted Sam Lantinga
                describing him the bug in SDL Audio C. concerning
                the incorrect order of conversions and bug in 16 bit
                mono -> stereo conversion...
si-config.h   - The config file that duplicates some SDL features when
                SDL is not used (The SI is supposed to work even without
                SDL) It also contains a primitive memory tracking
                facilities. (To assure that there are no leaks in SI :)
si.h          - The main public header.
si-internal.h - The public header for creating user loaders.
si-main.c     - The SI core implementation.

That should be all. Maybe you will find something usefull in SI for


-Matej Knopp

P.S. The speed of ADPCM decoding:
I've tested the ADPCM decoding and compared it Microsoft MediaPlayer and
the (innacurate) results are that on DURON 850 SI is faster than
Mplayer, but on Pentium 233 MMX the Mplayer is almost twice (5% compared
to 8% - 9% of the cpu usage) that fast than SI. Do you know about any
other possible optimizations ?  (Except rewriting it in assembly :)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: sound.tar.gz
Type: application/x-gzip
Size: 18552 bytes
URL: <>

More information about the sdlsound mailing list