diff --git a/mscore/importgtp-gp6.cpp b/mscore/importgtp-gp6.cpp index 0d515d6e5a..39a29ebae2 100644 --- a/mscore/importgtp-gp6.cpp +++ b/mscore/importgtp-gp6.cpp @@ -58,6 +58,18 @@ namespace Ms { +const static std::map instrumentMapping = { + {"e-gtr6", "electric-guitar"}, + {"tnr-s", "voice"}, + {"s-gtr6", "guitar-steel"}, + {"n-gtr6", "guitar-nylon"}, + {"snt-lead-ss", "poly-synth"}, + {"f-bass5", "bass-guitar"}, + {"snt-bass-ss", "metallic-synth"}, + {"mrcs", "maracas"}, + {"drmkt", "drumset"} + }; + //--------------------------------------------------------- // readBit //--------------------------------------------------------- @@ -398,25 +410,12 @@ void GuitarPro6::readTracks(QDomNode* track) part->setPartName(currentNode.toElement().text()); else if (nodeName == "Instrument") { QString ref = currentNode.attributes().namedItem("ref").toAttr().value(); - // use an array as a map instead? - if (!ref.compare("e-gtr6")) - part->setInstrument(Instrument::fromTemplate(Ms::searchTemplate("electric-guitar"))); - else if (!ref.compare("tnr-s")) - part->setInstrument(Instrument::fromTemplate(Ms::searchTemplate("voice"))); - else if (!ref.compare("s-gtr6")) - part->setInstrument(Instrument::fromTemplate(Ms::searchTemplate("guitar-steel"))); - else if (!ref.compare("n-gtr6")) - part->setInstrument(Instrument::fromTemplate(Ms::searchTemplate("guitar-nylon"))); - else if (!ref.compare("snt-lead-ss")) - part->setInstrument(Instrument::fromTemplate(Ms::searchTemplate("poly-synth"))); - else if (!ref.compare("f-bass5")) - part->setInstrument(Instrument::fromTemplate(Ms::searchTemplate("bass-guitar"))); - else if (!ref.compare("snt-bass-ss")) - part->setInstrument(Instrument::fromTemplate(Ms::searchTemplate("metallic-synth"))); - else if (!ref.compare("mrcs")) - part->setInstrument(Instrument::fromTemplate(Ms::searchTemplate("maracas"))); - else if (!ref.compare("drmkt")) - part->setInstrument(Instrument::fromTemplate(Ms::searchTemplate("drumset"))); + auto it = instrumentMapping.find(ref); + if (it != instrumentMapping.end()) { + part->setInstrument(Instrument::fromTemplate(Ms::searchTemplate(it->second))); + } + else + qDebug() << "Unknown instrument: " << ref; if (ref.endsWith("-gs")) { // grand staff Staff* s2 = new Staff(score); s2->setPart(part); diff --git a/mtest/guitarpro/multivoices.gpx-ref.mscx b/mtest/guitarpro/multivoices.gpx-ref.mscx index 99e0470915..32203a7e5b 100644 --- a/mtest/guitarpro/multivoices.gpx-ref.mscx +++ b/mtest/guitarpro/multivoices.gpx-ref.mscx @@ -53,8 +53,15 @@ N-Gt - Nylon Guitar - + Classical Guitar + Guit. + Classical Guitar + 40 + 83 + 40 + 83 + pluck.guitar.nylon-string + G8vb 21 40 @@ -64,7 +71,36 @@ 59 64 + + 100 + 100 + + + 100 + 33 + + + 100 + 50 + + + 100 + 67 + + + 100 + 100 + + + 120 + 67 + + + 120 + 100 + + @@ -427,8 +463,15 @@ - Nylon Guitar - + Classical Guitar + Guit. + Classical Guitar + 40 + 83 + 40 + 83 + pluck.guitar.nylon-string + G8vb 21 40 @@ -438,7 +481,36 @@ 59 64 + + 100 + 100 + + + 100 + 33 + + + 100 + 50 + + + 100 + 67 + + + 100 + 100 + + + 120 + 67 + + + 120 + 100 + + @@ -448,7 +520,7 @@ 0 - Nylon Guitar + Classical Guitar