Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MU3] Instruments recognition fix #8866

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions importexport/musicxml/importmxmlpass1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1933,6 +1933,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 @@ -449,7 +449,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
4 changes: 4 additions & 0 deletions libmscore/instrtemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,10 @@ 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