From dd26cd22d3a01dc5cb9e11f33e0ca80a7590e1ee Mon Sep 17 00:00:00 2001 From: Joachim Schmitz Date: Thu, 3 Oct 2024 19:37:19 +0200 Subject: [PATCH] Fix #311792, GH#23063: Override alter tag with note tuning value if present Code revivew issues from #25022, for #6693, that had been ported earlier --- importexport/musicxml/exportxml.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/importexport/musicxml/exportxml.cpp b/importexport/musicxml/exportxml.cpp index cf3a88c30535b..ab28c82980a49 100644 --- a/importexport/musicxml/exportxml.cpp +++ b/importexport/musicxml/exportxml.cpp @@ -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(); }