This is just a dumb little demo to remind you what tones to play, in case you are lost in the desert and see bright lights. It uses Midi::Realtime to play tones. It's not terribly well written, but it will impress an 8-year old. :-)
#!/usr/bin/perl
use warnings;
use strict;
use MIDI::Realtime;
use Tk;
my $midi = MIDI::Realtime->new(
dev => '/dev/sequencer',
midi_device => 1
); #1,2,3,4
#5 for external keyboard
#thru USB UM-1 connector
my %rects;
my $mw = tkinit;
my $canvas = $mw->Canvas(
-bg => 'black',
-width => 250,
-height => 240,
)->pack();
my $z = 0;
my $w = 0;
for my $x ( 1 .. 5 ) {
for my $y ( reverse( 49 .. 60 ) ) {
$rects{ $x }{ $y } =
$canvas->createRectangle( $z, $w, $z + 50, $w
++ 20,
-fill => 'lightblue' );
$w += 20;
}
$z += 50;
$w = 0;
}
$mw->waitVisibility;
$mw->after( 1000, sub { &signal_et } );
MainLoop;
######################################################################
+######
sub signal_et {
$midi->patch( 57 ); #change instrument,
my $time = 1;
for ( 1, 2 ) {
$w = 1;
foreach my $num ( 58, 60, 51, 49 ) {
$midi->note( $num, 1, 90 ); #note,channel,volu
+me
$canvas->itemconfigure( $rects{ $w }{ $num },
+-fill => 'hotpink' );
$mw->update;
select( undef, undef, undef, $time / $_ );
$midi->note( $num, 1, 0 );
$canvas->itemconfigure( $rects{ $w }{ $num },
-fill => 'lightblue' );
$mw->update;
$w++;
}
$midi->note( 56, 1, 90 );
$canvas->itemconfigure( $rects{ 5 }{ 56 }, -fill => 'h
+otpink' );
$mw->update;
select( undef, undef, undef, 1 );
$midi->note( 56, 1, 0 );
$canvas->itemconfigure( $rects{ 5 }{ 56 }, -fill => 'l
+ightblue' );
$mw->update;
select( undef, undef, undef, 1 );
$midi->patch( 56 ); #change instrument after 1rst v
+olley
}
#response
$midi->patch( 55 ); #et's instrument
foreach my $num ( 58, 60, 51, 49 ) {
$midi->note( $num, 1, 127 );
select( undef, undef, undef, .5 );
$midi->note( $num, 1, 0 );
}
$midi->note( 56, 1, 127 );
select( undef, undef, undef, 1 );
$midi->note( 56, 1, 0 );
select( undef, undef, undef, 3 );
exit;
}
__END__