Skip to content

Commit

Permalink
Merge pull request #25024 from pacebes/23063-importMusicXMLAlterEleme…
Browse files Browse the repository at this point in the history
…ntNotExported

Fix #23063: (import) MusicXML alter element not exported
  • Loading branch information
miiizen authored Oct 3, 2024
2 parents 4292347 + 9f52257 commit 3d73b53
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ void MxmlNotePitch::pitch(muse::XmlStreamReader& e)
// defaults
m_step = -1;
m_alter = 0;
m_tuning = 0.0;
m_octave = -1;

while (e.readNextStartElement()) {
Expand All @@ -143,6 +144,11 @@ void MxmlNotePitch::pitch(muse::XmlStreamReader& e)
if (ok2 && (std::abs(altervalue) < 2.0) && (m_accType == AccidentalType::NONE)) {
// try to see if a microtonal accidental is needed
m_accType = microtonalGuess(altervalue);

// If it's not a microtonal accidental we will use tuning
if (m_accType == AccidentalType::NONE) {
m_tuning = 100 * altervalue;
}
}
m_alter = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class MxmlNotePitch
Accidental* acc() const { return m_acc; }
AccidentalType accType() const { return m_accType; }
int alter() const { return m_alter; }
double tuning() const { return m_tuning; }
int displayOctave() const { return m_displayOctave; }
int displayStep() const { return m_displayStep; }
void displayStepOctave(muse::XmlStreamReader& e);
Expand All @@ -59,6 +60,7 @@ class MxmlNotePitch
Accidental* m_acc = nullptr; // created based on accidental element
AccidentalType m_accType = AccidentalType::NONE; // set by pitch() based on alter value (can be microtonal)
int m_alter = 0;
double m_tuning = 0.0;
int m_displayStep = -1; // invalid
int m_displayOctave = -1; // invalid
int m_octave = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,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)
static void xmlSetPitch(Note* n, int step, int alter, double tuning, int octave, const int octaveShift, const Instrument* const instr)
{
//LOGD("xmlSetPitch(n=%p, step=%d, alter=%d, octave=%d, octaveShift=%d)",
// n, step, alter, octave, octaveShift);
Expand All @@ -289,6 +289,7 @@ static void xmlSetPitch(Note* n, int step, int alter, int octave, const int octa
int tpc2 = step2tpc(step, AccidentalVal(alter));
int tpc1 = mu::engraving::transposeTpc(tpc2, intval, true);
n->setPitch(pitch, tpc1, tpc2);
n->setTuning(tuning);
//LOGD(" pitch=%d tpc1=%d tpc2=%d", n->pitch(), n->tpc1(), n->tpc2());
}

Expand Down Expand Up @@ -6406,10 +6407,10 @@ static void setPitch(Note* note, const MusicXMLInstruments& instruments, const S
note->setTpc(pitch2tpc(unpitched, Key::C, Prefer::NEAREST)); // TODO: necessary ?
} else {
//LOGD("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);
xmlSetPitch(note, mnp.step(), mnp.alter(), mnp.tuning(), mnp.octave(), octaveShift, instrument);
}
}

Expand Down

0 comments on commit 3d73b53

Please sign in to comment.