follow up for #272276: compatibility for articulation in drum variants

This commit is contained in:
lasconic 2018-05-17 20:19:47 +02:00
parent dd82ee5124
commit e94c03d7d7
4 changed files with 101 additions and 73 deletions

View file

@ -389,12 +389,12 @@ QVariant Articulation::propertyDefault(Pid propertyId) const
}
//---------------------------------------------------------
// articulationName
// symId2ArticulationName
//---------------------------------------------------------
const char* Articulation::articulationName() const
const char* Articulation::symId2ArticulationName(SymId symId)
{
switch (_symId) {
switch (symId) {
case SymId::articStaccatissimoAbove:
case SymId::articStaccatissimoBelow:
case SymId::articStaccatissimoStrokeAbove:
@ -441,6 +441,15 @@ const char* Articulation::articulationName() const
}
}
//---------------------------------------------------------
// articulationName
//---------------------------------------------------------
const char* Articulation::articulationName() const
{
return symId2ArticulationName(_symId);
}
//---------------------------------------------------------
// getPropertyStyle
//---------------------------------------------------------

View file

@ -82,6 +82,7 @@ class Articulation final : public Element {
virtual int subtype() const override { return int(_symId); }
QString userName() const;
const char* articulationName() const; // type-name of articulation; used for midi rendering
static const char* symId2ArticulationName(SymId symId);
virtual void layout() override;

View file

@ -130,9 +130,6 @@ bool Drumset::readProperties(XmlReader& e, int pitch)
else if (taga == "tremolo") {
div.tremolo = Tremolo::name2Type(e.readElementText());
}
else {
qDebug() << "trdf";
}
}
_drum[pitch].addVariant(div);
}

View file

