Tiny/SwingFills.pm

filter: Statementstmt 7.5% 15 / 199 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 14.2% 4 / 28 Podpod 100% 1 / 1 totaltotal 8.5% 20 / 233 CC 2 SCAR 7.6
CC
2
Cov
7%
_fills
6.0
get_fill
2.0
__ANON__
2.0
CRAP 2.1
« Tiny/Grooves.pm ↑ Summary Tiny/Types.pm »
1 package MIDI::Drummer::Tiny::SwingFills;
2 1 $MIDI::Drummer::Tiny::SwingFills::VERSION = '0.7102';
3 1 our $AUTHORITY = 'cpan:GENE';
4  
5 # ABSTRACT: Drum fills with swing
6  
7 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use MIDI::Util qw(dura_size);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #pod =head1 SYNOPSIS
13 #pod
14 #pod use MIDI::Drummer::Tiny;
15 #pod use MIDI::Drummer::Tiny::SwingFills;
16 #pod
17 #pod my $d = MIDI::Drummer::Tiny->new;
18 #pod my $f = MIDI::Drummer::Tiny::SwingFills->new;
19 #pod
20 #pod for my $i (1 .. $d->beats * $d->bars) {
21 #pod my $remainder = $d->beats * $d->bars - $i;
22 #pod my $fill = $f->get_fill($d, $d->ride2);
23 #pod if ($remainder == $fill->{dura}) {
24 #pod $fill->{fill}->();
25 #pod last;
26 #pod }
27 #pod else {
28 #pod $d->note($d->quarter, $d->open_hh, $_ % 2 ? $d->kick : $d->snare);
29 #pod }
30 #pod }
31 #pod
32 #pod =head1 DESCRIPTION
33 #pod
34 #pod TBD
35 #pod
36 #pod =cut
37  
38 #pod =head1 METHODS
39 #pod
40 #pod =head2 new
41 #pod
42 #pod $f = MIDI::Drummer::Tiny::Fills->new;
43 #pod
44 #pod Return a new C<MIDI::Drummer::Tiny::Fills> object.
45 #pod
46 #pod =head2 get_fill
47 #pod
48 #pod $fill = $f->get_fill($drummer_obj, $cymbal);
49 #pod
50 #pod Return a random fill given a B<drummer_object> and an optional
51 #pod B<cymbal>.
52 #pod
53 #pod The fill that is returned is a hash reference with keys: C<fill> - a
54 #pod code reference, and C<dura> - the numerical duration of the fill.
55 #pod
56 #pod =cut
57  
58 0 ▶sub get_fill {
Subroutine get_fill: not called CC=1 SCAR=6.9
Pod documented
59 0 my ($self, $drummer, $cymbal) = @_;
60 0 my $fills = $self->_fills($drummer, $cymbal);
61 0 my @keys = keys %$fills;
62 0 my $fill = $keys[ int rand @keys ];
63 0 return $fills->{$fill};
64 }
65  
66 0 ▶sub _fills {
Subroutine _fills: not called CC=2 SCAR=17.9
67 0 my ($self, $d, $cymbal) = @_;
68 0 ▶ $cymbal ||= $d->closed_hh;
Condition0%0/3
$cymbal ||= $d->closed_hh
l!l&&r!l&&!r
000
MC/DC0%0/2
$cymbal ||= $d->closed_hh
$cymbal $d->closed_hh
Truth table0%0/3
A ||= B
A= $cymbalB= $d->closed_hh
ABresult
1X1
011
000
69 my %fills = (
70  
71 1 => {
72 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
73 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
74 0 $d->note($d->sixteenth, $d->snare);
75 0 $d->note($d->triplet_eighth, $d->kick, $d->snare);
76 0 $d->note($d->triplet_eighth, $d->snare);
77 0 $d->note($d->triplet_eighth, $d->snare);
78 },
79 dura => dura_size($d->half),
80 },
81  
82 2 => {
83 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
84 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
85 0 $d->note($d->sixteenth, $d->snare);
86 0 $d->note($d->dotted_eighth, $d->snare);
87 0 $d->note($d->sixteenth, $d->kick, $cymbal);
88 },
89 dura => dura_size($d->half),
90 },
91  
92 3 => {
93 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
94 0 $d->note($d->eighth, $d->kick, $cymbal);
95 0 $d->note($d->triplet_sixteenth, $d->snare);
96 0 $d->note($d->triplet_sixteenth, $d->snare);
97 0 $d->note($d->triplet_sixteenth, $d->snare);
98 0 $d->note($d->dotted_eighth, $d->snare);
99 0 $d->note($d->sixteenth, $d->kick, $cymbal);
100 },
101 dura => dura_size($d->half),
102 },
103  
104 4 => {
105 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
106 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
107 0 $d->note($d->sixteenth, $d->snare);
108 0 $d->note($d->triplet_eighth, $d->kick, $d->snare);
109 0 $d->note($d->triplet_eighth, $d->snare);
110 0 $d->note($d->triplet_eighth, $d->snare);
111 0 $d->note($d->triplet_eighth, $d->kick, $d->snare);
112 0 $d->note($d->triplet_eighth, $d->snare);
113 0 $d->note($d->triplet_eighth, $d->snare);
114 0 $d->note($d->triplet_eighth, $d->kick, $d->snare);
115 0 $d->note($d->triplet_eighth, $d->snare);
116 0 $d->note($d->triplet_eighth, $d->snare);
117 },
118 dura => dura_size($d->whole),
119 },
120  
121 5 => {
122 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
123 0 $d->note($d->dotted_eighth, $d->kick, $d->snare, $cymbal);
124 0 $d->note($d->sixteenth, $cymbal);
125 0 $d->note($d->eighth, $d->kick, $cymbal);
126 0 $d->note($d->sixteenth, $d->snare);
127 0 $d->note($d->sixteenth, $d->snare);
128 0 $d->note($d->dotted_eighth, $d->snare);
129 0 $d->note($d->sixteenth, $d->kick, $cymbal);
130 },
131 dura => dura_size($d->dotted_half),
132 },
133  
134 6 => {
135 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
136 0 $d->note($d->dotted_eighth, $d->kick, $d->snare, $cymbal);
137 0 $d->note($d->sixteenth, $cymbal);
138 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
139 0 $d->note($d->sixteenth, $d->snare);
140 0 $d->note($d->dotted_eighth, $d->snare);
141 0 $d->note($d->sixteenth, $d->kick);
142 },
143 dura => dura_size($d->dotted_half),
144 },
145  
146 7 => {
147 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
148 0 $d->note($d->dotted_eighth, $d->snare, $cymbal);
149 0 $d->note($d->sixteenth, $d->snare, $cymbal);
150 0 $d->note($d->quarter, $d->snare, $cymbal);
151 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
152 0 $d->note($d->sixteenth, $d->kick);
153 },
154 dura => dura_size($d->dotted_half),
155 },
156  
157 8 => {
158 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
159 0 $d->note($d->dotted_eighth, $d->snare, $cymbal);
160 0 $d->note($d->sixteenth, $d->kick, $cymbal);
161 0 $d->note($d->quarter, $d->kick, $cymbal);
162 0 $d->note($d->dotted_eighth, $d->snare, $cymbal);
163 0 $d->note($d->sixteenth, $d->kick, $cymbal);
164 },
165 dura => dura_size($d->dotted_half),
166 },
167  
168 9 => {
169 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
170 0 my $initial = 49;
171 0 my $range = 39;
172 0 my $step = sprintf '%.0f', $range / 9;
173 0 my $n = 0;
174 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
175 0 $d->note($d->sixteenth, $d->snare);
176 0 $d->note($d->triplet_eighth, $d->kick, $d->snare, 'v' . ($initial + ($n++ * $step)));
177 0 $d->note($d->triplet_eighth, $d->snare, 'v' . ($initial + ($n++ * $step)));
178 0 $d->note($d->triplet_eighth, $d->snare, 'v' . ($initial + ($n++ * $step)));
179 0 $d->note($d->triplet_eighth, $d->kick, $d->snare, 'v' . ($initial + ($n++ * $step)));
180 0 $d->note($d->triplet_eighth, $d->snare, 'v' . ($initial + ($n++ * $step)));
181 0 $d->note($d->triplet_eighth, $d->snare, 'v' . ($initial + ($n++ * $step)));
182 0 $d->note($d->triplet_eighth, $d->kick, $d->snare, 'v' . ($initial + ($n++ * $step)));
183 0 $d->note($d->triplet_eighth, $d->snare, 'v' . ($initial + ($n++ * $step)));
184 0 $d->note($d->triplet_eighth, $d->snare, 'v' . ($initial + ($n++ * $step)));
185 },
186 dura => dura_size($d->whole),
187 },
188  
189 10 => {
190 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
191 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
192 0 $d->note($d->sixteenth, $d->snare);
193 0 $d->note($d->dotted_eighth, $d->snare, $cymbal);
194 0 $d->note($d->sixteenth, $d->kick, $cymbal);
195 0 $d->note($d->dotted_eighth, $d->snare, $cymbal);
196 0 $d->note($d->sixteenth, $d->snare);
197 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
198 0 $d->note($d->sixteenth, $cymbal);
199 },
200 dura => dura_size($d->whole),
201 },
202  
203 11 => {
204 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
205 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
206 0 $d->note($d->sixteenth, $d->snare);
207 0 $d->note($d->dotted_eighth, $d->snare, $cymbal);
208 0 $d->note($d->sixteenth, $d->kick, $cymbal);
209 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
210 0 $d->note($d->sixteenth, $d->snare);
211 0 $d->note($d->dotted_eighth, $d->snare, $cymbal);
212 0 $d->note($d->sixteenth, $d->kick, $cymbal);
213 },
214 dura => dura_size($d->whole),
215 },
216  
217 12 => {
218 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
219 0 $d->note($d->dotted_eighth, $d->snare, $cymbal);
220 0 $d->note($d->sixteenth, $d->kick);
221 0 $d->note($d->dotted_eighth, $cymbal);
222 0 $d->note($d->sixteenth, $d->snare, $cymbal);
223 0 $d->note($d->quarter, $d->kick, $cymbal);
224 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
225 0 $d->note($d->sixteenth, $cymbal);
226 },
227 dura => dura_size($d->whole),
228 },
229  
230 13 => {
231 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
232 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
233 0 $d->note($d->sixteenth, $d->snare);
234 0 $d->note($d->triplet_eighth, $d->snare);
235 0 $d->note($d->triplet_eighth, $d->snare);
236 0 $d->note($d->triplet_eighth, $d->snare);
237 0 $d->note($d->dotted_eighth, $d->snare);
238 0 $d->note($d->sixteenth, $d->kick);
239 0 $d->note($d->quarter, $d->kick);
240 },
241 dura => dura_size($d->whole),
242 },
243  
244 14 => {
245 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
246 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
247 0 $d->note($d->sixteenth, $d->snare);
248 0 $d->note($d->dotted_eighth, $cymbal);
249 0 $d->note($d->sixteenth, $d->snare, $cymbal);
250 0 $d->note($d->dotted_eighth, $cymbal);
251 0 $d->note($d->sixteenth, $d->kick);
252 0 $d->note($d->dotted_eighth, $cymbal);
253 0 $d->note($d->sixteenth, $d->kick);
254 },
255 dura => dura_size($d->whole),
256 },
257  
258 15 => {
259 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
260 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
261 0 $d->note($d->sixteenth, $d->snare);
262 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
263 0 $d->note($d->sixteenth, $d->snare, $cymbal);
264 0 $d->note($d->quarter, $d->kick, $cymbal);
265 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
266 0 $d->note($d->sixteenth, $d->snare, $cymbal);
267 },
268 dura => dura_size($d->whole),
269 },
270  
271 16 => {
272 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
273 0 $d->note($d->triplet_eighth, $d->kick, $d->snare, $cymbal);
274 0 $d->rest($d->triplet_eighth);
275 0 $d->note($d->triplet_eighth, $cymbal);
276 0 $d->note($d->triplet_eighth, $d->kick, $cymbal);
277 0 $d->rest($d->triplet_eighth);
278 0 $d->note($d->triplet_eighth, $d->snare);
279 0 $d->note($d->triplet_eighth, $d->kick, $cymbal);
280 0 $d->note($d->triplet_eighth, $d->snare);
281 0 $d->note($d->triplet_eighth, $d->snare, $cymbal);
282 },
283 dura => dura_size($d->dotted_half),
284 },
285  
286 17 => {
287 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
288 0 $d->note($d->dotted_eighth, $d->kick, $d->snare, $cymbal);
289 0 $d->note($d->sixteenth, $cymbal);
290 0 $d->note($d->quarter, $d->kick, $cymbal);
291 0 $d->note($d->triplet_sixteenth, $d->snare);
292 0 $d->note($d->triplet_sixteenth, $d->snare);
293 0 $d->note($d->triplet_sixteenth, $d->snare);
294 0 $d->note($d->dotted_eighth, $d->snare);
295 0 $d->note($d->sixteenth, $d->kick);
296 },
297 dura => dura_size($d->dotted_half),
298 },
299  
300 18 => {
301 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
302 0 $d->note($d->triplet_eighth, $d->kick, $cymbal);
303 0 $d->note($d->triplet_eighth, $d->snare);
304 0 $d->rest($d->triplet_eighth);
305 0 $d->note($d->triplet_eighth, $d->snare, $cymbal);
306 0 $d->rest($d->triplet_eighth);
307 0 $d->note($d->triplet_eighth, $d->snare, $cymbal);
308 0 $d->note($d->triplet_eighth, $d->snare, $cymbal);
309 0 $d->note($d->triplet_eighth, $d->kick);
310 0 $d->rest($d->triplet_eighth);
311 0 $d->note($d->triplet_eighth, $d->kick, $cymbal);
312 0 $d->rest($d->triplet_eighth);
313 0 $d->note($d->triplet_eighth, $d->kick, $cymbal);
314 },
315 dura => dura_size($d->dotted_half),
316 },
317  
318 19 => {
319 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
320 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
321 0 $d->note($d->sixteenth, $d->snare);
322 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
323 0 $d->note($d->sixteenth, $cymbal);
324 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
325 0 $d->note($d->sixteenth, $d->snare);
326 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
327 0 $d->note($d->sixteenth, $d->snare, $cymbal);
328 },
329 dura => dura_size($d->whole),
330 },
331  
332 20 => {
333 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
334 0 $d->flam($d->triplet_eighth, $d->snare);
335 0 $d->note($d->triplet_eighth, $d->kick);
336 0 $d->note($d->triplet_eighth, $d->kick);
337 0 $d->flam($d->triplet_eighth, $d->snare);
338 0 $d->note($d->triplet_eighth, $d->kick);
339 0 $d->note($d->triplet_eighth, $d->kick);
340 },
341 dura => dura_size($d->half),
342 },
343  
344 21 => {
345 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
346 0 $d->note($d->triplet_eighth, $d->kick);
347 0 $d->flam($d->triplet_eighth, $d->snare);
348 0 $d->note($d->triplet_eighth, $d->kick);
349 0 $d->flam($d->triplet_eighth, $d->snare);
350 0 $d->note($d->triplet_eighth, $d->kick);
351 0 $d->flam($d->triplet_eighth, $d->snare);
352 0 $d->note($d->triplet_eighth, $d->kick);
353 0 $d->flam($d->triplet_eighth, $d->snare);
354 0 $d->note($d->triplet_eighth, $d->kick);
355 0 $d->flam($d->triplet_eighth, $d->snare);
356 0 $d->note($d->triplet_eighth, $d->kick);
357 0 $d->note($d->triplet_eighth, $d->kick);
358 },
359 dura => dura_size($d->whole),
360 },
361  
362 22 => {
363 0 ▶ fill => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
364 0 $d->note($d->dotted_eighth, $d->kick, $cymbal);
365 0 $d->note($d->sixteenth, $d->snare);
366 0 $d->flam($d->triplet_eighth, $d->kick, $d->snare);
367 0 $d->flam($d->triplet_eighth, $d->snare);
368 0 $d->flam($d->triplet_eighth, $d->snare);
369 0 $d->note($d->dotted_eighth, $d->kick, $d->snare);
370 0 $d->note($d->sixteenth, $d->hi_tom);
371 0 $d->flam($d->triplet_eighth, $d->kick, $d->hi_tom);
372 0 $d->flam($d->triplet_eighth, $d->hi_tom);
373 0 $d->flam($d->triplet_eighth, $d->hi_tom);
374 },
375 0 dura => dura_size($d->whole),
376 },
377  
378 );
379 0 return \%fills;
380 }
381  
382 1 1;
383  
384 __END__
« Tiny/Grooves.pm ↑ Summary Tiny/Types.pm »