I’ve been using SDL_Mixer for quite a few months now and so far I
cannot get it to work properly. I can get good sound and music playing
but there is an unacceptable delay in playing the sounds. This delay
seems to be anywhere from 0.5 secs to 1 sec. This won’t do for things
like pressing interface buttons or creatures attacking.
I can’t understand why there should be a delay in playing a sound. To
me it should just play immediately.
Wow… If it was that easy, I’d still be using WinNT. Audio latency was
the single most important reason why I gave up on Windows - and MS still
don’t have an acceptable solution.
Anyway, there’s no way a “standard” OS will provide “instant” response of
any form, at least not in a remotely reliable fashion. You need real time
scheduling for that, and the only such OS that may eventually support
that would be future Linux versions (2.5+). (Some claim that BeOS can
too, but where are the figures…?)
The best you can do in this case is using memory mapped audio IO, and
"mix over + mix ahead". Quite hairy, doesn’t prevent occasional glitches
in the beginning of sounds, and doesn’t work too well with “global” DSP
effects, like reverb. It seems to be quite sufficient for games, though.
Problem is that SDL doesn’t support this method, and as a result, nor
does SDL_mixer. (At least DirectX, ALSA and OSS do support it, though, so
there is hope.)
I have tried different values using Mix_OpenAudio but I can’t get an
acceptable result. If the buffer size is below 8192 the sounds and
music start to stutter. I’ve tried this on a Win 95 P200 and a Win 2000
P1.5 Gig machine and I get the same result.
You would find that even on standard Linux, buffer sizes in the range of
hundreds of samples will work just fine. I’m not sure why Windows sucks
this bad in this respect - I can only conclude it does, on every single
version and machine I’ve tested it on. It seems that Windows simply
refuses to schedule threads frequently enough for smaller buffers.
When I run the examples supplied with SDL_Mixer I get the same problems
so it doesn’t seem to be a problem with my code.
Same problem with Kobo Deluxe, any version. (The latest versions could
be worse though, as they need more CPU time. Haven’t tested thoroughly
yet.)
Has anyone managed to get past this or is SDL_Mixer not suitable for
PCs?
It’s not SDL_Mixer’s fault. It’s just Windows that cannot deliver
acceptable latency without “dirty” hacks. (There’s a reason why the few
reasonably low latency soft synths there are for Windows are rather
expensive and surrounded by lots of hush-hush and/or patents.)
Maybe there are some tricks you could try to improve performance slightly
on Win32, but as I’ve said, I’ve given up on in. Using the “shared memory
method” is the best advice I can give you regarding Win32.
//David Olofson — Programmer, Reologica Instruments AB
.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |
-------------------------------------> http://olofson.net -'On Thursday 25 April 2002 02:00, David Moffatt wrote: