Permalink
Browse files

Clean up a couple weird duration cases.

  • Loading branch information...
1 parent 69d70e7 commit b7a037d06938942509db1de858c4e1d3457e6d27 @colomon committed May 19, 2012
Showing with 4 additions and 1 deletion.
  1. +3 −0 bin/abc2ly.pl
  2. +1 −1 lib/ABC/Duration.pm
View
@@ -203,6 +203,9 @@ (ABC::Header $header, $out)
my $note-length = 1 / $.context.length.eval;
my $count = $duration % $ticks-in-measure;
if $count ~~ Rat {
+ my $log2 = $count.denominator.log(2);
+ die "Strange partial measure found: $lilypond-bar" if $log2 != $log2.Int;
+
while $count.denominator > 1 {
$note-length *= 2; # makes twice as short
$count *= 2; # makes twice as long
View
@@ -18,7 +18,7 @@ role ABC::Duration {
when 1 { ""; }
when 1/2 { "/"; }
when Int { .Str; }
- when Rat { $_.numerator ~ "/" ~ $_.denominator; }
+ when Rat { $_.denominator == 1 ?? ~$_.numerator !! $_.numerator ~ "/" ~ $_.denominator; }
die "Duration must be Int or Rat, but it's { .WHAT }";
}
}

0 comments on commit b7a037d

Please sign in to comment.