Re: [linux-audio-dev] timing

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] timing
From: Paul Davis (pbd_AT_op.net)
Date: Thu Jun 20 2002 - 16:33:12 EEST


>whats the best way to handle timing in a music app?
>
>im thinking that by a sequencer lib it would be possible to use that. is that
>a good idea or is it better to roll your own system.
>
>i have been looking at tracker code but havent got any solid ideas.
>
>could someone explain the principal?

  low level solutions:

        * system timer via SIGALRM or SIGITIMER or usleep(2)
        * real time clock via SIGIO - needs root or CAP_RESOURCE to do
            better than the system timer
        * use a timer deriving from some other regular
            interrupt source
                    
  higher level solutions:

        * use a library like TSE3
        * use the ALSA sequencer (not so useful for non-MIDI)
        * use the ALSA timer interface (i have no experience with this)

people differ on which of these solutions they prefer. in softwerk
(http://softwerk.sf.net/ - the web site is somewhat out of date) i use
either of the first two in the list above (chosen by the user). the
(somewhat) regular signal delivered from the system timer or the RTC
is used to indicate the passage of time; softwerk has its own notion
of how many usecs correspond to a single "tick", and how many "ticks"
there are per second.

the system timer resolution is 10ms. you can use it directly or
indirectly by calling poll(2) (or an equivalent for a GUI event loop)
with a timeout. this is the approach keykit uses - it polls for
keyboard/mouse events but returns early to handle the next "tick".

--p


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Thu Jun 20 2002 - 16:41:22 EEST