All of lore.kernel.org
 help / color / mirror / Atom feed
* user mode sequencer timer?
@ 2002-08-19  7:22 Tim Goetze
  2002-08-19 15:27 ` Takashi Iwai
  0 siblings, 1 reply; 7+ messages in thread
From: Tim Goetze @ 2002-08-19  7:22 UTC (permalink / raw)
  To: alsa-devel

Is it possible to register a sequencer client that acts as a timer
(not only an event consumer/producer), and if so, how would one go 
about implementing one?

tia,

tim




-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: user mode sequencer timer?
  2002-08-19  7:22 user mode sequencer timer? Tim Goetze
@ 2002-08-19 15:27 ` Takashi Iwai
  2002-08-19 15:42   ` Tim Goetze
  0 siblings, 1 reply; 7+ messages in thread
From: Takashi Iwai @ 2002-08-19 15:27 UTC (permalink / raw)
  To: Tim Goetze; +Cc: alsa-devel

At Mon, 19 Aug 2002 09:22:10 +0200 (CEST),
Tim Goetze wrote:
> 
> Is it possible to register a sequencer client that acts as a timer
> (not only an event consumer/producer), and if so, how would one go 
> about implementing one?

timer = event producer in a certain schedule, isn't it ??
it will deliver "tick" events in a programmed rythm.


Takashi


-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: user mode sequencer timer?
  2002-08-19 15:27 ` Takashi Iwai
@ 2002-08-19 15:42   ` Tim Goetze
  2002-08-19 16:42     ` Takashi Iwai
  0 siblings, 1 reply; 7+ messages in thread
From: Tim Goetze @ 2002-08-19 15:42 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

Takashi Iwai wrote:

>At Mon, 19 Aug 2002 09:22:10 +0200 (CEST),
>Tim Goetze wrote:
>> 
>> Is it possible to register a sequencer client that acts as a timer
>> (not only an event consumer/producer), and if so, how would one go 
>> about implementing one?
>
>timer = event producer in a certain schedule, isn't it ??
>it will deliver "tick" events in a programmed rythm.

You mean it is sufficient to emit SND_SEQ_EVENT_SETPOS_TICK or *_TIME 
periodically, and transport control events accordingly? Are these 
events then used by alsa-lib to update the queue timing information?

tim



-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: user mode sequencer timer?
  2002-08-19 15:42   ` Tim Goetze
@ 2002-08-19 16:42     ` Takashi Iwai
  2002-08-19 18:40       ` Tim Goetze
  0 siblings, 1 reply; 7+ messages in thread
From: Takashi Iwai @ 2002-08-19 16:42 UTC (permalink / raw)
  To: Tim Goetze; +Cc: alsa-devel

At Mon, 19 Aug 2002 17:42:07 +0200 (CEST),
Tim Goetze wrote:
> 
> Takashi Iwai wrote:
> 
> >At Mon, 19 Aug 2002 09:22:10 +0200 (CEST),
> >Tim Goetze wrote:
> >> 
> >> Is it possible to register a sequencer client that acts as a timer
> >> (not only an event consumer/producer), and if so, how would one go 
> >> about implementing one?
> >
> >timer = event producer in a certain schedule, isn't it ??
> >it will deliver "tick" events in a programmed rythm.
> 
> You mean it is sufficient to emit SND_SEQ_EVENT_SETPOS_TICK or *_TIME 
> periodically, and transport control events accordingly? Are these 
> events then used by alsa-lib to update the queue timing information?

well, sorry, then i misunderstood your question.

do you mean that a sequencer client as a timer source, or as a
controller of the queue?

the former is difficult, because the queue is driven by interrupts
from a timer source.  that is, a sequencer client must give signals at
the constant and fine period.  this is not a job what a user process
does.

the latter, controlling a queue, would be feasible.
in this case, you can change the tempo or time skew dynamically by
sending events via system-timer port (0:0) to a specified queue.
but anyway, a queue must run individually from the client.

maybe i can give more specific answer if i understand your question
more clearly...


ciao,

Takashi


-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: user mode sequencer timer?
  2002-08-19 16:42     ` Takashi Iwai
@ 2002-08-19 18:40       ` Tim Goetze
  2002-08-20 21:58         ` Frank van de Pol
  0 siblings, 1 reply; 7+ messages in thread
From: Tim Goetze @ 2002-08-19 18:40 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

Takashi Iwai wrote:

>At Mon, 19 Aug 2002 17:42:07 +0200 (CEST),
>Tim Goetze wrote:
>> 
>> Takashi Iwai wrote:
>> 
>> >At Mon, 19 Aug 2002 09:22:10 +0200 (CEST),
>> >Tim Goetze wrote:
>> >> 
>> >> Is it possible to register a sequencer client that acts as a timer
>> >> (not only an event consumer/producer), and if so, how would one go 
>> >> about implementing one?
>> >
>> >timer = event producer in a certain schedule, isn't it ??
>> >it will deliver "tick" events in a programmed rythm.
>> 
>> You mean it is sufficient to emit SND_SEQ_EVENT_SETPOS_TICK or *_TIME 
>> periodically, and transport control events accordingly? Are these 
>> events then used by alsa-lib to update the queue timing information?
>
>well, sorry, then i misunderstood your question.
>
>do you mean that a sequencer client as a timer source, or as a
>controller of the queue?
>
>the former is difficult, because the queue is driven by interrupts
>from a timer source.  that is, a sequencer client must give signals at
>the constant and fine period.  this is not a job what a user process
>does.
>
>the latter, controlling a queue, would be feasible.
>in this case, you can change the tempo or time skew dynamically by
>sending events via system-timer port (0:0) to a specified queue.
>but anyway, a queue must run individually from the client.
>
>maybe i can give more specific answer if i understand your question
>more clearly...

