[linux-audio-dev] Re: How to use the alsa sequencer?

Stephen Cameron smcameron at yahoo.com
Sat Jun 17 17:19:48 UTC 2006


--- Stephen Cameron <smcameron at yahoo.com> wrote:
> 
> Hi,
> 
> I'm trying to figure out how to use the ALSA sequencer 
> with my app.  (to date, I've been just using raw midi).

Some progress...

This code seems to work... it relies on explicitly setting
the destination client id to 128... where I happen to know
the fluidsynth happens to be sitting.

void midi_noteon_alsa(struct midi_handle *mh,
        unsigned char channel,
        unsigned char value,
        unsigned char volume)
{
        struct midi_handle_alsa *mha = (struct midi_handle_alsa *) mh;
        snd_seq_event_t ev;
        struct snd_seq_real_time tstamp;
        int rc;

        memset(&tstamp, 0, sizeof(tstamp));
        snd_seq_ev_clear(&ev);
        snd_seq_ev_set_source(&ev, mha->outputport);
        snd_seq_ev_set_subs(&ev);
        snd_seq_ev_set_dest(&ev, 128, 0); /* <---- magically makes it work */
        /* snd_seq_ev_set_direct(&ev);
        snd_seq_ev_set_dest(&ev, SND_SEQ_EVENT_PORT_SUBSCRIBED, 0); */

        snd_seq_ev_set_noteon(&ev, channel, value, volume);
        /* ev.data.note.duration = 1000; */ /* it's drums... there is no note off. */

        snd_seq_ev_schedule_real(&ev, mha->queue, 1, &tstamp);
        /* printf("Sending event to port %d, chan=%d, note=%d, vel=%d, pid=%d\n",
                mha->outputport, ev.data.note.channel,
                ev.data.note.note, ev.data.note.velocity, getpid()); */
        rc = snd_seq_event_output(mha->seqp, &ev);
        if (rc < 0)
                printf("Failed to output note.\n");
        snd_seq_drain_output(mha->seqp);
        return;
}



But if I take out this line

        snd_seq_ev_set_dest(&ev, 128, 0);

And replace it with:

         snd_seq_ev_set_dest(&ev, SND_SEQ_EVENT_PORT_SUBSCRIBED, 0);

And try to use aconnect to connect things together, it doesn't
seem to work.

So, there's some piece of the puzzle regarding how aconnect
works that I'm missing.

Any ideas?

Thanks,

-- steve



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Linux-audio-dev mailing list