Audio latency

Hello :slight_smile:

How does one minimize the latency of the audio-stream
(in Windows) so much that it is possible to get instant / realtime
audio feedback in a game?

Setting the samples flag to 128 or 64 in the audio spec won’t
work. I saw some code in the Win* audiosys driver in the
SDL library which makes sure that samples are not
below freq / 4. I don’t know if this is the problem,
because the latency seems much larger than 1/4th of a second.

Is there perhaps some way of “force-feeding” the audio
device based on, say, the main loop in the application? (polling?)

Cheers–
val it = ("?NOQ of the Sun", “Johnny Andersen”,
[“anoq at vip.cybercity.dk”, “anoq at berlin-consortium.org”,
“anoq at diku.dk”], “http://users.cybercity.dk/~ccc25861/”)
: cyberspacename * meatspacename * email list * homepage URL

How does one minimize the latency of the audio-stream
(in Windows) so much that it is possible to get instant / realtime
audio feedback in a game?

Minimize the “desired->samples” value that you pass to SDL_OpenAudio().
512 seems to be a good value for low-latency applications.

Note that under NT, this value is rounded up to 1/4 of a second,
for various reasons.

Is there perhaps some way of “force-feeding” the audio
device based on, say, the main loop in the application? (polling?)

Nope. The callback is supposed to do it all. :slight_smile:

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

Sam Lantinga wrote:

Note that under NT, this value is rounded up to 1/4 of a second,
for various reasons.

This seems to be the problem. Why is it like this?

Cheers–
val it = ("?NOQ of the Sun", “Johnny Andersen”,
[“anoq at vip.cybercity.dk”, “anoq at berlin-consortium.org”,
“anoq at diku.dk”], “http://users.cybercity.dk/~ccc25861/”)
: cyberspacename * meatspacename * email list * homepage URL

Sam Lantinga wrote:

Note that under NT, this value is rounded up to 1/4 of a second,
for various reasons.

This seems to be the problem. Why is it like this?

On NT4, (up through service pack 3) the audio driver can’t handle more
than 1/4 second of sound. We round up to that to match as closely as
possible the real audio driver buffersize.

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/