File Coverage

blib/lib/MIDI/Simple/Drummer/Rock.pm
Criterion Covered Total %
statement 67 195 34.3
branch 0 8 0.0
condition 0 3 0.0
subroutine 19 44 43.1
pod 1 1 100.0
total 87 251 34.6


line stmt bran cond sub pod time code
1             package MIDI::Simple::Drummer::Rock;
2             $MIDI::Simple::Drummer::Rock::VERSION = '0.0811';
3             our $AUTHORITY = 'cpan:GENE';
4 1     1   599 use strict;
  1         2  
  1         23  
5 1     1   5 use warnings;
  1         1  
  1         23  
6 1     1   334 use parent 'MIDI::Simple::Drummer';
  1         257  
  1         4  
7              
8 1     1   43 use constant CLOSED => 'Closed Hi-Hat';
  1         3  
  1         57  
9 1     1   5 use constant CRASH => 'Crash Cymbal 1';
  1         2  
  1         36  
10 1     1   5 use constant BELL => 'Ride Bell';
  1         1  
  1         34  
11 1     1   4 use constant RIDE2 => 'Ride Cymbal 2';
  1         1  
  1         47  
12 1     1   6 use constant TOM1 => 'High Tom';
  1         1  
  1         37  
13 1     1   5 use constant TOM2 => 'Low-Mid Tom';
  1         1  
  1         43  
14 1     1   5 use constant TOM3 => 'Low Tom';
  1         2  
  1         44  
15 1     1   5 use constant TOM4 => 'High Floor Tom';
  1         2  
  1         35  
16 1     1   4 use constant TOM5 => 'Low Floor Tom';
  1         2  
  1         1873  
