midithru - a straight-through ALSA-MIDI client with a helpful display
midithru -i Pro,Key -o TiM xterm -font 9x15bold -geometry 66x23-1+1 -e midithru & xterm -font 7x14bold -geometry 66x23-1-1 -e midithru -n thru-2 & xterm -font 12x24 -geometry 58x21-1+1 -e midithru -i Pro & midithru -v perldoc midithru
midithru is a simple Straight-Through ALSA-MIDI client that displays real-time information about the MIDI-channels passing through it, such as which ALSA-client they most recently came from, which Patch they have most recently been set to, and what the latest Controller-Change was. For example:
ALSA-client midithru 129:0 (in) 129:1 (out) connected from 24=ProKeys, 130=aplaymidi, 131=midikbd Channel From Patch Latest CC 0 24=ProKeys 17=Percussive Organ cc64=127 1 28=Keystation 24=Acoustic Guitar(nylon) cc11=83 2 130=aplaymidi 33=Electric Bass(finger) 3 14=MidiThrough 4=Electric Piano cc64=0 9 130=aplaymidi percussion 12 130=aplaymidi bank 5,5 patch 2 connected to 20=Roland
If bank has not been set, the patches are named by
their General-MIDI names.
To quit midithru, type Ctrl-C twice.
Within a window 66x23 (or larger) it displays comfortably. The smallest window in which it works properly is 58x20, though it still works down to 58x19 by omitting the connected from line.
midithru is written in Lua,
and requires the modules
Because SIGWINCH is not Posix, luaposix does not support it, and indeed disables the kernel's SIGWINCH handler so that even tput, resize,
$COLS do not get updated.
Therefore midithru uses xwininfo, if it's available,
to detect changes in window size.
Set the ALSA input-client, to my ProKeys Sono 88 and my Keystation 49e in this example. As in the example, multiple input-clients may be specified, separated by commas. The clients are identified by a case-significant start-of-string match, or by their ALSA client-numbers. By default, no client is connected to the input.
Set the ALSA output-client, to TiMidity in this example.
The clients are identified by a case-significant start-of-string match,
or by their ALSA client-numbers.
As usual, a particular port within the client can be specified,
e.g. -o 14:3
Multiple output-clients may be specified, separated by commas.
By default, the environment variable ALSA_OUTPUT_PORTS is used, if it is set.
For compatibility with midifade, the -o 0 option is a special case, and means the midithru output is not connected to anything. This leaves you free to connect it later (remember that the midithru client produces its output on port 1 !) using e.g.
xterm -font 9x15bold -geometry 66x23-1+1 -e midithru -o 0 & ... aconnect midithru:1 TiMidity arecordmidi -p midithru:1 -b 60 -t 1000 /tmp/session.mid
Set the ALSA client-name, to midithru2 in this example. This is useful if you want to start up more than one midithru, and then connect to them by name with aconnect. The default client-name is midithru.
Prints version number.
To install midithru, save it to disc,
move it into your
$PATH, make it executable, and if necessary
edit the first line to reflect where lua is installed on your system.
You will also need the
1.2, 20140421, handles LINES=20 correctly
1.1, 20140420, displays connected from; adapts somewhat to screen size
1.0, 20140412, first working version
Peter J Billam www.pjb.com.au/comp/contact.html