Re: Compiling with VC++ 5.0

From: Thomas (noid@xs4all.nl)
Date: Thu Apr 06 2000 - 17:21:46 EDT


> Yes, it's just the dsound driver that glitches, I haven't had problems
> with file writing, or the Linux audio driver which worked a treat.
> Basically, the buffers are not being updated correctly, so there is
> always a discrepancy.

In sfront (using dsound), the buffer that is to be filled with audio data,
is first 'created' by directsound (the Lock function). The next time the
function is called (in which Lock is used), the buffer is unlocked and a new
buffer is locked. Only after the buffer is unlocked, it is actually sent to
the soundcard. This is not ideal, because this unlocking has to be done
right after the audio calculating is done and the buffer is filled.
To avoid glitches, audio buffers have to be filled earlier so that there are
(say) three buffers between writing to the buffer and sending it to the
soundcard. To decrease latency, the buffers have to be failry small ,maybe
256 or 512 samples (maybe smaller if possible)

I think the secondary write that is usually needed
> with a DS buffer is not being performed. The interface fucntions are not
> ideal from DirectSound's point of view, and probably a separate thread
> is needed to track DS buffer positions, as, from all that I have been
> told, NotifyPositions() is very unreliable.

Yes that's true, NotifyPosition is especially unreliable with small buffers.
Using a seperate thread is probably the only solution and the playposition
has to be checked by that thread (or yet another)..
I've built an application with dsound and the response is very fast and
glitch free, but in that app the priority is very high and three threads are
used. Since there are different kinds of computer systems(some faster than
others), the write position has to be set maunually. Only than can the audio
output be glitch free because latency is set according to the systems
hardware. It's even possible to build a 'smart' position checker, so the
write offset is increased in case of 'emergency'.

Thomas Jongepier

>



This archive was generated by hypermail 2b29 : Mon Jan 28 2002 - 11:46:38 EST