Skip to content

Commit

Permalink
Fix GH#20207: MusicXML import of common and cut time is too strict
Browse files Browse the repository at this point in the history
  • Loading branch information
Jojo-Schmitz committed Nov 27, 2023
1 parent c115da3 commit 15a87f4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 38 deletions.
30 changes: 11 additions & 19 deletions src/importexport/musicxml/internal/musicxml/importmxmlpass1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2602,28 +2602,20 @@ static bool determineTimeSig(MxmlLogger* logger, const QXmlStreamReader* const x
bts = 0; // the beats (max 4 separated by "+") as integer
btp = 0; // beat-type as integer
// determine if timesig is valid
if (beats == "2" && beatType == "2" && timeSymbol == "cut") {
if (timeSymbol == "cut") {
st = TimeSigType::ALLA_BREVE;
bts = 2;
btp = 2;
return true;
} else if (beats == "4" && beatType == "4" && timeSymbol == "common") {
} else if (timeSymbol == "common") {
st = TimeSigType::FOUR_FOUR;
bts = 4;
btp = 4;
return true;
} else {
if (!timeSymbol.isEmpty() && timeSymbol != "normal") {
logger->logError(QString("time symbol '%1' not recognized with beats=%2 and beat-type=%3")
.arg(timeSymbol, beats, beatType), xmlreader);
return false;
}
} else if (!timeSymbol.isEmpty() && timeSymbol != "normal") {
logger->logError(QString("time symbol '%1' not recognized")
.arg(timeSymbol), xmlreader);
return false;
}

btp = beatType.toInt();
QStringList list = beats.split("+");
for (int i = 0; i < list.size(); i++) {
bts += list.at(i).toInt();
}
btp = beatType.toInt();
QStringList list = beats.split("+");
for (int i = 0; i < list.size(); i++) {
bts += list.at(i).toInt();
}

// determine if bts and btp are valid
Expand Down
29 changes: 10 additions & 19 deletions src/importexport/musicxml/internal/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4408,28 +4408,19 @@ static bool determineTimeSig(const QString beats, const QString beatType, const
bts = 0; // the beats (max 4 separated by "+") as integer
btp = 0; // beat-type as integer
// determine if timesig is valid
if (beats == "2" && beatType == "2" && timeSymbol == "cut") {
if (timeSymbol == "cut") {
st = TimeSigType::ALLA_BREVE;
bts = 2;
btp = 2;
return true;
} else if (beats == "4" && beatType == "4" && timeSymbol == "common") {
} else if (timeSymbol == "common") {
st = TimeSigType::FOUR_FOUR;
bts = 4;
btp = 4;
return true;
} else {
if (!timeSymbol.isEmpty() && timeSymbol != "normal") {
LOGD("determineTimeSig: time symbol <%s> not recognized with beats=%s and beat-type=%s",
qPrintable(timeSymbol), qPrintable(beats), qPrintable(beatType)); // TODO
return false;
}
} else if (!timeSymbol.isEmpty() && timeSymbol != "normal") {
LOGD("determineTimeSig: time symbol <%s> not recognized", qPrintable(timeSymbol)); // TODO
return false;
}

btp = beatType.toInt();
QStringList list = beats.split("+");
for (int i = 0; i < list.size(); i++) {
bts += list.at(i).toInt();
}
btp = beatType.toInt();
QStringList list = beats.split("+");
for (int i = 0; i < list.size(); i++) {
bts += list.at(i).toInt();
}

// determine if bts and btp are valid
Expand Down

0 comments on commit 15a87f4

Please sign in to comment.