Skip Menu |

This queue is for tickets about the MIDI-Simple-Drummer CPAN distribution.

Report information
The Basics
Id: 107541
Status: resolved
Worked: 15 min
Priority: 0/
Queue: MIDI-Simple-Drummer

People
Owner: gene [...] cpan.org
Requestors: andrew2012 [...] flight.us
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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; -------------------------------------------------------------------------------------------
Hi Andrew. This is a report of two different issues. I have investigated the first so far. With code block A, in the backbeat sub, $self->div_name is the literal string 'QUARTER' - not note a proper note duration value. This just needs to be $self->QUARTER instead. -Gene On Sun Oct 04 13:57:20 2015, andrew2012@flight.us wrote: Show quoted text
> 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.
Show quoted text
> # ---------------------------------------------- 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;
> }
Andrew, For the second problem, you have just neglected to include the fin() subroutine in your Block B code, so perl can't find the custom pattern. Besides the SYNOPSIS, have a look at the example scripts in https://metacpan.org/source/GENE/MIDI-Simple-Drummer-0.08/eg :-) -Gene P.S. I will fix the div_name typo in the SYNOPSIS - Thank you for pointing that out. On Sun Oct 04 13:57:20 2015, andrew2012@flight.us wrote: Show quoted text
> 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 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 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; > > -------------------------------------------------------------------------------------------
-- -gb Epistemologist-at-large
Subject: Re: [rt.cpan.org #107541] MIDI::Simple::Drummer - run-time error
Date: Sun, 04 Oct 2015 18:28:40 -0400
To: bug-MIDI-Simple-Drummer [...] rt.cpan.org
From: Andrew <andrew2012 [...] flight.us>
On 10/04/2015 05:32 PM, Gene Boggs via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=107541 > > > Andrew, > > For the second problem, you have just neglected to include the fin() subroutine in your Block B code, so perl can't find the custom pattern. >
Tried it with the "fin" subroutine. Still same error: By the way, you have a typo in the "fin" subroutine; unclosed parenthesis in the first of series of method calls: $d->note($d->EIGHTH, $d->option_strike should be $d->note($d->EIGHTH, $d->option_strike); (correct?) ------------------ here's the non-working code, which includes the "fin" subroutine: ----------------------- #!/usr/bin/perl # A rock drummer: use MIDI::Simple::Drummer::Rock; $d = MIDI::Simple::Drummer::Rock->new(-bpm => 100); $d->count_in; $d->patterns(fin => \&fin); $d->beat(-name => 'fin'); my ($beat, $fill) = (0, 0); for my $p (1 .. $d->phrases) { if ($p % 2 > 0) { $beat = $d->beat(-name => 3, -fill => $fill); } else { $beat = $d->beat(-name => 4); $fill = $d->fill(-last => $fill); } } $d->write('drum_rock.mid'); #------------------------------------------------------------------- sub fin { my $d = shift; $d->note($d->EIGHTH, $d->option_strike); $d->note($d->EIGHTH, $d->strike('Splash Cymbal','Bass Drum 1')); $d->note($d->TRIPLET_SIXTEENTH, $d->snare) for 0 .. 2; $d->rest($d->SIXTEENTH); $d->note($d->EIGHTH, $d->strike('Splash Cymbal','Bass Drum 1')); } #------------------------------------------------------------------- result: Can't use an undefined value as a subroutine reference at /usr/local/share/perl/5.18.2/MIDI/Simple/Drummer.pm line 507. Show quoted text
> :-) > > -Gene > P.S. I will fix the div_name typo in the SYNOPSIS - Thank you for pointing that out.
Show quoted text
> > On Sun Oct 04 13:57:20 2015, andrew2012@flight.us wrote:
>> 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 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 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; >> >> -------------------------------------------------------------------------------------------
>
Hi Andrew. I have replaced the rock drummer SYNOPSIS section with a working example, that doesn't produce that mystery error. Please give that a shot! It is fixed in https://metacpan.org/release/GENE/MIDI-Simple-Drummer-0.0803 - just uploaded to CPAN. -Gene
Hello again. The error with problem B is because there is no beat named 3 or 4. Please look at https://metacpan.org/source/GENE/MIDI-Simple-Drummer-0.0803/lib/MIDI/Simple/Drummer/Rock.pm#L122 to know what the pre-programmed beats are named. Thank you again for pointing out the errors in my SYNOPSIS! :-) -Gene
Subject: Re: [rt.cpan.org #107541] MIDI::Simple::Drummer - run-time error
Date: Sun, 04 Oct 2015 21:05:28 -0400
To: bug-MIDI-Simple-Drummer [...] rt.cpan.org
From: Andrew <andrew2012 [...] flight.us>
On 10/04/2015 06:57 PM, Gene Boggs via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=107541 > > > Hi Andrew. > > I have replaced the rock drummer SYNOPSIS section with a working example, that doesn't produce that mystery error. Please give that a shot! > > It is fixed in https://metacpan.org/release/GENE/MIDI-Simple-Drummer-0.0803 - just uploaded to CPAN. > > -Gene >
Fantastic. I tried the jazz, rock, and multi-track examples; they all work. THANK YOU SO MUCH FOR YOUR CONTRIBUTION !!!! (and such a quick developer/maintainer response)