-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex-04-03.pl
More file actions
44 lines (34 loc) · 796 Bytes
/
Copy pathex-04-03.pl
File metadata and controls
44 lines (34 loc) · 796 Bytes
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
#!/usr/bin/env perl
use strict;
use warnings;
use MIDI::Util qw(setup_score set_chan_patch);
use Music::Scales qw(get_scale_MIDI);
my $score = setup_score(bpm => 120, volume => 120);
$score->synch(
\&bass,
\&treble,
) for 1 .. 4;
$score->write_score("$0.mid");
sub bass {
set_chan_patch($score, 0, 35);
my @pitches = (
get_scale_MIDI('C', 2, 'pentatonic'),
# get_scale_MIDI('C', 3, 'pentatonic'),
);
for my $n (1 .. 4) {
my $pitch = $pitches[int rand @pitches];
$score->n('hn', $pitch);
}
}
sub treble {
set_chan_patch($score, 1, 0);
my @pitches = (
get_scale_MIDI('C', 4, 'major'),
get_scale_MIDI('C', 5, 'major'),
);
for my $n (1 .. 4) {
my $pitch = $pitches[int rand @pitches];
$score->n('qn', $pitch);
$score->r('qn');
}
}