-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapplause.pl
More file actions
47 lines (39 loc) · 1 KB
/
applause.pl
File metadata and controls
47 lines (39 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env perl
use strict;
use warnings;
use MIDI::Drummer::Tiny ();
my $x = shift || 4;
my $y = shift || 4;
my $d = MIDI::Drummer::Tiny->new;
my @rows = map { row($_)->@* } 1 .. $y;
$d->sync(@rows);
use Data::Dumper::Compact qw(ddc);
warn __PACKAGE__,' L',__LINE__,' ',ddc([$d->score->Score], {max_width=>128});
$d->play_with_timidity;
# $d->write;
sub row {
my ($n) = @_;
my @subs;
for (1 .. $x) {
push @subs, sub {
my $bpm = random_item([70 .. 100]);
my $reverb = 15 + $n;
my $volume = 100 - $n;
my $mdt = MIDI::Drummer::Tiny->new(
score => $d->score,
setup => 0,
bpm => $bpm,
reverb => $reverb,
volume => $volume,
);
for (1 .. $mdt->beats) {
$mdt->note($mdt->quarter, $mdt->snare);
}
};
}
return \@subs;
}
sub random_item {
my ($items) = @_;
return $items->[ int rand @$items ];
}