Re: [LAU] MIDI to systemcommand, exute script etc.

From: Dominic Sacré <dominic.sacre@email-addr-hidden>
Date: Wed Nov 12 2008 - 03:55:01 EET

On Tuesday 11 November 2008 23:59:04 Ken Restivo wrote:
> On Mon, Nov 10, 2008 at 06:08:41PM +0100, Dominic Sacré wrote:
> > On Saturday 08 November 2008 22:31:51 Nils Gey wrote:
> > > Do you know any ways to receive midi events to start programms,
> > > execute shell-scripts or using other things you normaly do with your
> > > computer-keyboard and shortcuts?
> >
> > This is one of the things mididings (http://das.nasophon.de/mididings/)
> > was made for.
> > For example, the following Python script would listen on an ALSA MIDI
> > port, and run different shell commands in response to note-on events:
> >
> > from mididings import *
> >
> > run(
> > Filter(NOTEON) >> KeySplit({
> > 60: System('foo'),
> > 61: System('bar'),
> > ...
> > })
> > )
>
> I haven't used Python in a while, but what does that ">>" syntax do? A
> binary shift right?

Well, yes and no... For integers it would do a binary shift, but in Python
operators can be overloaded for user-defined types. With mididings, A >> B
means "connect B to A".
In the example above, all incoming MIDI events first go through a filter
that removes anything except note-on events. The remaining events are then
split by note number, so that each key runs a different command.

The idea behind mididings is that you use Python to define how MIDI events
are processed by connecting different "units". But all Python code is
(usually) run at startup. Once event processing is started, this is done
completely in C++, mainly because of latency and realtime safety.

Dominic
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-user
Received on Wed Nov 12 04:15:04 2008

This archive was generated by hypermail 2.1.8 : Wed Nov 12 2008 - 04:15:04 EET