[SDL] playing audio fx

Ryan C. Gordon icculus at clutteredmind.org
Tue Jun 25 10:23:00 PDT 2002


> i have tried to things, both using SDL_CreateThread.

The audio callback itself will run in a separate thread, so there may be
no reason to spin one yourself.

> in the first version the sound gets significantly delayed, and the
> second versions takes long bbefore the next sound can be played.

Your audio buffer is probably too big; this is what's specified in the
"samples" field of the first SDL_AudioSpec you passed to SDL_OpenAudio().

Try lowering it, but not too low. My previous guidelines went something
like this:

  if (desired.freq <= 11025)
    desired.samples = 512;
  else if (desired.freq <= 22050)
    desired.samples = 1024;
  else if (desired.freq <= 44100)
    desired.samples = 2048;
  else
    desired.samples = 4096;  // (*shrug*)


Tweak to preference.

--ryan.







More information about the SDL mailing list