Mail Archives: djgpp/1999/11/29/14:06:58
Raul Kompass writes:
>>> for an experiment we have to compare the exact timing of a click
>>> that is presented by the soundcard with that of a keypress.
>>
>> This is inevitable on all the soundcards that Allegro supports,
>> and indeed on most PC sound hardware, because the cards work by
>> transferring blocks of samples by DMA
>
> So it should be possible to determine the voice position on the
> basis of the block used and on DMA information. _dma_todo() seems
> to be the right function here. Is that right? Unfortunately I don't
> understand how it works. Can _dma_todo() be used to improve the
> resolution of voice_get_position()?
In theory, although it would still be far from exact due to the
hardware FIFO. But in practice adding this to the Allegro code
would be hard verging on impossible, because there are too many
layers in between the hardware and the information that you are
interested in. These layers all do useful things (software mixing
of multiple sound channels, hardware device abstraction so that
different drivers can support different cards, etc), but each
layer adds another potential for losing this precise time control,
and makes it harder to filter the timing information back up to
the top levels. In this case the most awkward problem would be
that although _dma_todo() will indeed tell you how far the
hardware is through the current buffer transfer, you would then
need to backtrack this information to ask the sample mixing code
where in each sample this position refers to, and that requires
a detailed memory of what samples were mixed, at what frequencies,
etc, which information doesn't exist anywhere.
In other words, I really don't think that Allegro is the right way
to do this. It was designed to make sure the timing errors are small
enough not to be noticed by the average human being, but since it
would seem that you are trying to do experiments into exactly how
short a time that is, even the smallest timing error won't be good
enough for you. It would help if you could describe exactly what it
is that you are trying to do, but if my guess is right and you really
do need it to be exactly precise, the best way is probably to use the
PC speaker to produce a beep (using the libc sound() and nosound()
functions), or play notes on a MIDI system like the Adlib or AWE32
synths (using the Allegro midi_out() function).
Shawn Hargreaves.
- Raw text -