Subject: Re: [linux-audio-dev] best method for timing
From: Paul Davis (pbd_AT_Op.Net)
Date: Wed Apr 17 2002 - 16:13:09 EEST
>> if you're only doing sequencing, you can safely use the number of
>> interrupts reported to calculate the time passed. however i think
>> it's more flexible to use another means of getting the current time
>> and just use the rtc as a simple pulse generator like paul described.
>
>For a simple applications i just thought it would be conceptually simpler to w
>ork uniquely off the interrupt. I mean, say we missed an interrupt somehow (th
>ey got built up under load) and so missed an event we wanted to trigger, then
>theres not really much we can do about it anyways...
the number of interrupts is irrelevant if there is any notion of
"transport state". what matters is not what wall-clock time it is
right now, but what musical/audio time it is right now. to be able to
use any notion of "time", you need to be woken up regularly and
often. thats what the RTC and/or ALSA timer interface is for. unless
your sequencer has no concept of "we moved back to the start" or "jump
to the 40th bar", measuring time by counting RTC interrupts is just
irrelevant.
>> most platforms provide a microsecond-resolution in gettimeofday(2) by
>> evaluating the cycle counter if one is present[*]. this saves you
>> #including <asm/*.h> and other dirty code if you can afford to have
>> the small syscall overhead, and i think you can in a sequencer clock.
>
>Yes, i suppose the overhead for gettimeofday() is really a non-issue.
about 60 cycles on my system, versus rdtsc at about 12 cycles.
--p
This archive was generated by hypermail 2b28 : Wed Apr 17 2002 - 15:57:44 EEST