Navigation Menu

Skip to content

Commit

Permalink
Add support for meters other than 4/4.
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Oct 23, 2010
1 parent 06b7722 commit e57f6a8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions bin/abc2ly.pl
Expand Up @@ -18,9 +18,10 @@

class Context {
has %.key;
has $.meter;

method new(%key) {
self.bless(*, :%key)
method new(%key, $meter) {
self.bless(*, :%key, :$meter);
}

method get-real-pitch($nominal-pitch) {
Expand All @@ -43,6 +44,10 @@

$match<basenote>.lc ~ %accidental-map{~$match<accidental>} ~ %octave-map{$octave};
}

method write-meter() {
print "\\time $.meter ";
}
}

sub HeaderToLilypond(ABC::Header $header) {
Expand Down Expand Up @@ -108,6 +113,7 @@ (Context $context, @elements)
sub BodyToLilypond(Context $context, $key, @elements) {
say "\{";
say "\\key $key \\major";
$context.write-meter;

my $start-of-section = 0;
my $duration-in-section = 0;
Expand Down Expand Up @@ -152,7 +158,8 @@ (Context $context, $key, @elements)
say '\\version "2.12.3"';
HeaderToLilypond($tune.header);
my $key = $tune.header.get("K")[0].value;
my $meter = $tune.header.get("M")[0].value;

BodyToLilypond(Context.new(key_signature($key)),
BodyToLilypond(Context.new(key_signature($key), $meter),
$key.comb(/./)[0].lc,
$tune.music);

0 comments on commit e57f6a8

Please sign in to comment.