Re: [linux-audio-dev] MIDI routing, FIFO's etc.

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] MIDI routing, FIFO's etc.
From: Paul Barton-Davis (pbd_AT_Op.Net)
Date: pe loka   08 1999 - 19:52:36 EDT


>Yes, initially I thought I could do this w/ a user space client talking to
>ALSA, interfacing w/ the legacy app thru a pipe, since the pipe would appear
>as a device file to the app. Unfortunately, most of the apps I'm interested
>in both read and write to the raw midi interface.

First, any program that only does I/O to /dev/midi should be shot at
dawn. If it uses a user-selectable one of /dev/midiNN, it can live.

In the meantime:

% su
Password:
# cd /dev
# for devnum in 00 01 02 03
# do
# mv midi${devnum} mididev${devnum}
# mkfifo midififo${devnum}
# ln -s midififo${devnum} midi${devnum}
# done
# rm midi
# ln -s midi midififo${yourchoice}
# ^D
%

To get back to the default state of affairs: then you just need a
small midirouting daemon that runs in the background, holds all
/dev/mididev* device files open, and forwards data to and from
/dev/midififo*. Note the inherent similarity to OMS here. I even wrote
such a small daemon last year, but I rarely use it anymore. It even
did channel splitting across ports, and I once had plans to do note
splits across ports as well (i.e. if (noteNum > N) send_to (portA)
else send_to (portB)). Fun stuff.

To get beyond the default state, create some more fifos, link them to
/dev/midiNN, and leave it at that. Programs can open /dev/midi09, and
actually be talking to a pipe.

Alas, FIFO's don't work exactly like files, devices or sockets. If you
do the open...read and open...write sequences in the wrong order
and/or without the correct logic, you will get errors instead of
blocking.

Also, the beauty of this kind of scheme is one of the things I have
against the ALSA lib API for raw MIDI devices. Anything that tries to
obscure or complicate the fact that a MIDI "port" is just a byte sink
and source is evil :) Thats why I never use the ALSA lib API for MIDI,
but just stick to regular Unix open/close/read/write on /dev/snd/midiCxxDyy

Seriously though, I doubt the success of Linux for MIDI until the kind
of facilities that OMS provides on the Mac exist *in the
kernel*. There are people (myself included) who feel uncomfortable
about having two context switches necessary to send MIDI data, have it
delivered, and then get on with what I'm doing. Its not clear to me if
the ALSA Sequencer can do all this, but it would be great if it could.

--p


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : pe maalis 10 2000 - 07:27:13 EST