Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 44 lines (35 sloc) 1.113 kB
053cc8a @colomon Start coding abctranspose, by simply reading the file and writing it …
authored
1 use v6;
2 use ABC::Header;
3 use ABC::Tune;
4 use ABC::Grammar;
5 use ABC::Actions;
6 use ABC::Duration; #OK
7 use ABC::Note;
8 use ABC::LongRest;
9 use ABC::Utils;
10
11 sub print-header($out, $header) {
12 for $header.lines -> $header-line {
13 say $header-line.key ~ ":" ~ $header-line.value;
14 }
15 }
16
d13c7ad @colomon Try to start setting up framework for transposition.
authored
17 sub print-music($out, @music) {
18 for @music -> $element {
053cc8a @colomon Start coding abctranspose, by simply reading the file and writing it …
authored
19 print ElementToStr($element);
20 }
21 }
22
23 sub Transpose($in, $out) {
24 my $actions = ABC::Actions.new;
25 my $match = ABC::Grammar.parse($in.slurp, :rule<tune_file>, :$actions);
26 die "Did not match ABC grammar: last tune understood:\n { $actions.current-tune }" unless $match;
27
28 for @( $match.ast ) -> $tune {
29 $*ERR.say: "Working on { $tune.header.get-first-value("T") // $tune.header.get-first-value("X") }";
30
31 print-header($out, $tune.header);
32
33 # my $key = $tune.header.get-first-value("K");
34 # my $meter = $tune.header.get-first-value("M");
35 # my $length = $tune.header.get-first-value("L") // "1/8";
36
d13c7ad @colomon Try to start setting up framework for transposition.
authored
37 print-music($out, $tune.music);
053cc8a @colomon Start coding abctranspose, by simply reading the file and writing it …
authored
38 }
39 }
40
41 multi sub MAIN() {
42 Transpose($*IN, $*OUT);
43 }
Something went wrong with that request. Please try again.