forked from LastOfTheCarelessMen/ABC
-
Notifications
You must be signed in to change notification settings - Fork 5
/
dg-check.pl
38 lines (31 loc) · 880 Bytes
/
dg-check.pl
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
use v6;
BEGIN { push @*INC, "lib" }
use ABC;
my @matches = $*IN.slurp.comb(m/ <ABC::tune> /, :match);
my %dg_notes = {
'g' => 1,
'a' => 1,
'b' => 1,
'c' => 1,
'd' => 1,
'e' => 1,
'^f' => 1
}
for @matches {
my %header = header_hash(.<ABC::tune><header>);
say %header<T> ~ ":";
my @notes = gather for .<ABC::tune><music><line_of_music> -> $line
{
for $line<bar> -> $bar
{
for $bar<element>
{
when .<broken_rhythm> { take .<broken_rhythm><stem>[0]<note>; take .<broken_rhythm><stem>[1]<note>; }
when .<stem> { take .<stem><note>; }
}
}
}
my %key_signature = key_signature(%header<K>);
my @trouble = @notes.map({apply_key_signature(%key_signature, .<pitch>)}).grep({!%dg_notes.exists(lc($_))});
say @trouble.perl;
}