All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ryan Pavlik <rpav@mephle.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: Simple alsa sequencer question
Date: Mon, 27 Oct 2003 16:59:33 -0800	[thread overview]
Message-ID: <20031027165933.2307acfe.rpav@mephle.com> (raw)
In-Reply-To: <s5hismb6jdu.wl@alsa2.suse.de>

[-- 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);
}

  reply	other threads:[~2003-10-28  0:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031027165933.2307acfe.rpav@mephle.com \
    --to=rpav@mephle.com \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.