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__
In reply to Signal-ET
by zentara
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.