Skip to content

Commit

Permalink
improved the instruments recognition algorithm using the instrument-a…
Browse files Browse the repository at this point in the history
…bbreviation tag

Duplicate of musescore#8866
  • Loading branch information
RomanPudashkin authored and Jojo-Schmitz committed Sep 10, 2021
1 parent 1e2b0ce commit d63ce93
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions importexport/musicxml/importmxmlpass1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,11 @@ void MusicXMLParserPass1::scoreInstrument(const QString& partId)
if (_instruments[partId].contains(instrId))
_instruments[partId][instrId].name = instrName;
}
else if (_e.name() == "instrument-abbreviation") {
QString abbreviation = _e.readElementText();
if (_instruments[partId].contains(instrId))
_instruments[partId][instrId].abbreviation = abbreviation;
}
else if (_e.name() == "instrument-sound") {
QString instrSound = _e.readElementText();
if (_instruments[partId].contains(instrId))
Expand Down
2 changes: 1 addition & 1 deletion importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ static Instrument createInstrument(const MusicXMLInstrument& mxmlInstr, const In
}

if (!it) {
it = Ms::searchTemplateForInstrNameList({mxmlInstr.name});
it = Ms::searchTemplateForInstrNameList({mxmlInstr.name, mxmlInstr.abbreviation});
}

if (!it) {
Expand Down
1 change: 1 addition & 0 deletions importexport/musicxml/musicxmlsupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ struct MusicXMLInstrument {
int unpitched; // midi-unpitched read from MusicXML
QString name; // instrument-name read from MusicXML
QString sound; // instrument-sound read from MusicXML
QString abbreviation; // instrument-abbreviation read from MusicXML
QString virtLib; // virtual-library read from MusicXML
QString virtName; // virtual-name read from MusicXML
int midiChannel; // midi-channel read from MusicXML
Expand Down
3 changes: 3 additions & 0 deletions libmscore/instrtemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,9 @@ InstrumentTemplate* searchTemplateForInstrNameList(const QList<QString>& nameLis
for (InstrumentGroup* g : qAsConst(instrumentGroups)) {
for (InstrumentTemplate* it : qAsConst(g->instrumentTemplates)) {
for (const QString& name : nameList) {
if (name.isEmpty())
continue;

if (it->trackName == name ||
it->longNames.contains(StaffName(name)) ||
it->shortNames.contains(StaffName(name)))
Expand Down

0 comments on commit d63ce93

Please sign in to comment.