Re: MIDI to systemcommand, exute script etc.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Nov 08, 2008 at 10:31:51PM +0100, 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?

Yes.

I've used several methods.  One of the most interesting for a while was
rebinding some very high notes on my piano to terminate MIDI capture and
do something with the file.  The same technique could be used to fork
off other shell-scripts in your case.

Here is how it worked:

1.  a change to arecordmidi to detect certain events, stop recording,
and return a specific exit status to a script, (patch attached),

2.  an arecordmidi-loop.sh script (attached) which I would start on my
computer before moving to my piano, it would begin recording MIDI
events to a file named according to the current date and time,

3.  some creative playing might ensue, or might not,

4.  one key on the piano if pressed would stop recording, discard the
file, and start recording again, this was marked with a yellow sticky as
"discard",

5.  another key if pressed would stop the recording, keep the file, and
start recording again, this was marked as "keep",

6.  another key would stop the recording, discard the file, and not
start recording again, this was marked as "terminate".

Each response set or cleared an indicator LED on my parallel port driven
indicator array.  That's what "pung" was doing.  This gave me a visual
indication of current state.

The "discard" and "keep" responses would also briefly play a MIDI
sequence confirming the action ... so I didn't need to watch the screen.

-- 
James Cameron    mailto:quozl@xxxxxxxxxxxxx     http://quozl.netrek.org/

Attachment: arecordmidi-loop.sh
Description: Bourne shell script

--- arecordmidi.c.orig	2008-11-09 12:11:52.000000000 +1100
+++ arecordmidi.c	2008-11-09 12:13:03.000000000 +1100
@@ -864,6 +864,27 @@
 			err = snd_seq_event_input(seq, &event);
 			if (err < 0)
 				break;
+			if (event && 
+			    event->type == SND_SEQ_EVENT_NOTEON && 
+			    event->data.note.note == 108) {
+				printf("NORMAL STOP\n");
+				stop = 1;
+				break;
+			}
+			if (event && 
+			    event->type == SND_SEQ_EVENT_NOTEON && 
+			    event->data.note.note == 107) {
+				printf("DISCARD STOP\n");
+				stop = 2;
+				break;
+			}
+			if (event && 
+			    event->type == SND_SEQ_EVENT_NOTEON && 
+			    event->data.note.note == 106) {
+				printf("TERMINATE STOP\n");
+				stop = 3;
+				break;
+			}
 			if (event)
 				record_event(event);
 		} while (err > 0);
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@xxxxxxxxxxxxxxxxxxxx
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-user

[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux