Subject: | MIDI::Simple::Drummer - run-time error |
Date: | Sun, 04 Oct 2015 16:57:05 -0400 |
To: | bug-MIDI-Simple-Drummer [...] rt.cpan.org |
From: | Andrew <andrew2012 [...] flight.us> |
Hi, Gene:
When I run your MIDI::Simple::Drummer from this page -
https://metacpan.org/pod/MIDI::Simple::Drummer#patterns - code i get
errors...
for the first block (See "Block A"), i get:
Unknown note/rest option: "QUARTER" at
/usr/local/share/perl/5.18.2/MIDI/Simple/Drummer.pm line 434.
For the third block, with the "Rock" module (see "Block B"), I get:
Can't use an undefined value as a subroutine reference at
/usr/local/share/perl/5.18.2/MIDI/Simple/Drummer.pm line 507.
For the "Rock" module, i think this line is where things go wrong,
when the "->beat" method is called:
$self->{-patterns}{$n}->($self, %args);
(The above is from Drummer.pm, line 507, the "beat" subroutine)
Syntax is OK, according to "perl -c ...."
# ---------------------------------------------- Block A
---------------------------------------
#!/usr/bin/perl
# Multi-tracking:
use MIDI::Simple::Drummer;
my $d = MIDI::Simple::Drummer->new(-file => "$0.mid");
$d->patterns(b1 => \&hihat);
$d->patterns(b2 => \&backbeat);
$d->sync_tracks(
sub { $d->beat(-name => 'b1') },
sub { $d->beat(-name => 'b2') },
);
$d->write();
sub hihat { # tick
my $self = shift;
$self->note($self->EIGHTH, $self->tick) for 1 .. 2 * $self->beats;
}
sub backbeat { # kick/snare
my $self = shift;
$self->note($self->div_name, $self->rotate($_)) for 1 .. $self->beats;
}
#------------------------------------------------------- Block B
---------------------------------------------------------
use MIDI::Simple::Drummer::Rock;
$d = MIDI::Simple::Drummer::Rock->new(-bpm => 100);
my ($beat, $fill) = (0, 0);
$d->count_in;
for my $p (1 .. $d->phrases) {
print "\n [$p] ... ";
if ($p % 2 > 0) {
$beat = $d->beat(-name => 3, -fill => $fill);
}
else {
$beat = $d->beat(-name => 4);
$fill = $d->fill(-last => $fill);
}
}
$d->patterns(fin => \&fin);
$d->beat(-name => 'fin');
$d->write;
-------------------------------------------------------------------------------------------