[SDL] Re: SDL_Mixer sound effect problem causing my game to stutter

Rasmus Neckelmann neckelmann at gmail.com
Wed Nov 9 01:19:53 PST 2005


Alex Volkov writes:
> I can easily re-record the files, so what will I get the best performance out
> of? 22Khz, or 44.1Khz at 8 or 16 bit if I do this: Mix_OpenAudio(44100,
> AUDIO_S16SYS, 2, 2048)

Usually I think 16-bit, 22 kHz are enough for simple sound effects -
and the clear advantage  over 44 kHz is that it only occupies half the
space :)
Also I think it should be up to the user to decide what sound output
quality he want - and let it be up to underlying (SDL_mixer) layer to
bother with conversion and performance questions. Anyway, when it is
such simple conversions it shouldn't cause a performance impact.

> How would I go about doing something like this? I was thinking about doing
> something like making a vector of Mix_Chunk's, and then having a function that
> manually loaded each file into the vector.

If your game is very simple and you know beforehand exactly what sound
effects there's going to be in it, the simplest solution is to have an
array of Mix_Chunks, load them at initialization time, unload them
when quitting, and have a void PlaySoundEffect(int fx) function to
play the effects (with fx simply being an index into your chunk
array).

It's all very simple with SDL_mixer.

--
Rasmus Neckelmann




More information about the SDL mailing list