Skip to content

Commit

Permalink
Fix #311792, GH#23063: Override alter tag with note tuning value if p…
Browse files Browse the repository at this point in the history
…resent

Code revivew issues from musescore#25022, for musescore#6693, that had been ported earlier
  • Loading branch information
Jojo-Schmitz committed Oct 3, 2024
1 parent 0eccb13 commit dd26cd2
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3824,27 +3824,22 @@ static void writePitch(XmlWriter& xml, const Note* const note, const bool useDru
xml.tag(useDrumset ? "display-step" : "step", step);
// Check for microtonal accidentals and overwrite "alter" tag
const Accidental* acc = note->accidental();
double alter2 = 0.0;
double microtonalAlter = 0.0;
if (acc) {
switch (acc->accidentalType()) {
case AccidentalType::MIRRORED_FLAT: alter2 = -0.5; break;
case AccidentalType::SHARP_SLASH: alter2 = 0.5; break;
case AccidentalType::MIRRORED_FLAT2: alter2 = -1.5; break;
case AccidentalType::SHARP_SLASH4: alter2 = 1.5; break;
default: break;
case AccidentalType::MIRRORED_FLAT: microtonalAlter = -0.5; break;
case AccidentalType::SHARP_SLASH: microtonalAlter = 0.5; break;
case AccidentalType::MIRRORED_FLAT2: microtonalAlter = -1.5; break;
case AccidentalType::SHARP_SLASH4: microtonalAlter = 1.5; break;
default: break;
}
}
// Override accidental with explicit note tuning
qreal tuning = note->tuning();
if (fabs(tuning) > 0.01)
alter2 = tuning / 100.0;
// `alter` represents the "regular" (Western) pitch which can be
// 0 (natural), 1 (sharp), -1 (flat), etc. or some other integer depending on transposing instruments.
// `alter2` represents a microtone or manually-adjusted note tuning.
// In MusicXML, These two values are merged in the same "alter" tag.
// https://usermanuals.musicxml.com/MusicXML/Content/EL-MusicXML-alter.htm
if (alter || alter2)
xml.tag("alter", alter + alter2);
if (!qFuzzyIsNull(tuning))
microtonalAlter = tuning / 100.0;
if (alter || microtonalAlter )
xml.tag("alter", alter + microtonalAlter );
xml.tag(useDrumset ? "display-octave" : "octave", octave);
xml.etag();
}
Expand Down

0 comments on commit dd26cd2

Please sign in to comment.