Skip to content

Commit

Permalink
Add inferencing for incorrect part names
Browse files Browse the repository at this point in the history
Sibelius seems to export part names as "P#" rather than specifying
print-object="no". This commit adds handling of this case, omitting
part names of the (regex) form "$P[0-9]+^".
  • Loading branch information
iveshenry18 committed Jun 22, 2021
1 parent 24d892e commit 5cadfae
Show file tree
Hide file tree
Showing 4 changed files with 862 additions and 89 deletions.
15 changes: 14 additions & 1 deletion importexport/musicxml/importmxmlpass2.cpp
Expand Up @@ -1437,6 +1437,19 @@ SpannerSet MusicXMLParserPass2::findIncompleteSpannersAtPartEnd()
return res;
}


//---------------------------------------------------------
// isLikelyIncorrectPartName
//---------------------------------------------------------
/**
Sibelius exports part names of the form "P#" rather than
specifying print-object="no". This finds those.
*/

static bool isLikelyIncorrectPartName(const QString& partName) {
return partName.contains(QRegularExpression("^P[0-9]+$"));
}

//---------------------------------------------------------
// multi-measure rest state handling
//---------------------------------------------------------
Expand Down Expand Up @@ -1653,7 +1666,7 @@ void MusicXMLParserPass2::part()
// set the part name
auto mxmlPart = _pass1.getMusicXmlPart(id);
_pass1.getPart(id)->setPartName(mxmlPart.getName());
if (mxmlPart.getPrintName())
if (mxmlPart.getPrintName() && !isLikelyIncorrectPartName(mxmlPart.getName()))
_pass1.getPart(id)->setLongName(mxmlPart.getName());
else
_pass1.getPart(id)->setLongName("");
Expand Down
Binary file modified mtest/musicxml/io/testPartNames.pdf
Binary file not shown.

0 comments on commit 5cadfae

Please sign in to comment.