OK, here goes. I have a core here that processes MIDI and PCM. There's
a RTC thread that controls event timing, synced to the sample clock. 
So, internally, the application has a precise idea of the current 
tempo, tick, time and frame.

Currently, events sent to ALSA sequencer ports are sent via
snd_seq_event_output_direct(), with a 0 timestamp. 

Now what I'm looking for is a way to export this timer functionality
to the sequencer system, ie make it possible for other clients to
sync to this clock.

tim



-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: user mode sequencer timer?
  2002-08-19 18:40       ` Tim Goetze
@ 2002-08-20 21:58         ` Frank van de Pol
  2002-08-21 11:15           ` Tim Goetze
  0 siblings, 1 reply; 7+ messages in thread
From: Frank van de Pol @ 2002-08-20 21:58 UTC (permalink / raw)
  To: Tim Goetze; +Cc: Takashi Iwai, alsa-devel


On Mon, Aug 19, 2002 at 08:40:34PM +0200, Tim Goetze wrote:
> >
> >the former is difficult, because the queue is driven by interrupts
> >from a timer source.  that is, a sequencer client must give signals at
> >the constant and fine period.  this is not a job what a user process
> >does.

Just nitpicking: The monotonicy is not required. The only thing needed is
that the interval is known - so we can use dynamically variable clock
frequency :-)

> >
> >the latter, controlling a queue, would be feasible.
> >in this case, you can change the tempo or time skew dynamically by
> >sending events via system-timer port (0:0) to a specified queue.
> >but anyway, a queue must run individually from the client.
> >
> >maybe i can give more specific answer if i understand your question
> >more clearly...
> 
> OK, here goes. I have a core here that processes MIDI and PCM. There's
> a RTC thread that controls event timing, synced to the sample clock. 
> So, internally, the application has a precise idea of the current 
> tempo, tick, time and frame.
> 
> Currently, events sent to ALSA sequencer ports are sent via
> snd_seq_event_output_direct(), with a 0 timestamp. 
> 
> Now what I'm looking for is a way to export this timer functionality
> to the sequencer system, ie make it possible for other clients to
> sync to this clock.
> 
> tim
> 

If I understand you correctly you actually want to slave ALSA to your
application's timing source.

I see 2 options for it (please correct me if I'm wrong since i've been away
for too long):

- sync the timer using SND_SEQ_EVENT_SETPOS_TIME events (and optionally
  SND_SEQ_EVENT_QUEUE_SKEW). ALSA remains running it's own clock (system
  clock, rtc, external clock), following your internal clock.

- Use a PCM device as timing source (you'll need a reasonable small fragment
  size though).

- Add support for a userspace clock source eg. add some
  "SND_SEQ_EVENT_CLOCK_ADVANCE" which would trigger a timer callback (hence
  snd_seq_timer_interrupt()).


Cheers,
Frank.

-- 
+---- --- -- -  -   -    - 
| Frank van de Pol                  -o)    A-L-S-A
| FvdPol@home.nl                    /\\  Sounds good!
| http://www.alsa-project.org      _\_v
| Linux - Why use Windows if we have doors available?


-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: user mode sequencer timer?
  2002-08-20 21:58         ` Frank van de Pol
@ 2002-08-21 11:15           ` Tim Goetze
  0 siblings, 0 replies; 7+ messages in thread
From: Tim Goetze @ 2002-08-21 11:15 UTC (permalink / raw)
  To: Frank van de Pol; +Cc: Takashi Iwai, alsa-devel

Welkom terug, Frank!

>I see 2 options for it (please correct me if I'm wrong since i've been away
>for too long):
>
>- sync the timer using SND_SEQ_EVENT_SETPOS_TIME events (and optionally
>  SND_SEQ_EVENT_QUEUE_SKEW). ALSA remains running it's own clock (system
>  clock, rtc, external clock), following your internal clock.
>
>- Use a PCM device as timing source (you'll need a reasonable small fragment
>  size though).
>
>- Add support for a userspace clock source eg. add some
>  "SND_SEQ_EVENT_CLOCK_ADVANCE" which would trigger a timer callback (hence
>  snd_seq_timer_interrupt()).

? :) That's three options, unless a PCM device already is a possible
trigger for the main sequencer timer as per first option.

Anyway, my favourite would be the last option. It would also allow
us to implement the kind of predelay soft synths need without a big
fuzz: a clock-master client would only need to advance the clock 
ahead of time.

Groetjes, Tim




-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-08-21 11:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-19  7:22 user mode sequencer timer? Tim Goetze
2002-08-19 15:27 ` Takashi Iwai
2002-08-19 15:42   ` Tim Goetze
2002-08-19 16:42     ` Takashi Iwai
2002-08-19 18:40       ` Tim Goetze
2002-08-20 21:58         ` Frank van de Pol
2002-08-21 11:15           ` Tim Goetze

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.