Skip to content

Commit

Permalink
Hack to hopefully improve partial bar situation.
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Sep 24, 2012
1 parent d916fde commit f66e5b6
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions bin/abc2ly
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ class TuneConvertor {
~ " "; ~ " ";
} }


method WrapBar($lilypond-bar, $duration) { method WrapBar($lilypond-bar, $duration, :$beginning?) {
my $ticks-in-measure = $.context.ticks-in-measure; my $ticks-in-measure = $.context.ticks-in-measure;
my $result = ""; my $result = "";
if $duration % $ticks-in-measure != 0 { if $beginning && $duration % $ticks-in-measure != 0 {
my $note-length = 1 / $.context.length; my $note-length = 1 / $.context.length;
my $count = $duration % $ticks-in-measure; my $count = $duration % $ticks-in-measure;
if $count ~~ Rat { if $count ~~ Rat {
Expand All @@ -181,7 +181,8 @@ class TuneConvertor {
$result ~ $lilypond-bar; $result ~ $lilypond-bar;
} }


method SectionToLilypond(@elements, $out) { method SectionToLilypond(@elements, $out, :$beginning?) {
my $first-time = $beginning // False;
my $notes = ""; my $notes = "";
my $lilypond = ""; my $lilypond = "";
my $duration = 0; my $duration = 0;
Expand Down Expand Up @@ -235,7 +236,8 @@ class TuneConvertor {
} }
} }
when "barline" { when "barline" {
$notes ~= self.WrapBar($lilypond, $duration); $notes ~= self.WrapBar($lilypond, $duration, :beginning($first-time));
$first-time = False;
if $element.value eq "||" { if $element.value eq "||" {
$notes ~= ' \\bar "||"'; $notes ~= ' \\bar "||"';
} else { } else {
Expand Down Expand Up @@ -313,7 +315,8 @@ class TuneConvertor {
} }


$out.say: "\{"; $out.say: "\{";
$notes ~= self.WrapBar($lilypond, $duration); $notes ~= self.WrapBar($lilypond, $duration, :beginning($first-time));
$first-time = False;
$out.say: $notes; $out.say: $notes;
$out.say: " \}"; $out.say: " \}";
} }
Expand All @@ -334,7 +337,7 @@ class TuneConvertor {
|| @elements[$i].value eq ':|:' | ':|' | '::' { || @elements[$i].value eq ':|:' | ':|' | '::' {
$out.print: "\\repeat volta 2 "; # 2 is abitrarily chosen here! $out.print: "\\repeat volta 2 "; # 2 is abitrarily chosen here!
} }
self.SectionToLilypond(@elements[$start-of-section ..^ $i], $out); self.SectionToLilypond(@elements[$start-of-section ..^ $i], $out, :beginning);
$start-of-section = $i + 1; $start-of-section = $i + 1;
given @elements[$i].value { given @elements[$i].value {
when '||' { $out.say: '\\bar "||"'; } when '||' { $out.say: '\\bar "||"'; }
Expand Down Expand Up @@ -375,7 +378,7 @@ class TuneConvertor {
if @elements[*-1].value eq ':|:' | ':|' | '::' { if @elements[*-1].value eq ':|:' | ':|' | '::' {
$out.print: "\\repeat volta 2 "; # 2 is abitrarily chosen here! $out.print: "\\repeat volta 2 "; # 2 is abitrarily chosen here!
} }
self.SectionToLilypond(@elements[$start-of-section ..^ +@elements], $out); self.SectionToLilypond(@elements[$start-of-section ..^ +@elements], $out, :beginning);
if @elements[*-1].value eq '|]' { if @elements[*-1].value eq '|]' {
$out.say: '\\bar "|."'; $out.say: '\\bar "|."';
} }
Expand Down Expand Up @@ -430,6 +433,10 @@ multi sub MAIN($first-abc-file, *@other-abc-files) {


TuneStreamToLilypondStream($in, $out); TuneStreamToLilypondStream($in, $out);


# $out.say: '\markup {';
# $out.say: ' "For more information on these tunes, please see http://midlandceltic.org/ws2011/"';
# $out.say: '}';

$out.close; $out.close;
$in.close; $in.close;
} }
Expand Down

0 comments on commit f66e5b6

Please sign in to comment.