Re: [linux-audio-dev] Midi/OSC help

From: Jens M Andreasen <jens.andreasen@email-addr-hidden>
Date: Wed Jun 22 2005 - 10:14:45 EEST

On Tue, 2005-06-21 at 21:54 -0400, Paul Coccoli wrote:

>
> The best ALSA MIDI reference I found was http://www.suse.de/~mana/seqdemo.c
>
> It's an example client that illustrates how to receive MIDI messages.
> It should be pretty clear how to add MIDI control after you look at
> that code.
>

I use that one too, but think that the inner switch is perhaps a little
too simplistic to be fully helpful, with missing velocity, aftertouch,
pgmchange and so. After spending some time ploughing through header
files, my adaption of the switch now looks like this:

            //*///////////////////////////////////////////////////*//

            switch (ev->type)
              {
              case SND_SEQ_EVENT_CONTROLLER:
                mx44_control( mx44,
                              ev->data.control.channel,
                              ev->data.control.param,
                              ev->data.control.value );
                                
                break;
              case SND_SEQ_EVENT_PITCHBEND:
                mx44_pitchbend( mx44,
                                ev->data.control.channel,
                                ev->data.control.value,
                                0x3F ); // ALSA has +/- pitchbend!
                break;
              case SND_SEQ_EVENT_NOTEON:
                mx44_noteon( mx44,
                             ev->data.note.channel,
                             ev->data.note.note,
                             ev->data.note.velocity );
                break;
              case SND_SEQ_EVENT_NOTEOFF:
                mx44_noteoff( mx44,
                              ev->data.note.channel,
                              ev->data.note.note,
                              ev->data.note.velocity );
                break;
              case SND_SEQ_EVENT_PORT_SUBSCRIBED:
                
                fprintf(stderr,"Subscribed: send: %d:%d dest: %d:%d\n",
                        ev->data.connect.sender.client,
                        ev->data.connect.sender.port,
                        ev->data.connect.dest.client,
                        ev->data.connect.dest.port);
                break;

              case SND_SEQ_EVENT_PGMCHANGE:
                mx44_pgmchange( mx44,
                                ev->data.control.channel,
                                ev->data.control.value );
                if(mx44->isGraphic)
                  setwidgets(mx44->tmpPatch,
                             ev->data.control.channel,
                             ev->data.control.value); break;

              case SND_SEQ_EVENT_SENSING:
                // FIXME:
                //
                // This is apparently active sensing.
                // If we get it once and then loose it,
                // we should shut up!
                //
                break;

              case SND_SEQ_EVENT_CHANPRESS:
                mx44_chanpress( mx44,
                                ev->data.control.channel,
                                ev->data.control.value );
                break;

              default:
                fprintf(stderr,"Unknown SND_SEQ_EVENT_#%d\n",ev->type);
              }

            //*///////////////////////////////////////////////////*//

Perhaps Matthias could extend seqdemo.c to include these additions?

mvh // Jens M Andreasen

PS: The call to pitchbend() looks funny because it was written to accept
the raw LSB/MSB bytes from /dev/midi. You would probably just use the
single cooked value as given by ALSA.

-- 
Received on Wed Jun 22 12:15:12 2005

This archive was generated by hypermail 2.1.8 : Wed Jun 22 2005 - 12:15:13 EEST