#!/usr/bin/perl use warnings; use strict; use MIDI::Realtime; use Term::ReadKey; ReadMode('cbreak'); #this works on linux with an SBlive, Alsa 1.0.4, kernel 2.4.22 # on my system, it has a bug when usb-hotplug and usb-midi are used my $midi = MIDI::Realtime->new(dev=>'/dev/sequencer', midi_device=> 1); #1,2,3,4 while(1){ my $char; if (defined ($char = ReadKey(0)) ) { print ord($char),"\n"; # input was waiting and it was $char $midi->patch(ord($char)); #change instrument, 127 gives "exploding keyboard" :-) $midi->note(50,1,127); #play note } else { # no input was waiting } } ReadMode('normal'); # restore normal tty settings __END__