Skip to content

Commit b518263

Browse files
committed
update Musicxml pull parser 3
1 parent e2460bc commit b518263

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

mscore/importmxmlpass2.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,22 +1764,22 @@ static void markUserAccidentals(const int firstStaff,
17641764
AccidentalVal currAccVal = currAcc.accidentalVal(ln);
17651765
if ((alter == -1
17661766
&& currAccVal == AccidentalVal::FLAT
1767-
&& nt->accidental()->accidentalType() == Accidental::Type::FLAT
1767+
&& nt->accidental()->accidentalType() == AccidentalType::FLAT
17681768
&& !accTmp.value(ln, false))
17691769
|| (alter == 0
17701770
&& currAccVal == AccidentalVal::NATURAL
1771-
&& nt->accidental()->accidentalType() == Accidental::Type::NATURAL
1771+
&& nt->accidental()->accidentalType() == AccidentalType::NATURAL
17721772
&& !accTmp.value(ln, false))
17731773
|| (alter == 1
17741774
&& currAccVal == AccidentalVal::SHARP
1775-
&& nt->accidental()->accidentalType() == Accidental::Type::SHARP
1775+
&& nt->accidental()->accidentalType() == AccidentalType::SHARP
17761776
&& !accTmp.value(ln, false))) {
1777-
nt->accidental()->setRole(Accidental::Role::USER);
1777+
nt->accidental()->setRole(AccidentalRole::USER);
17781778
}
1779-
else if (nt->accidental()->accidentalType() > Accidental::Type::NATURAL
1780-
&& nt->accidental()->accidentalType() < Accidental::Type::END) {
1779+
else if (nt->accidental()->accidentalType() > AccidentalType::NATURAL
1780+
&& nt->accidental()->accidentalType() < AccidentalType::END) {
17811781
// microtonal accidental
1782-
nt->accidental()->setRole(Accidental::Role::USER);
1782+
nt->accidental()->setRole(AccidentalRole::USER);
17831783
accTmp.insert(ln, false);
17841784
}
17851785
else {
@@ -1847,7 +1847,7 @@ void MusicXMLParserPass2::measure(const QString& partId,
18471847
// note: chord and grace note handling done in note()
18481848
// dura > 0 iff valid rest or first note of chord found
18491849
Note* n = note(partId, measure, time + mTime, time + prevTime, dura, cv, gcl, beam, fbl, alt);
1850-
if (n && n->accidental() && n->accidental()->accidentalType() != Accidental::Type::NONE)
1850+
if (n && n->accidental() && n->accidental()->accidentalType() != AccidentalType::NONE)
18511851
alterMap.insert(n, alt);
18521852
if (dura.isValid() && dura > Fraction(0, 1)) {
18531853
prevTime = mTime; // save time stamp last chord created
@@ -2984,36 +2984,36 @@ static bool isAppr(const double v, const double ref, const double epsilon)
29842984
//---------------------------------------------------------
29852985

29862986
/**
2987-
Convert a MusicXML alter tag into a microtonal accidental in MuseScore enum Accidental::Type.
2987+
Convert a MusicXML alter tag into a microtonal accidental in MuseScore enum AccidentalType.
29882988
Works only for quarter tone, half tone, three-quarters tone and whole tone accidentals.
29892989
*/
29902990

2991-
static Accidental::Type microtonalGuess(double val)
2991+
static AccidentalType microtonalGuess(double val)
29922992
{
29932993
const double eps = 0.001;
29942994
if (isAppr(val, -2, eps))
2995-
return Accidental::Type::FLAT2;
2995+
return AccidentalType::FLAT2;
29962996
else if (isAppr(val, -1.5, eps))
2997-
return Accidental::Type::MIRRORED_FLAT2;
2997+
return AccidentalType::MIRRORED_FLAT2;
29982998
else if (isAppr(val, -1, eps))
2999-
return Accidental::Type::FLAT;
2999+
return AccidentalType::FLAT;
30003000
else if (isAppr(val, -0.5, eps))
3001-
return Accidental::Type::MIRRORED_FLAT;
3001+
return AccidentalType::MIRRORED_FLAT;
30023002
else if (isAppr(val, 0, eps))
3003-
return Accidental::Type::NATURAL;
3003+
return AccidentalType::NATURAL;
30043004
else if (isAppr(val, 0.5, eps))
3005-
return Accidental::Type::SHARP_SLASH;
3005+
return AccidentalType::SHARP_SLASH;
30063006
else if (isAppr(val, 1, eps))
3007-
return Accidental::Type::SHARP;
3007+
return AccidentalType::SHARP;
30083008
else if (isAppr(val, 1.5, eps))
3009-
return Accidental::Type::SHARP_SLASH4;
3009+
return AccidentalType::SHARP_SLASH4;
30103010
else if (isAppr(val, 2, eps))
3011-
return Accidental::Type::SHARP2;
3011+
return AccidentalType::SHARP2;
30123012
else
30133013
qDebug("Guess for microtonal accidental corresponding to value %f failed.", val); // TODO
30143014

30153015
// default
3016-
return Accidental::Type::NONE;
3016+
return AccidentalType::NONE;
30173017
}
30183018

30193019
//---------------------------------------------------------
@@ -3034,7 +3034,7 @@ static void addSymToSig(KeySigEvent& sig, const QString& step, const QString& al
30343034
bool ok;
30353035
double d;
30363036
d = alter.toDouble(&ok);
3037-
Accidental::Type accTpAlter = ok ? microtonalGuess(d) : Accidental::Type::NONE;
3037+
AccidentalType accTpAlter = ok ? microtonalGuess(d) : AccidentalType::NONE;
30383038
id = mxmlString2accSymId(accidentalType2MxmlString(accTpAlter));
30393039
}
30403040

@@ -3710,7 +3710,7 @@ Note* MusicXMLParserPass2::note(const QString& partId,
37103710
Fraction timeMod(0, 0); // invalid (will handle "present but incorrect" as "not present")
37113711
QString type;
37123712
QString voice;
3713-
Accidental::Type accType = Accidental::Type::NONE; // set based on alter value (can be microtonal)
3713+
AccidentalType accType = AccidentalType::NONE; // set based on alter value (can be microtonal)
37143714
Accidental* acc = 0; // created based on accidental element
37153715
MScore::Direction stemDir = MScore::Direction::AUTO;
37163716
bool noStem = false;
@@ -3808,8 +3808,8 @@ Note* MusicXMLParserPass2::note(const QString& partId,
38083808

38093809
// accidental handling
38103810
//qDebug("note acc %p type %hhd acctype %hhd",
3811-
// acc, acc ? acc->accidentalType() : static_cast<Ms::Accidental::Type>(0), accType);
3812-
if (!acc && accType != Accidental::Type::NONE) {
3811+
// acc, acc ? acc->accidentalType() : static_cast<Ms::AccidentalType>(0), accType);
3812+
if (!acc && accType != AccidentalType::NONE) {
38133813
acc = new Accidental(_score);
38143814
acc->setAccidentalType(accType);
38153815
}
@@ -4055,7 +4055,7 @@ Note* MusicXMLParserPass2::note(const QString& partId,
40554055
if (acc) {
40564056
note->add(acc);
40574057
// save alter value for user accidental
4058-
if (acc->accidentalType() != Accidental::Type::NONE)
4058+
if (acc->accidentalType() != AccidentalType::NONE)
40594059
alt = alter;
40604060
}
40614061
c->add(note);
@@ -4580,14 +4580,14 @@ Accidental* MusicXMLParserPass2::accidental()
45804580
bool parentheses = _e.attributes().value("parentheses") == "yes";
45814581

45824582
QString s = _e.readElementText();
4583-
Accidental::Type type = mxmlString2accidentalType(s);
4583+
AccidentalType type = mxmlString2accidentalType(s);
45844584

4585-
if (type != Accidental::Type::NONE) {
4585+
if (type != AccidentalType::NONE) {
45864586
Accidental* a = new Accidental(_score);
45874587
a->setAccidentalType(type);
45884588
if (editorial || cautionary || parentheses) {
45894589
a->setHasBracket(cautionary || parentheses);
4590-
a->setRole(Accidental::Role::USER);
4590+
a->setRole(AccidentalRole::USER);
45914591
}
45924592
return a;
45934593
}
@@ -4709,7 +4709,7 @@ void MusicXMLParserPass2::timeModification(Fraction& timeMod, TDuration& normalT
47094709
// pitch
47104710
//---------------------------------------------------------
47114711

4712-
void MusicXMLParserPass2::pitch(int& step, int& alter, int& oct, Accidental::Type& accid)
4712+
void MusicXMLParserPass2::pitch(int& step, int& alter, int& oct, AccidentalType& accid)
47134713
{
47144714
Q_ASSERT(_e.isStartElement() && _e.name() == "pitch");
47154715

@@ -4727,7 +4727,7 @@ void MusicXMLParserPass2::pitch(int& step, int& alter, int& oct, Accidental::Typ
47274727
logError(QString("invalid alter '%1'").arg(strAlter));
47284728
bool ok2;
47294729
double altervalue = strAlter.toDouble(&ok2);
4730-
if (ok2 && (qAbs(altervalue) < 2.0) && (accid == Accidental::Type::NONE)) {
4730+
if (ok2 && (qAbs(altervalue) < 2.0) && (accid == AccidentalType::NONE)) {
47314731
// try to see if a microtonal accidental is needed
47324732
accid = microtonalGuess(altervalue);
47334733
}
@@ -5440,4 +5440,4 @@ MusicXMLParserDirection::MusicXMLParserDirection(QXmlStreamReader& e,
54405440
// nothing
54415441
}
54425442

5443-
}
5443+
}

mscore/importmxmlpass2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class MusicXMLParserPass2 {
114114
void forward(Fraction& dura);
115115
void backup(Fraction& dura);
116116
void timeModification(Fraction& timeMod, TDuration& normalType);
117-
void pitch(int& step, int& alter, int& oct, Accidental::Type& accid);
117+
void pitch(int& step, int& alter, int& oct, AccidentalType& accid);
118118
void rest(int& step, int& octave);
119119
void lyric(QMap<int, Lyrics*>& numbrdLyrics, QMap<int, Lyrics*>& defyLyrics,
120120
QList<Lyrics*>& unNumbrdLyrics);

0 commit comments

Comments
 (0)