Skip to content

Commit

Permalink
Merge pull request #25813 from rettinghaus/mei/places
Browse files Browse the repository at this point in the history
[MEI] simplify setting of direction
  • Loading branch information
cbjeukendrup authored Dec 15, 2024
2 parents df4fd74 + b35a1c4 commit 470f0af
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
23 changes: 6 additions & 17 deletions src/importexport/mei/internal/meiconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1246,10 +1246,7 @@ void Convert::dynamFromMEI(engraving::Dynamic* dynamic, const StringList& meiLin
warning = false;

// @place
if (meiDynam.HasPlace()) {
dynamic->setProperty(engraving::Pid::DIRECTION,
meiDynam.GetPlace() == libmei::STAFFREL_above ? engraving::DirectionV::UP : engraving::DirectionV::DOWN);
}
dynamic->setProperty(engraving::Pid::DIRECTION, Convert::directionFromMEI(meiDynam.GetPlace()));

// @label
if (meiDynam.HasLabel()) {
Expand Down Expand Up @@ -1308,9 +1305,7 @@ libmei::Dynam Convert::dynamToMEI(const engraving::Dynamic* dynamic, StringList&
libmei::Dynam meiDynam;

// @place
if (dynamic->getProperty(engraving::Pid::DIRECTION) != dynamic->propertyDefault(engraving::Pid::DIRECTION)) {
meiDynam.SetPlace(Convert::directionToMEI(dynamic->direction()));
}
meiDynam.SetPlace(Convert::directionToMEI(dynamic->direction()));

// @layer
Convert::layerIdentToMEI(dynamic, meiDynam);
Expand Down Expand Up @@ -1628,10 +1623,7 @@ void Convert::hairpinFromMEI(engraving::Hairpin* hairpin, const libmei::Hairpin&
warning = false;

// @place
if (meiHairpin.HasPlace()) {
hairpin->setProperty(engraving::Pid::DIRECTION, meiHairpin.GetPlace()
== libmei::STAFFREL_above ? engraving::DirectionV::UP : engraving::DirectionV::DOWN);
}
hairpin->setProperty(engraving::Pid::DIRECTION, Convert::directionFromMEI(meiHairpin.GetPlace()));

// @form
if (meiHairpin.GetForm() == libmei::hairpinLog_FORM_cres) {
Expand Down Expand Up @@ -1660,9 +1652,7 @@ libmei::Hairpin Convert::hairpinToMEI(const engraving::Hairpin* hairpin)
libmei::Hairpin meiHairpin;

// @place
if (hairpin->getProperty(engraving::Pid::DIRECTION) != hairpin->propertyDefault(engraving::Pid::DIRECTION)) {
meiHairpin.SetPlace(Convert::directionToMEI(hairpin->direction()));
}
meiHairpin.SetPlace(Convert::directionToMEI(hairpin->direction()));

// @form
if (hairpin->hairpinType() == engraving::HairpinType::CRESC_HAIRPIN) {
Expand Down Expand Up @@ -2646,9 +2636,8 @@ libmei::data_STAFFREL Convert::placeToMEI(engraving::PlacementV place)
}
}

engraving::DirectionV Convert::directionFromMEI(const libmei::data_STAFFREL meiPlace, bool& warning)
engraving::DirectionV Convert::directionFromMEI(const libmei::data_STAFFREL meiPlace)
{
warning = false;
switch (meiPlace) {
case (libmei::STAFFREL_above): return engraving::DirectionV::UP;
case (libmei::STAFFREL_below): return engraving::DirectionV::DOWN;
Expand All @@ -2663,7 +2652,7 @@ libmei::data_STAFFREL Convert::directionToMEI(engraving::DirectionV direction)
case (engraving::DirectionV::UP): return libmei::STAFFREL_above;
case (engraving::DirectionV::DOWN): return libmei::STAFFREL_below;
default:
return libmei::STAFFREL_above;
return libmei::STAFFREL_NONE;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/importexport/mei/internal/meiconverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class Convert
static engraving::PlacementV placeFromMEI(const libmei::data_STAFFREL meiPlace, bool& warning);
static libmei::data_STAFFREL placeToMEI(engraving::PlacementV place);

static engraving::DirectionV directionFromMEI(const libmei::data_STAFFREL meiPlace, bool& warning);
static engraving::DirectionV directionFromMEI(const libmei::data_STAFFREL meiPlace);
static libmei::data_STAFFREL directionToMEI(engraving::DirectionV direction);

static void slurFromMEI(engraving::SlurTie* slur, const libmei::Slur& meiSlur, bool& warning);
Expand Down
2 changes: 1 addition & 1 deletion src/importexport/mei/tests/data/dynamic-01.mei
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<dynam xml:id="d1hg5le3" label="mp" staff="1" startid="#n6si3n7">mp</dynam>
<dynam xml:id="d1n0kf96" label="sffz" staff="1" startid="#n7c44ti">sffz</dynam>
<dynam xml:id="d1btxom9" label="sfz" layer="1" staff="1" startid="#nvtsktx">sfz</dynam>
<dynam xml:id="d1rbma6l" label="pp" staff="1" startid="#ns8t4tw">pp</dynam>
<dynam xml:id="d1rbma6l" label="pp" staff="1" startid="#ns8t4tw" place="below">pp</dynam>
</measure>
<measure xml:id="m428gem" right="end" n="2">
<staff xml:id="m2s1" n="1">
Expand Down
1 change: 1 addition & 0 deletions src/importexport/mei/tests/data/dynamic-01.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
<Dynamic>
<subtype>pp</subtype>
<velocity>33</velocity>
<direction>down</direction>
</Dynamic>
<Chord>
<durationType>whole</durationType>
Expand Down

0 comments on commit 470f0af

Please sign in to comment.