All of lore.kernel.org
 help / color / mirror / Atom feed
* incoming sequencer event timestamping (via a running queue): how?
@ 2011-04-11 18:01 R. Dresens
  2011-04-11 20:10 ` r10kindsofpeople
  0 siblings, 1 reply; 4+ messages in thread
From: R. Dresens @ 2011-04-11 18:01 UTC (permalink / raw)
  To: alsa-devel


Hello,

I'm attempting to write a program that lets me record (and play)
MIDI sequences,

I have created a sequencer queue (with `snd_seq_alloc_queue`), and
when I set it up and let it run I can observe that the tick value
properly increases (with `snd_seq_queue_status_get_tick_time`);
everything runs fine. Queing events to an output work as well.

But is it somehow possible to bind "incoming events" to this queue as
well? (...in such a way that the `event->time.tick` value of these
incoming events is used to automatically store the queue timer value
at reception? ...)

At this moment, I just sample the tick value manually when I get an
event. That kinda works, but chances are high that the kernel
sequencer system can do that for me with more accuracy?

I wrote a function that essentially reconnects the inputs of the port
used for reception just before the queue is started. This allows me
to set the queue explicitly. I also enable
`snd_seq_port_subscribe_set_time_update`. It doesnt't work (yet).

Should this work? Am I on the right track? Or am I missing something?

Can anyone give me a hint?

Thanks!

Greetings,

Raymond.

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

* Re: incoming sequencer event timestamping (via a running queue): how?
  2011-04-11 18:01 incoming sequencer event timestamping (via a running queue): how? R. Dresens
@ 2011-04-11 20:10 ` r10kindsofpeople
  2011-04-12  5:49   ` Clemens Ladisch
  0 siblings, 1 reply; 4+ messages in thread
From: r10kindsofpeople @ 2011-04-11 20:10 UTC (permalink / raw)
  To: alsa-devel

On Mon, Apr 11, 2011 at 2:01 PM, R. Dresens <chromisx@nedlinux.nl> wrote:
>
> Hello,
>
> I'm attempting to write a program that lets me record (and play)
> MIDI sequences,
>
> I have created a sequencer queue (with `snd_seq_alloc_queue`), and
> when I set it up and let it run I can observe that the tick value
> properly increases (with `snd_seq_queue_status_get_tick_time`);
> everything runs fine. Queing events to an output work as well.
>
> But is it somehow possible to bind "incoming events" to this queue as
> well? (...in such a way that the `event->time.tick` value of these
> incoming events is used to automatically store the queue timer value
> at reception? ...)
>
> At this moment, I just sample the tick value manually when I get an
> event. That kinda works, but chances are high that the kernel
> sequencer system can do that for me with more accuracy?
>
> I wrote a function that essentially reconnects the inputs of the port
> used for reception just before the queue is started. This allows me
> to set the queue explicitly. I also enable
> `snd_seq_port_subscribe_set_time_update`. It doesnt't work (yet).
>
> Should this work? Am I on the right track? Or am I missing something?
>
> Can anyone give me a hint?
>
> Thanks!
>
> Greetings,
>
> Raymond.
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>

In your function that does the connection to the reception port...
snd_seq_port_subscribe_set_queue(subs, queue_id);  //<< queue_id being
the one you allocated
snd_seq_port_subscribe_set_time_update(subs, 1);
snd_seq_port_subscribe_set_time_real(subs, 0);
snd_seq_subscribe_port(pSeq, subs);

...with the caution that this may be the completely wrong way to go
about this, but it may help until someone more knowledgeable comes
along...

John

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

* Re: incoming sequencer event timestamping (via a running queue): how?
  2011-04-11 20:10 ` r10kindsofpeople
@ 2011-04-12  5:49   ` Clemens Ladisch
  2011-04-12  7:05     ` R. Dresens
  0 siblings, 1 reply; 4+ messages in thread
From: Clemens Ladisch @ 2011-04-12  5:49 UTC (permalink / raw)
  To: R. Dresens, r10kindsofpeople; +Cc: alsa-devel

r10kindsofpeople wrote:
> On Mon, Apr 11, 2011 at 2:01 PM, R. Dresens <chromisx@nedlinux.nl> wrote:
> > At this moment, I just sample the tick value manually when I get an
> > event. That kinda works, but chances are high that the kernel
> > sequencer system can do that for me with more accuracy?
> 
> In your function that does the connection to the reception port...
> snd_seq_port_subscribe_set_queue(subs, queue_id);  //<< queue_id being the one you allocated
> snd_seq_port_subscribe_set_time_update(subs, 1);
> snd_seq_subscribe_port(pSeq, subs);

This is the correct way to get timestamps on events that go through
a subscription.

Alternatively, you can get timestamps on events that arrive at a port:
  snd_seq_port_info_set_timestamping(pinfo, 1);
  snd_seq_port_info_set_timestamp_queue(pinfo, queue);
  snd_seq_create_port(pSeq, pinfo);


Regards,
Clemens

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

* Re: incoming sequencer event timestamping (via a running queue): how?
  2011-04-12  5:49   ` Clemens Ladisch
@ 2011-04-12  7:05     ` R. Dresens
  0 siblings, 0 replies; 4+ messages in thread
From: R. Dresens @ 2011-04-12  7:05 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel, r10kindsofpeople

On Tue, 12 Apr 2011 07:49:26 +0200
Clemens Ladisch <clemens@ladisch.de> wrote:

> r10kindsofpeople wrote:

> > In your function that does the connection to the reception port...
> > snd_seq_port_subscribe_set_queue(subs, queue_id);  //<< queue_id..
> > snd_seq_port_subscribe_set_time_update(subs, 1);
> > snd_seq_subscribe_port(pSeq, subs);
 
> This is the correct way to get timestamps on events that go through
> a subscription.
 
> Alternatively, you can get timestamps on events that arrive at a
> port:

>   snd_seq_port_info_set_timestamping(pinfo, 1);
>   snd_seq_port_info_set_timestamp_queue(pinfo, queue);
>   snd_seq_create_port(pSeq, pinfo);

Hello,

I have both solutions working now,

Setting the port_info seems (to me) the easiest solution,

Working with port subscriptions was a nice exercize though... ;)

Thanks!

Greetings,

Raymond.

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

end of thread, other threads:[~2011-04-12  7:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-11 18:01 incoming sequencer event timestamping (via a running queue): how? R. Dresens
2011-04-11 20:10 ` r10kindsofpeople
2011-04-12  5:49   ` Clemens Ladisch
2011-04-12  7:05     ` R. Dresens

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.