@ -721,6 +721,73 @@ static NoteHead::Type convertHeadType(int i)
return val;
}
//---------------------------------------------------------
// ArticulationNames
//---------------------------------------------------------
static struct ArticulationNames {
SymId id;
const char* name;
} articulationNames[] = {
{ SymId::fermataAbove, "fermata", },
{ SymId::fermataShortAbove, "shortfermata", },
{ SymId::fermataLongAbove, "longfermata", },
{ SymId::fermataVeryLongAbove, "verylongfermata", },
{ SymId::articAccentAbove, "sforzato", },
{ SymId::articStaccatoAbove, "staccato", },
{ SymId::articStaccatissimoAbove, "staccatissimo", },
{ SymId::articTenutoAbove, "tenuto", },
{ SymId::articTenutoStaccatoAbove, "portato", },
{ SymId::articMarcatoAbove, "marcato", },
{ SymId::guitarFadeIn, "fadein", },
{ SymId::guitarFadeOut, "fadeout", },
{ SymId::guitarVolumeSwell, "volumeswell", },
{ SymId::wiggleSawtooth, "wigglesawtooth", },
{ SymId::wiggleSawtoothWide, "wigglesawtoothwide", },
{ SymId::wiggleVibratoLargeFaster, "wigglevibratolargefaster", },
{ SymId::wiggleVibratoLargeSlowest, "wigglevibratolargeslowest", },
{ SymId::brassMuteOpen, "ouvert", },
{ SymId::brassMuteClosed, "plusstop", },
{ SymId::stringsUpBow, "upbow", },
{ SymId::stringsDownBow, "downbow", },
{ SymId::ornamentTurnInverted, "reverseturn", },
{ SymId::ornamentTurn, "turn", },
{ SymId::ornamentTrill, "trill", },
{ SymId::ornamentMordent, "prall", },
{ SymId::ornamentMordentInverted, "mordent", },
{ SymId::ornamentTremblement, "prallprall", },
{ SymId::ornamentPrallMordent, "prallmordent", },
{ SymId::ornamentUpPrall, "upprall", },
{ SymId::ornamentUpMordent, "upmordent", },
{ SymId::ornamentDownMordent, "downmordent", },
{ SymId::ornamentPrallDown, "pralldown", },
{ SymId::ornamentPrallUp, "prallup", },
{ SymId::ornamentLinePrall, "lineprall", },
{ SymId::ornamentPrecompSlide, "schleifer", },
{ SymId::pluckedSnapPizzicatoAbove, "snappizzicato", },
{ SymId::stringsThumbPosition, "thumb", },
{ SymId::luteFingeringRHThumb, "lutefingeringthumb", },
{ SymId::luteFingeringRHFirst, "lutefingering1st", },
{ SymId::luteFingeringRHSecond, "lutefingering2nd", },
{ SymId::luteFingeringRHThird, "lutefingering3rd", },
{ SymId::ornamentPrecompMordentUpperPrefix, "downprall" },
{ SymId::ornamentPrecompMordentUpperPrefix, "ornamentDownPrall" },
};
//---------------------------------------------------------
// oldArticulationNames2SymId
//---------------------------------------------------------
SymId oldArticulationNames2SymId(const QString& s)
{
for (auto i : articulationNames) {
if (i.name == s)
return i.id;
}
return SymId::noSym;
}
//---------------------------------------------------------
// readDrumset
//---------------------------------------------------------
@ -736,6 +803,27 @@ static void readDrumset(Drumset* ds, XmlReader& e)
const QStringRef& tag(e.name());
if (tag == "head")
ds->drum(pitch).notehead = convertHeadGroup(e.readInt());
else if (tag == "variants") {
while(e.readNextStartElement()) {
const QStringRef& tagv(e.name());
if (tagv == "variant") {
DrumInstrumentVariant div;
div.pitch = e.attribute("pitch").toInt();
while (e.readNextStartElement()) {
const QStringRef& taga(e.name());
if (taga == "articulation") {
QString oldArticulationName = e.readElementText();
SymId oldId = oldArticulationNames2SymId(oldArticulationName);
div.articulationName = Articulation::symId2ArticulationName(oldId);
}
else if (taga == "tremolo") {
div.tremolo = Tremolo::name2Type(e.readElementText());
}
}
ds->drum(pitch).addVariant(div);
}
}
}
else if (ds->readProperties(e, pitch))
;
else
@ -1280,73 +1368,6 @@ void readTextLine206(XmlReader& e, TextLineBase* tlb)
}
}
//---------------------------------------------------------
// ArticulationNames
//---------------------------------------------------------
static struct ArticulationNames {
SymId id;
const char* name;
} articulationNames[] = {
{ SymId::fermataAbove, "fermata", },
{ SymId::fermataShortAbove, "shortfermata", },
{ SymId::fermataLongAbove, "longfermata", },
{ SymId::fermataVeryLongAbove, "verylongfermata", },
{ SymId::articAccentAbove, "sforzato", },
{ SymId::articStaccatoAbove, "staccato", },
{ SymId::articStaccatissimoAbove, "staccatissimo", },
{ SymId::articTenutoAbove, "tenuto", },
{ SymId::articTenutoStaccatoAbove, "portato", },
{ SymId::articMarcatoAbove, "marcato", },
{ SymId::guitarFadeIn, "fadein", },
{ SymId::guitarFadeOut, "fadeout", },
{ SymId::guitarVolumeSwell, "volumeswell", },
{ SymId::wiggleSawtooth, "wigglesawtooth", },
{ SymId::wiggleSawtoothWide, "wigglesawtoothwide", },
{ SymId::wiggleVibratoLargeFaster, "wigglevibratolargefaster", },
{ SymId::wiggleVibratoLargeSlowest, "wigglevibratolargeslowest", },
{ SymId::brassMuteOpen, "ouvert", },
{ SymId::brassMuteClosed, "plusstop", },
{ SymId::stringsUpBow, "upbow", },
{ SymId::stringsDownBow, "downbow", },
{ SymId::ornamentTurnInverted, "reverseturn", },
{ SymId::ornamentTurn, "turn", },
{ SymId::ornamentTrill, "trill", },
{ SymId::ornamentMordent, "prall", },
{ SymId::ornamentMordentInverted, "mordent", },
{ SymId::ornamentTremblement, "prallprall", },
{ SymId::ornamentPrallMordent, "prallmordent", },
{ SymId::ornamentUpPrall, "upprall", },
{ SymId::ornamentUpMordent, "upmordent", },
{ SymId::ornamentDownMordent, "downmordent", },
{ SymId::ornamentPrallDown, "pralldown", },
{ SymId::ornamentPrallUp, "prallup", },
{ SymId::ornamentLinePrall, "lineprall", },
{ SymId::ornamentPrecompSlide, "schleifer", },
{ SymId::pluckedSnapPizzicatoAbove, "snappizzicato", },
{ SymId::stringsThumbPosition, "thumb", },
{ SymId::luteFingeringRHThumb, "lutefingeringthumb", },
{ SymId::luteFingeringRHFirst, "lutefingering1st", },
{ SymId::luteFingeringRHSecond, "lutefingering2nd", },
{ SymId::luteFingeringRHThird, "lutefingering3rd", },
{ SymId::ornamentPrecompMordentUpperPrefix, "downprall" },
{ SymId::ornamentPrecompMordentUpperPrefix, "ornamentDownPrall" },
};
//---------------------------------------------------------
// oldArticulationNames2SymId
//---------------------------------------------------------
SymId oldArticulationNames2SymId(const QString& s)
{
for (auto i : articulationNames) {
if (i.name == s)
return i.id;
}
return SymId::noSym;
}
//---------------------------------------------------------
// setFermataPlacement
// set fermata placement from old ArticulationAnchor