Thanks for that, gives me some more to chew on for a
lil while.

That's a nice compact program inline in the text with
compile command, very much appreciated...

thanks
Rua HM.

--- Malte Steiner <[EMAIL PROTECTED]> wrote:

> Hi.
> 
> I dont know the state of Jackmidi so I did the same.
> 
> Its rather simple with Alsa:
> 
> http://tldp.org/HOWTO/MIDI-HOWTO-9.html
> http://www.suse.de/~mana/alsa090_howto.html
> 
> this got me started without problems:
> 
> $ gcc seqdemo.c -o seqdemo -lasound
> 
> /* seqdemo.c by Matthias Nagorni */
>
----------------------------------------------------------------
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <alsa/asoundlib.h>
> 
> snd_seq_t *open_seq();
> void midi_action(snd_seq_t *seq_handle);
> 
> snd_seq_t *open_seq() {
> 
>    snd_seq_t *seq_handle;
>    int portid;
> 
>    if (snd_seq_open(&seq_handle, "default",
> SND_SEQ_OPEN_INPUT, 0) < 0) {
>      fprintf(stderr, "Error opening ALSA
> sequencer.\n");
>      exit(1);
>    }
>    snd_seq_set_client_name(seq_handle, "ALSA
> Sequencer Demo");
>    if ((portid =
> snd_seq_create_simple_port(seq_handle, "ALSA
> Sequencer 
> Demo",
>             
> SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE,
>              SND_SEQ_PORT_TYPE_APPLICATION)) < 0) {
>      fprintf(stderr, "Error creating sequencer
> port.\n");
>      exit(1);
>    }
>    return(seq_handle);
> }
> 
> void midi_action(snd_seq_t *seq_handle) {
> 
>    snd_seq_event_t *ev;
> 
>    do {
>      snd_seq_event_input(seq_handle, &ev);
>      switch (ev->type) {
>        case SND_SEQ_EVENT_CONTROLLER:
>          fprintf(stderr, "Control event on Channel
> %2d: %5d       \r",
>                  ev->data.control.channel,
> ev->data.control.value);
>          break;
>        case SND_SEQ_EVENT_PITCHBEND:
>          fprintf(stderr, "Pitchbender event on
> Channel %2d: %5d   \r",
>                  ev->data.control.channel,
> ev->data.control.value);
>          break;
>        case SND_SEQ_EVENT_NOTEON:
>          fprintf(stderr, "Note On event on Channel
> %2d: %5d       \r",
>                  ev->data.control.channel,
> ev->data.note.note);
>          break;
>        case SND_SEQ_EVENT_NOTEOFF:
>          fprintf(stderr, "Note Off event on Channel
> %2d: %5d      \r",
>                  ev->data.control.channel,
> ev->data.note.note);
>          break;
>      }
>      snd_seq_free_event(ev);
>    } while (snd_seq_event_input_pending(seq_handle,
> 0) > 0);
> }
> 
> int main(int argc, char *argv[]) {
> 
>    snd_seq_t *seq_handle;
>    int npfd;
>    struct pollfd *pfd;
> 
>    seq_handle = open_seq();
>    npfd = snd_seq_poll_descriptors_count(seq_handle,
> POLLIN);
>    pfd = (struct pollfd *)alloca(npfd *
> sizeof(struct pollfd));
>    snd_seq_poll_descriptors(seq_handle, pfd, npfd,
> POLLIN);
>    while (1) {
>      if (poll(pfd, npfd, 100000) > 0) {
>        midi_action(seq_handle);
>      }
>    }
> }
>
------------------------------------------------------------------
> 
> 
> Cheers,
> 
> Malte
> 
> 
> -- 
> Malte Steiner
> media art + development
> -www.block4.com-
> 
> next concert:
> Elektronengehirn 30.8. ICMC 2007, Copenhagen,
> Denmark
> 
> _______________________________________________
> 64studio-devel mailing list
> [email protected]
>
http://lists.64studio.com/mailman/listinfo/64studio-devel
> 


Send instant messages to your online friends http://au.messenger.yahoo.com 

_______________________________________________
64studio-devel mailing list
[email protected]
http://lists.64studio.com/mailman/listinfo/64studio-devel

Reply via email to