Skip to content

Commit 64b1f05

Browse files
infojunkieJojo-Schmitz
authored andcommitted
Fix #311792: Override alter tag with note tuning value if present
Duplicate of musescore#6693
1 parent 37238b4 commit 64b1f05

File tree

4 files changed

+850
-5
lines changed

4 files changed

+850
-5
lines changed

importexport/musicxml/exportxml.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3305,11 +3305,17 @@ static void writePitch(XmlWriter& xml, const Note* const note, const bool useDru
33053305
default: break;
33063306
}
33073307
}
3308-
if (alter && !alter2)
3309-
xml.tag("alter", alter);
3310-
if (!alter && alter2)
3311-
xml.tag("alter", alter2);
3312-
// TODO what if both alter and alter2 are present? For Example: playing with transposing instruments
3308+
// Override accidental with explicit note tuning
3309+
auto tuning = note->tuning();
3310+
if (fabs(tuning) > 0.01)
3311+
alter2 = tuning / 100.0;
3312+
// `alter` represents the "regular" (Western) pitch which can be
3313+
// 0 (natural), 1 (sharp), -1 (flat), etc. or some other integer depending on transposing instruments.
3314+
// `alter2` represents a microtone or manually-adjusted note tuning.
3315+
// In MusicXML, These two values are merged in the same "alter" tag.
3316+
// https://usermanuals.musicxml.com/MusicXML/Content/EL-MusicXML-alter.htm
3317+
if (alter || alter2)
3318+
xml.tag("alter", alter + alter2);
33133319
xml.tag(useDrumset ? "display-octave" : "octave", octave);
33143320
xml.etag();
33153321
}

0 commit comments

Comments
 (0)