All of lore.kernel.org
 help / color / mirror / Atom feed
* Simple alsa sequencer question
@ 2003-10-25  9:41 Ryan Pavlik
  2003-10-27 10:54 ` Takashi Iwai
  2003-10-27 12:14 ` Clemens Ladisch
  0 siblings, 2 replies; 8+ messages in thread
From: Ryan Pavlik @ 2003-10-25  9:41 UTC (permalink / raw)
  To: alsa-devel

Minor question... I probably just overlooked something...
but when I subscribe to a port, and I've done this:

        :
    snd_seq_port_subscribe_set_queue(subs, 1);
    snd_seq_port_subscribe_set_time_update(subs, 1);
    snd_seq_port_subscribe_set_time_real(subs, 1);
        :

Shouldn't I get numbers in ev->time.time.tv_*?  I'm just getting
zeros... what did I miss? ;)

-- 
Ryan Pavlik <rpav@mephle.com>

"I was promised claws and an impossible biology!" - 8BT


-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/

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

* Re: Simple alsa sequencer question
  2003-10-25  9:41 Simple alsa sequencer question Ryan Pavlik
@ 2003-10-27 10:54 ` Takashi Iwai
  2003-10-28  0:59   ` Ryan Pavlik
  2003-10-27 12:14 ` Clemens Ladisch
  1 sibling, 1 reply; 8+ messages in thread
From: Takashi Iwai @ 2003-10-27 10:54 UTC (permalink / raw)
  To: Ryan Pavlik; +Cc: alsa-devel

At Sat, 25 Oct 2003 02:41:06 -0700,
Ryan Pavlik wrote:
> 
> Minor question... I probably just overlooked something...
> but when I subscribe to a port, and I've done this:
> 
>         :
>     snd_seq_port_subscribe_set_queue(subs, 1);
>     snd_seq_port_subscribe_set_time_update(subs, 1);
>     snd_seq_port_subscribe_set_time_real(subs, 1);
>         :
> 
> Shouldn't I get numbers in ev->time.time.tv_*?  I'm just getting
> zeros... what did I miss? ;)

no, it should be, as long as the event is delivered to these
subscribers (i.e. setting the destination as SND_SEQ_ADDR_SUBSCRIBERS).

btw, to update the timestamp of every event to a certain port, you can
set the timestamp attribute on the port_info, too.


Takashi


-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/

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

* Re: Simple alsa sequencer question
  2003-10-25  9:41 Simple alsa sequencer question Ryan Pavlik
  2003-10-27 10:54 ` Takashi Iwai
@ 2003-10-27 12:14 ` Clemens Ladisch
  1 sibling, 0 replies; 8+ messages in thread
From: Clemens Ladisch @ 2003-10-27 12:14 UTC (permalink / raw)
  To: Ryan Pavlik; +Cc: alsa-devel

Ryan Pavlik wrote:
> but when I subscribe to a port, and I've done this:
>         :
>     snd_seq_port_subscribe_set_queue(subs, 1);
>     snd_seq_port_subscribe_set_time_update(subs, 1);
>     snd_seq_port_subscribe_set_time_real(subs, 1);
>         :
> Shouldn't I get numbers in ev->time.time.tv_*?  I'm just getting
> zeros... what did I miss? ;)

The second parameter of ..._set_queue is the id of the queue to get
the time from. Probably queue #1 doesn't exist, or isn't running when
the events get delivered.


HTH
Clemens




-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/

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

* Re: Simple alsa sequencer question
  2003-10-27 10:54 ` Takashi Iwai
@ 2003-10-28  0:59   ` Ryan Pavlik
  2003-10-28  9:23     ` Clemens Ladisch
  0 siblings, 1 reply; 8+ messages in thread
From: Ryan Pavlik @ 2003-10-28  0:59 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 1436 bytes --]

On Mon, 27 Oct 2003 11:54:21 +0100
Takashi Iwai <tiwai@suse.de> wrote:

> At Sat, 25 Oct 2003 02:41:06 -0700,
> Ryan Pavlik wrote:
<snip>
> > Shouldn't I get numbers in ev->time.time.tv_*?  I'm just getting
> > zeros... what did I miss? ;)
> 
> no, it should be, as long as the event is delivered to these
> subscribers (i.e. setting the destination as SND_SEQ_ADDR_SUBSCRIBERS).
> 
> btw, to update the timestamp of every event to a certain port, you can
> set the timestamp attribute on the port_info, too.

OK, I've attached some code to show what I'm doing exactly.

I'm trying to receive input from an external sequencer that's tagged
with the event arrival time.  The docs indicate this should be no
problem, and I believe I've done what they say, but I'm obviously not
doing something right. :-)

I prefer time in realtime, not midi time, for accuracy and time
calculation reasons, but neither seems to work.

Also, I seem to be getting a lot of type 42 messages (active sense).
Now, only one piece of gear (Roland, go figure ;) generates these, and
the MTP/AV i'm using blocks them (thankfully).  The Roland gear is
off, and the MTP/AV shows no input traffic.  Why am I still getting
these messages...?  (For my ruby lib, i'm filtering them at the moment
since they're the useless, but saving a little CPU would be nice,
too.)

Thanks,

-- 
Ryan Pavlik <rpav@mephle.com>

"I believe in exploiting debts, not having them." - 8BT

[-- Attachment #2: test.c --]
[-- Type: application/octet-stream, Size: 1602 bytes --]

#include <alsa/asoundlib.h>

#define CLIENT 72
#define PORT    0

void subscribe_to(snd_seq_t *seq, int port, int client, int c_port);

int main() {
    snd_seq_t       *seq;
    int              port;
    snd_seq_event_t *ev;

    /* Open the sequencer */
    snd_seq_open(&seq, "default", SND_SEQ_OPEN_INPUT, 0);
    snd_seq_set_client_name(seq, "test");

    /* Our port */
    port = snd_seq_create_simple_port(seq, "test port",
                                      SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE,
                                      SND_SEQ_PORT_TYPE_MIDI_GENERIC|SND_SEQ_PORT_TYPE_APPLICATION);


    subscribe_to(seq, port, CLIENT, PORT);

    for(;;) {
        snd_seq_event_input(seq, &ev);
        printf("Type: %d Time: %d %d\n", ev->type, ev->time.time.tv_sec,
               ev->time.time.tv_nsec);
        /* This prints 0 0 ... what do I do to receive time? */
    }
}

void subscribe_to(snd_seq_t *seq, int port, int client, int c_port) {
    snd_seq_addr_t sender, dest;
    snd_seq_port_subscribe_t *subs;
    int queue;
    snd_seq_event_t ev;

    sender.client = client;
    sender.port   = c_port;
    dest.client   = snd_seq_client_id(seq);
    dest.port     = port;
    queue         = snd_seq_alloc_queue(seq);

    snd_seq_port_subscribe_alloca(&subs);
    snd_seq_port_subscribe_set_sender(subs, &sender);
    snd_seq_port_subscribe_set_dest(subs, &dest);
    snd_seq_port_subscribe_set_queue(subs, queue);
    snd_seq_port_subscribe_set_time_update(subs, 1);
    snd_seq_port_subscribe_set_time_real(subs, 1);
    snd_seq_subscribe_port(seq, subs);
}

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

* Re: Simple alsa sequencer question
  2003-10-28  0:59   ` Ryan Pavlik
@ 2003-10-28  9:23     ` Clemens Ladisch
  2003-10-28 16:29       ` Ryan Pavlik
  0 siblings, 1 reply; 8+ messages in thread
From: Clemens Ladisch @ 2003-10-28  9:23 UTC (permalink / raw)
  To: Ryan Pavlik; +Cc: Takashi Iwai, alsa-devel

Ryan Pavlik wrote:
> Takashi Iwai <tiwai@suse.de> wrote:
>
> > Ryan Pavlik wrote:
> > > Shouldn't I get numbers in ev->time.time.tv_*?  I'm just getting
> > > zeros... what did I miss? ;)
> >
> > (snip)
>
> OK, I've attached some code to show what I'm doing exactly.

The event timestamps are set yo the current time of the queue. Your
queue isn't running, so its current time is zero.

Call snd_seq_start_queue(seq, queue, NULL) (and snd_seq_drain_output).


HTH
Clemens




-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/

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

* Re: Simple alsa sequencer question
  2003-10-28  9:23     ` Clemens Ladisch
@ 2003-10-28 16:29       ` Ryan Pavlik
  0 siblings, 0 replies; 8+ messages in thread
From: Ryan Pavlik @ 2003-10-28 16:29 UTC (permalink / raw)
  To: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 870 bytes --]

On Tue, 28 Oct 2003 10:23:40 +0100 (MET)
Clemens Ladisch <clemens@ladisch.de> wrote:

> Ryan Pavlik wrote:
> > Takashi Iwai <tiwai@suse.de> wrote:
> >
> > > Ryan Pavlik wrote:
> > > > Shouldn't I get numbers in ev->time.time.tv_*?  I'm just getting
> > > > zeros... what did I miss? ;)
> > >
> > > (snip)
> >
> > OK, I've attached some code to show what I'm doing exactly.
> 
> The event timestamps are set yo the current time of the queue. Your
> queue isn't running, so its current time is zero.
> 
> Call snd_seq_start_queue(seq, queue, NULL) (and snd_seq_drain_output).

Hmm, nope... I've tried this in various combinations along with
tempo-setting and position-setting events sent to the queue, with no
avail.  I'm still getting 0 0.

I've attached the new code.

thanks,

-- 
Ryan Pavlik <rpav@mephle.com>

"Maybe it's the unfocused, blind, murderous rage." - 8BT

[-- Attachment #2: test.c --]
[-- Type: application/octet-stream, Size: 3986 bytes --]

#include <alsa/asoundlib.h>

#define CLIENT 72
#define PORT    0

void subscribe_to(snd_seq_t *seq, int port, int client, int c_port);
void start_queue(snd_seq_t *seq, int client, int port, int q);
void set_queue_tempo(snd_seq_t *seq, int client, int port, int q,
                     unsigned int tempo);
void set_queue_position(snd_seq_t *seq, int client, int port, int q,
                        unsigned int position);

int main() {
    snd_seq_t       *seq;
    int              port, p_timer;
    snd_seq_event_t *ev;

    /* Open the sequencer */
    snd_seq_open(&seq, "default", SND_SEQ_OPEN_INPUT, 0);
    snd_seq_set_client_name(seq, "test");

    /* Our port */
    port = snd_seq_create_simple_port(seq, "test port",
                                      SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE,
                                      SND_SEQ_PORT_TYPE_APPLICATION);


    /* Thought this might be something... but it's not */
    //snd_seq_connect_to(seq, port, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_TIMER);
    //subscribe_to(seq, port, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_TIMER);

    subscribe_to(seq, port, CLIENT, PORT);

    for(;;) {
        snd_seq_event_input(seq, &ev);
        printf("Type: %d Time: %d %d\n", ev->type, ev->time.time.tv_sec,
               ev->time.time.tv_nsec);
        /* This prints 0 0 ... what do I do to receive time? */
    }
}

void subscribe_to(snd_seq_t *seq, int port, int client, int c_port) {
    snd_seq_addr_t sender, dest;
    snd_seq_port_subscribe_t *subs;
    int id, queue;
    snd_seq_event_t ev;

    id            = snd_seq_client_id(seq);
    sender.client = client;
    sender.port   = c_port;
    dest.client   = id;
    dest.port     = port;
    queue         = snd_seq_alloc_queue(seq);

    snd_seq_port_subscribe_alloca(&subs);
    snd_seq_port_subscribe_set_sender(subs, &sender);
    snd_seq_port_subscribe_set_dest(subs, &dest);
    snd_seq_port_subscribe_set_queue(subs, queue);
    snd_seq_port_subscribe_set_time_update(subs, 1);
    snd_seq_port_subscribe_set_time_real(subs, 1);
    snd_seq_subscribe_port(seq, subs);

    /* Uncommenting these seems to have no visible effect either */
    //set_queue_tempo(seq, id, port, queue, 10000);
    //set_queue_position(seq, id, port, queue, 5);
    //start_queue(seq, id, port, queue);
    
    snd_seq_start_queue(seq, queue, NULL);
    snd_seq_drain_output(seq);
}

void start_queue(snd_seq_t *seq, int client, int port, int q) {
    snd_seq_event_t ev;
    snd_seq_ev_clear(&ev);
    ev.type = SND_SEQ_EVENT_START;
    ev.dest.client = SND_SEQ_CLIENT_SYSTEM;
    ev.dest.port = SND_SEQ_PORT_SYSTEM_TIMER;
    ev.source.client = client;
    ev.source.port = port;
    ev.queue = SND_SEQ_QUEUE_DIRECT; // no scheduling
    ev.data.queue.queue = q;	// affected queue id
    snd_seq_event_output(seq, &ev);    
}


void set_queue_tempo(snd_seq_t *seq, int client, int port, int q,
                     unsigned int tempo) {
    snd_seq_event_t ev;
    snd_seq_ev_clear(&ev);
    ev.type = SND_SEQ_EVENT_TEMPO;
    ev.dest.client = SND_SEQ_CLIENT_SYSTEM;
    ev.dest.port = SND_SEQ_PORT_SYSTEM_TIMER;
    ev.source.client = client;
    ev.source.port = port;
    ev.queue = SND_SEQ_QUEUE_DIRECT; // no scheduling
    ev.data.queue.queue = q;	// affected queue id
    ev.data.queue.param.value = tempo;	// new tempo in microsec.
    snd_seq_event_output(seq, &ev);    
}

void set_queue_position(snd_seq_t *seq, int client, int port, int q,
                        unsigned int position) {
    snd_seq_event_t ev;
    snd_seq_ev_clear(&ev);
    ev.type = SND_SEQ_EVENT_TEMPO;
    ev.dest.client = SND_SEQ_CLIENT_SYSTEM;
    ev.dest.port = SND_SEQ_PORT_SYSTEM_TIMER;
    ev.source.client = client;
    ev.source.port = port;
    ev.queue = SND_SEQ_QUEUE_DIRECT; // no scheduling
    ev.data.queue.queue = q;	// affected queue id
    ev.data.queue.param.position = position;	// new tempo in microsec.
    snd_seq_event_output(seq, &ev);    
}

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

* Re: Simple alsa sequencer question
  2003-10-28 19:20 ` Pedro Lopez-Cabanillas
@ 2003-10-28 20:52   ` Ryan Pavlik
  0 siblings, 0 replies; 8+ messages in thread
From: Ryan Pavlik @ 2003-10-28 20:52 UTC (permalink / raw)
  To: Pedro Lopez-Cabanillas; +Cc: alsa-devel

On Tue, 28 Oct 2003 20:20:40 +0100
Pedro Lopez-Cabanillas <plcl@telefonica.net> wrote:

> El Martes, 28 de Octubre de 2003 17:30, Ryan Pavlik escribió:
> > Clemens Ladisch <clemens@ladisch.de> wrote:
> > > The event timestamps are set yo the current time of the queue. Your
> > > queue isn't running, so its current time is zero.
> > >
> > > Call snd_seq_start_queue(seq, queue, NULL) (and snd_seq_drain_output).
> >
> > Hmm, nope... I've tried this in various combinations along with
> > tempo-setting and position-setting events sent to the queue, with no
> > avail.  I'm still getting 0 0.
> 
> Try:
> 	snd_seq_open(&seq, "default", SND_SEQ_OPEN_DUPLEX, 0);
> 
> Opening with SND_SEQ_OPEN_INPUT, any call to snd_seq_start_queue will return a 
> -22 error code.

YES!  Thank you! :-)  Now, why didn't I try that.  Both of these
combined did the trick.

Anyhow, thanks a ton, solved a very nagging problem.  My ruby-alsa
module should soon have a useful sequencer. ;-)

ttyl,

-- 
Ryan Pavlik <rpav@mephle.com>

"Maybe it's the unfocused, blind, murderous rage." - 8BT


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/

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

* Re: Simple alsa sequencer question
       [not found] <E1AEWlF-0005EN-00@sc8-sf-list2.sourceforge.net>
@ 2003-10-28 19:20 ` Pedro Lopez-Cabanillas
  2003-10-28 20:52   ` Ryan Pavlik
  0 siblings, 1 reply; 8+ messages in thread
From: Pedro Lopez-Cabanillas @ 2003-10-28 19:20 UTC (permalink / raw)
  To: alsa-devel; +Cc: Ryan Pavlik

El Martes, 28 de Octubre de 2003 17:30, Ryan Pavlik escribió:
> Clemens Ladisch <clemens@ladisch.de> wrote:
> > The event timestamps are set yo the current time of the queue. Your
> > queue isn't running, so its current time is zero.
> >
> > Call snd_seq_start_queue(seq, queue, NULL) (and snd_seq_drain_output).
>
> Hmm, nope... I've tried this in various combinations along with
> tempo-setting and position-setting events sent to the queue, with no
> avail.  I'm still getting 0 0.

Try:
	snd_seq_open(&seq, "default", SND_SEQ_OPEN_DUPLEX, 0);

Opening with SND_SEQ_OPEN_INPUT, any call to snd_seq_start_queue will return a 
-22 error code.

Regards,
Pedro

-- 
ALSA Library Bindings for Pascal
http://alsapas.alturl.com



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/

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

end of thread, other threads:[~2003-10-28 20:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-25  9:41 Simple alsa sequencer question Ryan Pavlik
2003-10-27 10:54 ` Takashi Iwai
2003-10-28  0:59   ` Ryan Pavlik
2003-10-28  9:23     ` Clemens Ladisch
2003-10-28 16:29       ` Ryan Pavlik
2003-10-27 12:14 ` Clemens Ladisch
     [not found] <E1AEWlF-0005EN-00@sc8-sf-list2.sourceforge.net>
2003-10-28 19:20 ` Pedro Lopez-Cabanillas
2003-10-28 20:52   ` Ryan Pavlik

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.