Skip to content

Commit

Permalink
Fix GH#23063: (import) MusicXML alter element not exported
Browse files Browse the repository at this point in the history
Backport of musescore#25024
  • Loading branch information
pacebes authored and Jojo-Schmitz committed Oct 3, 2024
1 parent dd26cd2 commit 3aaafd3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions importexport/musicxml/importmxmlnotepitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ void mxmlNotePitch::pitch(QXmlStreamReader& e)
// defaults
_step = -1;
_alter = 0;
_tuning = 0.0;
_octave = -1;

while (e.readNextStartElement()) {
Expand All @@ -123,6 +124,10 @@ void mxmlNotePitch::pitch(QXmlStreamReader& e)
if (ok2 && (qAbs(altervalue) < 2.0) && (_accType == AccidentalType::NONE)) {
// try to see if a microtonal accidental is needed
_accType = microtonalGuess(altervalue);

// If it's not a microtonal accidental we will use tuning
if (_accType == AccidentalType::NONE)
_tuning = 100 * altervalue;
}
_alter = 0;
}
Expand Down
2 changes: 2 additions & 0 deletions importexport/musicxml/importmxmlnotepitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class mxmlNotePitch
Accidental* acc() const { return _acc; }
AccidentalType accType() const { return _accType; }
int alter() const { return _alter; }
qreal tuning() const { return _tuning; }
int displayOctave() const { return _displayOctave; }
int displayStep() const { return _displayStep; }
void displayStepOctave(QXmlStreamReader& e);
Expand All @@ -48,6 +49,7 @@ class mxmlNotePitch
Accidental* _acc = 0; // created based on accidental element
AccidentalType _accType = AccidentalType::NONE; // set by pitch() based on alter value (can be microtonal)
int _alter = 0;
qreal _tuning = 0.0;
int _displayStep = -1; // invalid
int _displayOctave = -1; // invalid
int _octave = -1;
Expand Down
7 changes: 4 additions & 3 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ static int MusicXMLStepAltOct2Pitch(int step, int alter, int octave)
Note that n's staff and track have not been set yet
*/

static void xmlSetPitch(Note* n, int step, int alter, int octave, const int octaveShift, const Instrument* const instr, Interval inferredTranspose = Interval(0))
static void xmlSetPitch(Note* n, int step, int alter, qreal tuning, int octave, const int octaveShift, const Instrument* const instr, Interval inferredTranspose = Interval(0))
{
//qDebug("xmlSetPitch(n=%p, step=%d, alter=%d, octave=%d, octaveShift=%d)",
// n, step, alter, octave, octaveShift);
Expand All @@ -258,6 +258,7 @@ static void xmlSetPitch(Note* n, int step, int alter, int octave, const int octa
tpc2 = Ms::transposeTpc(tpc2, inferredTranspose, true);
int tpc1 = Ms::transposeTpc(tpc2, combinedIntval, true);
n->setPitch(pitch, tpc1, tpc2);
n->setTuning(tuning);
//qDebug(" pitch=%d tpc1=%d tpc2=%d", n->pitch(), n->tpc1(), n->tpc2());
}

Expand Down Expand Up @@ -5946,11 +5947,11 @@ static void setPitch(Note* note, MusicXMLParserPass1& pass1, const QString& part
}
else {
//qDebug("disp step %d oct %d", displayStep, displayOctave);
xmlSetPitch(note, mnp.displayStep(), 0, mnp.displayOctave(), 0, instrument);
xmlSetPitch(note, mnp.displayStep(), 0, 0.0, mnp.displayOctave(), 0, instrument);
}
}
else {
xmlSetPitch(note, mnp.step(), mnp.alter(), mnp.octave(), octaveShift, instrument, pass1.getMusicXmlPart(partId)._inferredTranspose);
xmlSetPitch(note, mnp.step(), mnp.alter(), mnp.tuning(), mnp.octave(), octaveShift, instrument, pass1.getMusicXmlPart(partId)._inferredTranspose);
}
}

Expand Down

0 comments on commit 3aaafd3

Please sign in to comment.