17              
18             sub new {
19 1     1 1 501 my $self = shift;
20 1         7 $self->SUPER::new(
21             -patch => 1,
22             @_
23             );
24             }
25              
26             # "Quater-note beat" Qn tick. Cym on 1. Kick 1&3. Snare 2&4.
27             sub _quarter {
28 2     2   2 my $self = shift;
29 2         6 my %args = @_;
30 2         9 for my $beat (1 .. $self->beats) {
31             $self->note($self->QUARTER,
32             $self->rotate($beat, $args{-rotate}),
33             $self->strike($args{-key_patch})
34 8         469 );
35             }
36             }
37              
38             # Common eighth-note based grooves with kick syncopation.
39             sub _eighth {
40 0     0   0 my $self = shift;
41 0         0 my %args = @_;
42 0         0 for my $beat (1 .. $self->beats) {
43             # Lay-down a back-beat rhythm.
44 0         0 $self->note($self->EIGHTH,
45             $self->backbeat_rhythm(%args, -beat => $beat)
46             );
47             # Add another kick or tick if we're at the right beat.
48             $self->note($self->EIGHTH,
49 0         0 ((grep { $beat == $_ } @{$args{-key_beat}})
  0         0  
50             ? ($self->kick, $self->tick) : $self->tick)
51 0 0 0     0 ) if $args{-key_beat} && @{$args{-key_beat}};
  0 0       0  
52             }
53             }
54              
55             sub _kick_fill {
56 0     0   0 my $self = shift;
57 0         0 my %args = @_;
58             $self->note(
59             $args{-note},
60             $self->kick,
61             $args{-fill}
62 0 0       0 ? $self->strike($args{-patches} ? @{$args{-patches}} : CRASH)
  0 0       0  
63             : $self->tick
64             );
65             }
66              
67             sub _half_one {
68 0     0   0 my $self = shift;
69 0         0 my %args = @_;
70 0         0 $self->_kick_fill(-note => $self->EIGHTH, %args);
71 0         0 $self->note($self->EIGHTH, $self->tick);
72 0         0 $self->note($self->EIGHTH, $self->snare, $self->tick);
73 0         0 $self->note($self->EIGHTH, $self->tick);
74             }
75              
76             sub _half_two {
77 0     0   0 my $self = shift;
78 0         0 my %args = @_;
79 0         0 $self->note($self->EIGHTH, $self->kick, $self->tick);
80 0         0 $self->note($self->EIGHTH, $self->kick, $self->tick);
81 0         0 $self->note($self->EIGHTH, $self->snare, $self->tick);
82 0         0 $self->note($self->EIGHTH, $self->tick);
83             }
84              
85             sub _half_three {
86 0     0   0 my $self = shift;
87 0         0 my %args = @_;
88 0         0 $self->note($self->EIGHTH, $self->tick);
89 0         0 $self->note($self->EIGHTH, $self->kick, $self->tick);
90 0         0 $self->note($self->EIGHTH, $self->snare, $self->tick);
91 0         0 $self->note($self->EIGHTH, $self->kick, $self->tick);
92             }
93              
94             sub _half_four {
95 0     0   0 my $self = shift;
96 0         0 my %args = @_;
97 0         0 $self->note($self->EIGHTH, $self->kick, $self->tick) for 0 .. 1;
98 0         0 $self->note($self->EIGHTH, $self->snare, $self->tick);
99 0         0 $self->note($self->EIGHTH, $self->kick, $self->tick);
100             }
101              
102             sub _half_four_two {
103 0     0   0 my $self = shift;
104 0         0 my %args = @_;
105 0         0 $self->note($self->EIGHTH, $self->tick);
106 0         0 $self->note($self->EIGHTH, $self->kick, $self->tick);
107 0         0 $self->note($self->EIGHTH, $self->snare, $self->tick);
108 0         0 $self->note($self->EIGHTH, $self->tick);
109             }
110              
111             sub _half_five {
112 0     0   0 my $self = shift;
113 0         0 my %args = @_;
114 0         0 $self->note($self->EIGHTH, $self->kick, $self->tick);
115 0         0 $self->note($self->EIGHTH, $self->tick);
116 0         0 $self->note($self->EIGHTH, $self->snare, $self->tick);
117 0         0 $self->note($self->EIGHTH, $self->kick, $self->tick);
118             }
119              
120             sub _default_patterns {
121 1     1   2 my $self = shift;
122             return {
123              
124             1.1 => sub {
125 2     2   3 my $self = shift;
126 2         6 my %args = (-key_patch => CLOSED, @_);
127 2         7 $self->_quarter(%args);
128             },
129             1.2 => sub {
130 0     0   0 my $self = shift;
131 0         0 my %args = (-key_patch => BELL, @_);
132 0         0 $self->_quarter(%args);
133             },
134             1.3 => sub {
135 0     0   0 my $self = shift;
136 0         0 my %args = (-key_patch => RIDE2, @_);
137 0         0 $self->_quarter(%args);
138             },
139              
140             # Exercises from the see also link.
141             2.1 => sub { # Ex. 1
142 0     0   0 my $self = shift;
143 0         0 my %args = @_;
144 0         0 $self->_half_one(%args);
145 0         0 $self->_half_one;
146             },
147             2.2 => sub { # Ex. 2
148 0     0   0 my $self = shift;
149 0         0 my %args = @_;
150 0         0 $self->_half_one(%args);
151 0         0 $self->_half_two;
152             },
153             2.3 => sub { # Ex. 3
154 0     0   0 my $self = shift;
155 0         0 my %args = @_;
156 0         0 $self->_half_one(%args);
157 0         0 $self->_half_three;
158             },
159             2.4 => sub { # Ex. 4
160 0     0   0 my $self = shift;
161 0         0 my %args = @_;
162 0         0 $self->_half_four(%args);
163 0         0 $self->_half_four_two;
164             },
165             2.5 => sub { # Ex. 5
166 0     0   0 my $self = shift;
167 0         0 my %args = @_;
168 0         0 $self->_half_five(%args);
169 0         0 $self->_half_four;
170             },
171             2.6 => sub { # Ex. 6
172 0     0   0 my $self = shift;
173 0         0 my %args = @_;
174 0         0 $self->_half_five(%args);
175 0         0 $self->_half_one;
176 0         0 $self->_half_one;
177 0         0 $self->_half_four;
178 0         0 $self->_half_five;
179 0         0 $self->_half_one;
180             },
181             2.7 => sub { # Ex. 7
182 0     0   0 my $self = shift;
183 0         0 my %args = @_;
184 0         0 $self->_half_four(%args);
185 0         0 $self->_half_five;
186 0         0 $self->_half_five;
187 0         0 $self->_half_four_two;
188 0         0 $self->_half_four;
189 0         0 $self->_half_five;
190             },
191             2.8 => sub { # Ex. 8
192 0     0   0 my $self = shift;
193 0         0 my %args = @_;
194 0         0 $self->_half_one(%args);
195 0         0 $self->_half_four_two;
196 0         0 $self->_half_four;
197 0         0 $self->_half_three;
198 0         0 $self->_half_one;
199 0         0 $self->_half_four_two;
200             },
201              
202             3.1 => sub { # "Syncopated beat 1" en c-hh. qn k1,3,4&. qn s2,4.
203 0     0   0 my $self = shift;
204 0         0 my %args = (-key_beat => [4], @_);
205 0         0 $self->_eighth(%args);
206             },
207             3.2 => sub { # "Syncopated beat 2" en c-hh. qn k1,3,3&,4&. qn s2,4.
208 0     0   0 my $self = shift;
209 0         0 my %args = (-key_beat => [3, 4], @_);
210 0         0 $self->_eighth(%args);
211             },
212              
213             '1 fill' => sub {
214 0     0   0 my $self = shift;
215 0         0 $self->note($self->SIXTEENTH, $self->snare) for 0 .. 3;
216 0         0 $self->note($self->SIXTEENTH, $self->strike(TOM1)) for 0 .. 3;
217 0         0 $self->note($self->SIXTEENTH, $self->strike(TOM3)) for 0 .. 3;
218 0         0 $self->note($self->SIXTEENTH, $self->strike(TOM5)) for 0 .. 3;
219             },
220             '2 fill' => sub {
221 0     0   0 my $self = shift;
222 0         0 $self->note($self->SIXTEENTH, $self->snare, $self->strike(TOM5)) for 0 .. 3;
223             },
224             '3 fill' => sub {
225 0     0   0 my $self = shift;
226 0         0 $self->note($self->SIXTEENTH, $self->snare) for 0 .. 1;
227 0         0 $self->note($self->EIGHTH, $self->snare);
228 0         0 $self->note($self->SIXTEENTH, $self->strike(TOM1)) for 0 .. 1;
229 0         0 $self->note($self->EIGHTH, $self->strike(TOM1));
230             },
231             '4 fill' => sub {
232 0     0   0 my $self = shift;
233 0         0 $self->note($self->SIXTEENTH, $self->snare, $self->strike(TOM5)) for 0 .. 1;
234 0         0 $self->note($self->SIXTEENTH, $self->snare) for 0 .. 1;
235 0         0 $self->note($self->SIXTEENTH, $self->strike(TOM1)) for 0 .. 1;
236             },
237             '5 fill' => sub {
238 1     1   2 my $self = shift;
239 1         4 $self->note($self->EIGHTH, $self->kick, $self->strike(CRASH));
240 1         138 $self->note($self->EIGHTH, $self->snare) for 0 .. 2;
241 1         47 $self->note($self->SIXTEENTH, $self->strike(TOM1)) for 0 .. 3;
242 1         48 $self->note($self->SIXTEENTH, $self->strike(TOM3)) for 0 .. 3;
243             },
244             '6 fill' => sub {
245 1     1   2 my $self = shift;
246 1         12 $self->note($self->SIXTEENTH, $self->snare) for 0 .. 3;
247 1         141 $self->note($self->EIGHTH, $self->strike(TOM1));
248 1         55 $self->note($self->SIXTEENTH, $self->strike(TOM1)) for 0 .. 1;
249 1         46 $self->note($self->SIXTEENTH, $self->snare) for 0 .. 1;
250 1         169 $self->note($self->EIGHTH, $self->strike(TOM1));
251 1         53 $self->note($self->SIXTEENTH, $self->snare) for 0 .. 1;
252 1         46 $self->note($self->EIGHTH, $self->strike(TOM3));
253             },
254             '7 fill' => sub {
255 0     0   0 my $self = shift;
256 0         0 $self->note($self->SIXTEENTH, $self->snare);
257 0         0 $self->note($self->EIGHTH, $self->snare);
258 0         0 $self->note($self->SIXTEENTH, $self->strike(TOM1));
259 0         0 $self->note($self->EIGHTH, $self->strike(TOM1));
260 0         0 $self->note($self->SIXTEENTH, $self->strike(TOM3)) for 0 .. 1;
261 0         0 $self->note($self->SIXTEENTH, $self->snare) for 0 .. 3;
262 0         0 $self->note($self->SIXTEENTH, $self->strike(TOM3)) for 0 .. 1;
263 0         0 $self->note($self->EIGHTH, $self->strike(TOM3));
264             },
265             '8 fill' => sub {
266 1     1   1 my $self = shift;
267 1         4 $self->note($self->EIGHTH, $self->snare);
268 1         57 $self->note($self->EIGHTH, $self->kick) for 0 .. 1;
269 1         46 $self->note($self->EIGHTH, $self->snare);
270 1         47 $self->note($self->EIGHTH, $self->kick) for 0 .. 1;
271 1         64 $self->note($self->EIGHTH, $self->snare);
272 1         50 $self->note($self->EIGHTH, $self->kick);
273             },
274              
275 1         69 };
276             }
277              
278             1;
279              
280             __END__