-
Notifications
You must be signed in to change notification settings - Fork 5
/
tabla
96 lines (85 loc) · 1.91 KB
/
tabla
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env perl
use strict;
use warnings;
# $ cat ~/timidity.cfg
# dir /home/YOU/Music
# # https://gleitz.github.io/midi-js-soundfonts/Tabla/Tabla.sf2
# soundfont Tabla.sf2
#
# $ rm -f tabla.mid
# $ perl tabla 8 100 1
# $ timidity -c ~/timidity.cfg tabla.mid
use lib map { "$ENV{HOME}/sandbox/$_/lib" } qw(MIDI-Drummer-Tiny Music-Duration-Partition); # local author libraries
use MIDI::Drummer::Tiny;
use Music::Duration::Partition;
my $bars = shift || 8;
my $bpm = shift || 100;
my $motifs = shift || 2;
my @notes = (60 .. 87);
# Find a tabla player...
my $d = MIDI::Drummer::Tiny->new(
file => "$0.mid",
bpm => $bpm,
channel => 0,
volume => 127,
);
$d->sync(
\&tabla,
\&tabla,
);
$d->write;
sub tabla {
# Instantiate a new phrase maker
my $mdp = Music::Duration::Partition->new(
size => 5,
pool => [qw(qn en tqn sn)],
weights => [ 5, 10, 5, 5 ],
groups => [ 1, 2, 3, 4 ],
);
# Generate rhythmic phrases
my @motifs = map { $mdp->motif } 1 .. $motifs;
# For each measure...
for my $n (1 .. $bars) {
# Choose a motif
my $motif = $motifs[ $n % @motifs ];
# Play the fill motif
for my $i (0 .. $#$motif) {
# Choose a random note
my $note = $notes[ int rand @notes ];
# Add the motif-note to the score
$d->note($motif->[$i], $note);
}
}
}
__END__
...
1 60 ringing mid
2 61 muted low
3 62 slap
4 63 ringing mid slap
5 64 low knock
6 65 muted ringing low
7 66 lower
8 67 low-up
9 68 muted slap
10 69 ringing low
11 70 flam slap
12 71 loud tap
13 72 lowest mute
14 73 ringing low
15 74 muted low
16 75 loud tap double
17 76 high-low
18 77 high slap
19 78 tap
20 79 high knock
21 80 short low-up
22 81 mid tap
23 82 muted tap
24 83 mid
25 84 muted
26 85 loud mid double
27 86 slightly more muted
28 87 low mid
29 88 ringing mid
...