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

Cache all alteration for the whole current measure, so that xCC displays e.g....

Cache all alteration for the whole current measure, so that xCC displays e.g. two Cis. Need to reset after each measure
parent 74a63894
No related branches found
No related tags found
No related merge requests found
...@@ -63,6 +63,11 @@ $old_duration = $divisions; ...@@ -63,6 +63,11 @@ $old_duration = $divisions;
$old_type = ""; $old_type = "";
$old_octave = 4; $old_octave = 4;
# Store all alterations already used in the current measure, so that e.g.
# xCC also detects the second note as a Cis! Needs to be reset at the
# beginning of a new bar.
%active_alterations = {};
($mday, $mon, $year) = (localtime()) [3..5]; ($mday, $mon, $year) = (localtime()) [3..5];
$encoding_date = sprintf("%4d-%02d-%02d", $year + 1900, $mon+1, $mday); $encoding_date = sprintf("%4d-%02d-%02d", $year + 1900, $mon+1, $mday);
...@@ -284,6 +289,7 @@ sub parse_notes { ...@@ -284,6 +289,7 @@ sub parse_notes {
'; ';
if ($n < $measrest) { if ($n < $measrest) {
print OUT " </measure>\n"; print OUT " </measure>\n";
reset_measure_attributes ();
if ($notes ne "") { if ($notes ne "") {
print OUT ' <measure number="'.$meas.'"> print OUT ' <measure number="'.$meas.'">
'; ';
...@@ -383,6 +389,7 @@ sub parse_notes { ...@@ -383,6 +389,7 @@ sub parse_notes {
'; ';
} }
print OUT " </measure>\n"; print OUT " </measure>\n";
reset_measure_attributes ();
if ($notes ne "") { if ($notes ne "") {
print OUT ' <measure number="'.$meas.'"> print OUT ' <measure number="'.$meas.'">
'; ';
...@@ -442,6 +449,7 @@ sub parse_notes { ...@@ -442,6 +449,7 @@ sub parse_notes {
} }
if ($mopen) { if ($mopen) {
print OUT " </measure>\n"; print OUT " </measure>\n";
reset_measure_attributes ();
} }
} }
...@@ -543,10 +551,24 @@ sub parse_note { ...@@ -543,10 +551,24 @@ sub parse_note {
$toprint .= "note: oct. $oct/acc. $acc/dur. $dur/dots $dot/grace,cue $gracecue/pitch $pitch\n"; $toprint .= "note: oct. $oct/acc. $acc/dur. $dur/dots $dot/grace,cue $gracecue/pitch $pitch\n";
} }
sub reset_measure_attributes {
%active_alterations = {};
# TODO: reset all measure-only attributes, like manual accidentals
}
sub alter { sub alter {
my ($pitch, $acc, $keysig) = @_; my ($pitch, $acc, $keysig) = @_;
my $alt = 0; my $alt = 0;
# If we had the same pitch with explicit alteration already in the current
# measure, that alteration goes on, unless the current note has an explicit
# alteration
if ($acc eq "") {
$acc = $active_alterations{$pitch};
} else {
# Store the explicit alteration of the current pitch!
$active_alterations{$pitch} = $acc;
}
if (index ($keysig,$pitch) > -1) { if (index ($keysig,$pitch) > -1) {
$keysig =~ /^(.).*$/gs; $keysig =~ /^(.).*$/gs;
......
Test Composer
Accidentals (c-cis-cis-cisis-ces-ceses-ceses-c/ces-as-bes-g-cis-aisis-beses-g/)
1.1.1: S accidentals
plain&easy: %G-2@c$ '8CxCCxxCbCbbCCnC/$bBEADGC 8CABnGxCxxAbbBG/BAGCxBAGB/
Test Library
00000000
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment