Skip to content
Snippets Groups Projects
Commit c6aeb153 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Handle beam starts with the first note rather than at top-level

Otherwise tuplet handling will need to explicitly check for a beam start...
parent 201e9e75
No related branches found
No related tags found
No related merge requests found
......@@ -255,6 +255,10 @@ sub parse_notes {
$notes =~ s/(xx|x|bb|b|n)qq/qq$1/gs; # qq first, then parts of notes
$notes =~ s/([\.\d,'xbn])+(q|g)/$2$1/gs; # q and g first, then parts of notes
# Beam starts/endings are handled by the first/last note of the beam, since
# we need to know for the first note the <beam>begin</beam> and for the
# last note that the <beam>end</beam> tag should be used!
# Thus, the RegExp for a note contains the beam start/end tags { and }
while ($notes ne "") {
if ($notes =~ /^(\'+|\,+)(.*)$/) { # Octave marks
($oct, $notes) = ($1, $2);
......@@ -265,12 +269,6 @@ sub parse_notes {
} elsif ($notes =~ /^r(.*)$/) { # End grace
$notes = $1;
$qq = 0;
} elsif ($notes =~ /^{(.*)$/) { # Begin beam
$notes = $1;
$BEAM = 1;
# Beam endings are handled by the last note of the beam, since
# we need to know for the last note that the <beam>end</beam> tag
# should be used!
} elsif ($notes =~ /^\=(\d*)(\/.*)$/) { # multi-measure rests
$measrest = $1;
$notes = $2;
......@@ -306,23 +304,23 @@ sub parse_notes {
}
}
}
} elsif ($notes =~ /^((\^)?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?)(.*)$/) { # a note
} elsif ($notes =~ /^({?(\^)?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?)(.*)$/) { # a note
($note, $notes) = ($1,$7);
parse_note($note, $keysig, "", "", $qq);
} elsif ($notes =~ /^(\((g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)[t\+]*\)[t\+}]*)(.*)$/) { # one note with a fermata
} elsif ($notes =~ /^({?\((g|q)?{?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)[t\+]*\)[t\+}]*)(.*)$/) { # one note with a fermata
($note, $notes) = ($1,$6);
parse_note($note, $keysig, "", "", $qq);
} elsif ($notes =~ /^(\(((\^)?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?){3}\))(.*)$/) { # a triplet
} elsif ($notes =~ /^(\(({?(\^)?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?){3}\))(.*)$/) { # a triplet
($triplet, $notes) = ($1,$8);
# print "TRIPLET: ".$triplet." -> ";
$triplet =~ /^\(((\^)?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?)(.*)\)$/gs;
$triplet =~ /^\(({?(\^)?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?)(.*)\)$/gs;
($note, $triplet) = ($1,$7);
#print "$note $triplet\n";
parse_note($note, $keysig, '<tuplet type="start"/>', ' <time-modification>
<actual-notes>3</actual-notes>
<normal-notes>2</normal-notes>
</time-modification>', $qq);
$triplet =~ /^((g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?)(.*)$/gs;
$triplet =~ /^({?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?)(.*)$/gs;
($note, $triplet) = ($1,$6);
#print "$note $triplet\n";
parse_note($note, $keysig, '', ' <time-modification>
......@@ -333,10 +331,10 @@ sub parse_notes {
<actual-notes>3</actual-notes>
<normal-notes>2</normal-notes>
</time-modification>', $qq);
} elsif ($notes =~ /^((\d+)\(((\^)?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?)+\;(\d+)\))(.*)$/) { # an n-tuplet
} elsif ($notes =~ /^((\d+)\(({?(\^)?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?)+\;(\d+)\))(.*)$/) { # an n-tuplet
($tuplet, $notes) = ($1,$10);
# print "N-TUPLET: ".$tuplet." -> ";
$tuplet =~ /^(\d+)\(((\,|\')*(x|xx|b|bb|n)?\d*\.*(g|q)?(\-|A|B|C|D|E|F|G)t?\+?}?)(.*);(\d)\)$/gs;
$tuplet =~ /^(\d+)\(({?(\,|\')*(x|xx|b|bb|n)?\d*\.*(g|q)?(\-|A|B|C|D|E|F|G)t?\+?}?)(.*);(\d)\)$/gs;
($combdur, $note, $tuplet, $numval) = ($1,$2,$7,$8);
#print "i=$combdur, n=$numval; $note / $tuplet\n";
my $ind_dur = duration($combdur)/$numval;
......@@ -346,7 +344,7 @@ sub parse_notes {
<actual-notes>'.$act_notes.'</actual-notes>
<normal-notes>1</normal-notes>
</time-modification>', $qq);
while ($tuplet =~ /^((g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?)(.+)$/gs) {
while ($tuplet =~ /^({?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?\}?)([^}]+}?)$/gs) {
($note, $tuplet) = ($1,$6);
#print "$note / $tuplet\n";
parse_note($note, $keysig, '', ' <time-modification>
......@@ -446,7 +444,7 @@ sub parse_notes {
</note>
';
}
elsif ($notes =~ s/(\d+\.*)\(((g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?)\)/\($1$2\)/gs) { # pull duration into fermata parentheses
elsif ($notes =~ s/(\d+\.*)\(({?(g|q)?(\,|\')*(x|xx|b|bb|n)?\d*\.*(\-|A|B|C|D|E|F|G)t?\+?}?)\)/\($1$2\)/gs) { # pull duration into fermata parentheses
# print "after replacement: $notes\n"; exit;
}
elsif ($notes =~ /^ +(.*)$/) {
......@@ -480,8 +478,8 @@ sub parse_note {
$fermata = 1;
}
$note =~ /^(\^)?(g|q)?((\,|\')*)(x|xx|b|bb|n)?(\d*)(\.*)(\-|A|B|C|D|E|F|G)(t?)(\+?)(}?)$/;
my ($chord, $gracecue, $oct, $acc, $dur, $dot, $pitch, $trill, $tie, $beamend) = ($1, $2, $3, $5, $6, $7, $8, $9, $10, $11);
$note =~ /^({)?(\^)?(g|q)?((\,|\')*)(x|xx|b|bb|n)?(\d*)(\.*)(\-|A|B|C|D|E|F|G)(t?)(\+?)(}?)$/;
my ($beamstart, $chord, $gracecue, $oct, $acc, $dur, $dot, $pitch, $trill, $tie, $beamend) = ($1, $2, $3, $4, $6, $7, $8, $9, $10, $11, $12);
print OUT ' <note>
';
......@@ -544,14 +542,17 @@ sub parse_note {
print OUT $addition;
# print out beaming information if needed:
if ($BEAM == 1) {
print OUT " <beam>begin</beam>\n";
$BEAM = 2;
if (($beamstart eq "{") && ($beamend eq "}")) {
# Single-note beam means a hook
print OUT " <beam>forward hook</beam>\n";
} elsif ($beamstart eq "{") {
++$BEAM;
print OUT " <beam number=\"$BEAM\">begin</beam>\n";
} elsif (($BEAM > 0) && ($beamend eq "}")) {
print OUT " <beam>end</beam>\n";
$BEAM = 0;
print OUT " <beam number=\"$BEAM\">end</beam>\n";
--$BEAM;
} elsif ($BEAM > 0) {
print OUT " <beam>continue</beam>\n";
print OUT " <beam number=\"$BEAM\">continue</beam>\n";
}
my $notationbracket = $fermata || $tienotation || ($trill eq "t") || ($notation ne "");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment