Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 54 lines (45 sloc) 1.408 kB
7e3eca2 @LastOfTheCarelessMen First "working" playing.pl.
LastOfTheCarelessMen authored
1 use v6;
2
c08cd27 @LastOfTheCarelessMen Move the grammar to the ABC.pm file.
LastOfTheCarelessMen authored
3 BEGIN { push @*INC, "lib" }
4 use ABC;
5
7e3eca2 @LastOfTheCarelessMen First "working" playing.pl.
LastOfTheCarelessMen authored
6 my $abc = q«X:64
7 T:Cuckold Come Out o' the Amrey
8 S:Northumbrian Minstrelsy
9 M:4/4
10 L:1/8
11 K:D
12 A/B/c/A/ +trill+c>d e>deg | GG +trill+B>c d/B/A/G/ B/c/d/B/ |
13 A/B/c/A/ c>d e>deg | dB/A/ gB +trill+A2 +trill+e2 ::
a326b88 @LastOfTheCarelessMen Working early key signature framework.
LastOfTheCarelessMen authored
14 g>ecg ec e/=f/g/e/ | d/c/B/A/ Gd BG B/c/d/B/ |
7e3eca2 @LastOfTheCarelessMen First "working" playing.pl.
LastOfTheCarelessMen authored
15 g/f/e/d/ c/d/e/f/ gc e/f/g/e/ | dB/A/ gB +trill+A2 +trill+e2 :|»;
16
0aaec06 @LastOfTheCarelessMen playing.pl now has test code to go through a matched tune and pull ou…
LastOfTheCarelessMen authored
17 my $match = $abc ~~ m/ <ABC::tune> /;
18
19 die "Tune not matched\n" unless $match ~~ Match;
20
21 my @notes = gather for $match<ABC::tune><music><line_of_music> -> $line
7e3eca2 @LastOfTheCarelessMen First "working" playing.pl.
LastOfTheCarelessMen authored
22 {
0aaec06 @LastOfTheCarelessMen playing.pl now has test code to go through a matched tune and pull ou…
LastOfTheCarelessMen authored
23 for $line<bar> -> $bar
40667a5 @LastOfTheCarelessMen Successfully match and dump ABC header.
LastOfTheCarelessMen authored
24 {
0aaec06 @LastOfTheCarelessMen playing.pl now has test code to go through a matched tune and pull ou…
LastOfTheCarelessMen authored
25 for $bar<element>
26 {
27 when .<broken_rhythm> { take .<broken_rhythm><note>[0]; take .<broken_rhythm><note>[1]; }
28 when .<note> { take .<note>; }
29 }
40667a5 @LastOfTheCarelessMen Successfully match and dump ABC header.
LastOfTheCarelessMen authored
30 }
32c2cbc @LastOfTheCarelessMen Start to implement notes.
LastOfTheCarelessMen authored
31 }
32
a326b88 @LastOfTheCarelessMen Working early key signature framework.
LastOfTheCarelessMen authored
33 sub apply_key_signature(%key_signature, $pitch)
34 {
35 my $resulting_note = "";
36 if $pitch<accidental>
37 {
38 $resulting_note ~= $pitch<accidental>.Str;
39 }
40 else
41 {
42 $resulting_note ~= %key_signature{$pitch<basenote>.uc}
43 if (%key_signature.exists($pitch<basenote>.uc));
44 }
45 $resulting_note ~= $pitch<basenote>;
46 $resulting_note ~= $pitch<octave> if $pitch<octave>;
47 return $resulting_note;
48 }
49
50 my %header = header_hash($match<ABC::tune><header>);
51 my %key_signature = key_signature(%header<K>);
9b8264b @LastOfTheCarelessMen Closer to having working key signature code.
LastOfTheCarelessMen authored
52
a326b88 @LastOfTheCarelessMen Working early key signature framework.
LastOfTheCarelessMen authored
53 @notes.map({say .<pitch> ~ " => " ~ apply_key_signature(%key_signature, .<pitch>)});
Something went wrong with that request. Please try again.