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, part 1
  • Loading branch information
RomanPudashkin authored and Jojo-Schmitz committed Aug 16, 2021
1 parent fd906ea commit 0c825e8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions importexport/musicxml/importmxmlpass1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,13 @@ 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

0 comments on commit 0c825e8

Please sign in to comment.