[PD] midiout broken

günter geiger geiger at xdv.org
Tue Nov 15 08:41:09 CET 2005


On Mon, 14 Nov 2005, federico wrote:
> this patch was submitted time ago.

Did you submit it to the patches tracker ?

Guenter

> what does tries to fix?
> it simply parses for system exclusive messages (they begin with 0xf0 and
> end with 0xf7) so we put everithing that comes between 0xf0...0xf7 in a
> buffer, and when receiving the 0xf7 byte (end-of-sysex) we send the
> entire buffer to alsa.
> this should be the right way of doing it.
> since note&controllers worked, i think it is okay sending them like we
> actually do.
>
> however when I tried this didn't work because sys_alsa_putmidibyte
> doesn't gets called.
> how do I re-enable it?
>
>
> --- pd-0.39-1.orig/src/s_midi_alsa.c    2005-08-20 01:25:19.000000000 +0200
> +++ pd-0.39-1/src/s_midi_alsa.c    2005-10-24 21:17:27.000000000 +0200
> @@ -163,20 +163,39 @@ void sys_alsa_putmidimess(int portno, in
>
> void sys_alsa_putmidibyte(int portno, int byte)
> {
> +#define dataptr_sz 1024
> +    static unsigned int dataptr_pos = 0;
> +    static unsigned char dataptr[dataptr_sz];
> +
> +    fprintf(stderr, "midi byte: 0x%2,2X\n");
> +       snd_seq_event_t ev;
>     snd_seq_ev_clear(&ev);
>     if (portno >= 0 && portno < alsa_nmidiout)
>     {
> -        // repack into 1 byte char and put somewhere to point at
> -        unsigned char data = (unsigned char)byte;
> -        unsigned char *dataptr = malloc(1);
> -        memcpy(dataptr,&byte,1);
> -
> -        snd_seq_ev_set_sysex(&ev,1,dataptr); //...set_variable *should*
> have worked but didn't
> -        snd_seq_ev_set_direct(&ev);
> -        snd_seq_ev_set_subs(&ev);
> -        snd_seq_ev_set_source(&ev,alsa_midioutfd[portno]);
> -        snd_seq_event_output_direct(midi_handle,&ev);
> +    if(dataptr_pos < dataptr_sz) {
> +        // store sysex (from xf0 to xf7) in a buffer...
> +        if(dataptr_pos == 0 && byte != 0xf0) return; // drop unexpeted
> result
> +        dataptr[dataptr_pos++] = (unsigned char)byte;
> +        if(byte != 0xf7) return; // wait til xf7
> +    } else {
> +        // overflow: drop the msg
> +        dataptr_pos = 0;
> +        return;
> +    }
> +
> +    int i;
> +    fprintf(stderr, "sending sysex (len=%d)", dataptr_pos);
> +    for(i=0; i<dataptr_pos; i++) fprintf(stderr, " 0x%.2X", dataptr[i]);
> +    fprintf(stderr, "\n");
> +   +    if(dataptr_pos > 0) {
> +            snd_seq_ev_set_sysex(&ev,dataptr_pos,dataptr);
> +        snd_seq_ev_set_direct(&ev);
> +            snd_seq_ev_set_subs(&ev);
> +            snd_seq_ev_set_source(&ev,alsa_midioutfd[portno]);
> +            snd_seq_event_output_direct(midi_handle,&ev);
> +    }
>     }
> }
>
>
>
> _______________________________________________
> PD-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
>




More information about the Pd-list mailing list