diff --git a/src/engraving/dom/staff.cpp b/src/engraving/dom/staff.cpp index 42a38efca019b..08c1d0a7f7eed 100644 --- a/src/engraving/dom/staff.cpp +++ b/src/engraving/dom/staff.cpp @@ -964,7 +964,7 @@ SwingParameters Staff::swing(const Fraction& tick) const int swingUnit = 0; muse::ByteArray ba = style().styleSt(Sid::swingUnit).toAscii(); DurationType unit = TConv::fromXml(ba.constChar(), DurationType::V_INVALID); - int swingRatio = style().styleI(Sid::swingRatio); + float swingRatio = style().styleI(Sid::swingRatio); if (unit == DurationType::V_EIGHTH) { swingUnit = Constants::DIVISION / 2; } else if (unit == DurationType::V_16TH) { diff --git a/src/engraving/dom/stafftextbase.h b/src/engraving/dom/stafftextbase.h index b66075029e33d..650a6237afe71 100644 --- a/src/engraving/dom/stafftextbase.h +++ b/src/engraving/dom/stafftextbase.h @@ -52,7 +52,7 @@ class StaffTextBase : public TextBase Segment* segment() const; String channelName(voice_idx_t voice) const { return m_channelNames[voice]; } void setChannelName(voice_idx_t v, const String& s) { m_channelNames[v] = s; } - void setSwingParameters(int unit, int ratio) + void setSwingParameters(int unit, float ratio) { m_swingParameters.swingUnit = unit; m_swingParameters.swingRatio = ratio; diff --git a/src/engraving/rw/write/twrite.cpp b/src/engraving/rw/write/twrite.cpp index 71044dfe13a91..03999016a76cd 100644 --- a/src/engraving/rw/write/twrite.cpp +++ b/src/engraving/rw/write/twrite.cpp @@ -2807,7 +2807,7 @@ void TWrite::writeProperties(const StaffTextBase* item, XmlWriter& xml, WriteCon } else { swingUnit = DurationType::V_ZERO; } - int swingRatio = item->swingParameters().swingRatio; + float swingRatio = item->swingParameters().swingRatio; xml.tag("swing", { { "unit", TConv::toXml(swingUnit) }, { "ratio", swingRatio } }); } diff --git a/src/engraving/style/styledef.cpp b/src/engraving/style/styledef.cpp index 73efc4121f535..54514395c4e20 100644 --- a/src/engraving/style/styledef.cpp +++ b/src/engraving/style/styledef.cpp @@ -479,7 +479,7 @@ const std::array StyleDef::styleValue styleDef(barlineBeforeSigChange, false), styleDef(doubleBarlineBeforeKeySig, false), styleDef(doubleBarlineBeforeTimeSig, false), - styleDef(swingRatio, PropertyValue(60)), + styleDef(swingRatio, PropertyValue(60.0)), styleDef(swingUnit, PropertyValue(String())), styleDef(chordSymbolSpelling, NoteSpellingType::STANDARD), styleDef(automaticCapitalization, true), diff --git a/src/engraving/types/types.h b/src/engraving/types/types.h index eb74a8038e522..6ed644a5b5069 100644 --- a/src/engraving/types/types.h +++ b/src/engraving/types/types.h @@ -1135,7 +1135,7 @@ static inline Key operator-=(Key& a, const Key& b) { return a = Key(static_cast< struct SwingParameters { int swingUnit = 0; - int swingRatio = 0; + float swingRatio = 0; bool isOn() const { return swingUnit != 0; } }; diff --git a/src/importexport/musicxml/internal/musicxml/export/exportmusicxml.cpp b/src/importexport/musicxml/internal/musicxml/export/exportmusicxml.cpp index 83dfdbb8951e9..2641d113c625b 100644 --- a/src/importexport/musicxml/internal/musicxml/export/exportmusicxml.cpp +++ b/src/importexport/musicxml/internal/musicxml/export/exportmusicxml.cpp @@ -5177,8 +5177,8 @@ void ExportMusicXml::systemText(StaffTextBase const* const text, staff_idx_t sta if (!text->swingParameters().swingUnit) { m_xml.tag("straight"); } else { - const int swingPercentage = text->swingParameters().swingRatio; - const int swingDivisor = std::gcd(text->swingParameters().swingRatio, 100); + const int swingPercentage = static_cast(text->swingParameters().swingRatio); + const int swingDivisor = std::gcd(static_cast(text->swingParameters().swingRatio), 100); m_xml.tag("first", 100 / swingDivisor); m_xml.tag("second", swingPercentage / swingDivisor); if (text->swingParameters().swingUnit == Constants::DIVISION / 2) { diff --git a/src/importexport/musicxml/tests/data/testSwingFloat.xml b/src/importexport/musicxml/tests/data/testSwingFloat.xml new file mode 100644 index 0000000000000..19b02e25f5df1 --- /dev/null +++ b/src/importexport/musicxml/tests/data/testSwingFloat.xml @@ -0,0 +1,963 @@ +Add commentMore actions + + + + Swing Test + + + + MuseScore 0.7.0 + 2007-09-10 + + + + + + + + + + Xylophone + Xyl. + + Xylophone + + + + 1 + 14 + 78.7402 + 0 + + + + + + + 4 + + 0 + + + + G + 2 + + + 0 + 0 + 1 + + + + + + quarter + 120 + + + + + + + A + 4 + + 2 + 1 + eighth + up + begin + + + + B + 4 + + 2 + 1 + eighth + up + continue + + + + A + 4 + + 2 + 1 + eighth + up + continue + + + + B + 4 + + 2 + 1 + eighth + up + end + + + + A + 4 + + 2 + 1 + eighth + up + begin + + + + B + 4 + + 2 + 1 + eighth + up + continue + + + + A + 4 + + 2 + 1 + eighth + up + continue + + + + B + 4 + + 2 + 1 + eighth + up + end + + + + + + Swing + + + + 5.25 + 3.33 + eighth + + + + + + A + 4 + + 2 + 1 + eighth + up + begin + + + + B + 4 + + 2 + 1 + eighth + up + continue + + + + A + 4 + + 2 + 1 + eighth + up + continue + + + + B + 4 + + 2 + 1 + eighth + up + end + + + + A + 4 + + 2 + 1 + eighth + up + begin + + + + B + 4 + + 2 + 1 + eighth + up + continue + + + + A + 4 + + 2 + 1 + eighth + up + continue + + + + B + 4 + + 2 + 1 + eighth + up + end + + + + + + Straight + + + + + + + + + + A + 4 + + 2 + 1 + eighth + up + begin + + + + B + 4 + + 2 + 1 + eighth + up + continue + + + + A + 4 + + 2 + 1 + eighth + up + continue + + + + B + 4 + + 2 + 1 + eighth + up + end + + + + A + 4 + + 2 + 1 + eighth + up + begin + + + + B + 4 + + 2 + 1 + eighth + up + continue + + + + A + 4 + + 2 + 1 + eighth + up + continue + + + + B + 4 + + 2 + 1 + eighth + up + end + + + + + + A + 4 + + 1 + 1 + 16th + up + begin + begin + + + + B + 4 + + 1 + 1 + 16th + up + continue + continue + + + + A + 4 + + 1 + 1 + 16th + up + continue + continue + + + + B + 4 + + 1 + 1 + 16th + up + end + end + + + + A + 4 + + 1 + 1 + 16th + up + begin + begin + + + + B + 4 + + 1 + 1 + 16th + up + continue + continue + + + + A + 4 + + 1 + 1 + 16th + up + continue + continue + + + + B + 4 + + 1 + 1 + 16th + up + end + end + + + + A + 4 + + 1 + 1 + 16th + up + begin + begin + + + + B + 4 + + 1 + 1 + 16th + up + continue + continue + + + + A + 4 + + 1 + 1 + 16th + up + continue + continue + + + + B + 4 + + 1 + 1 + 16th + up + end + end + + + + A + 4 + + 1 + 1 + 16th + up + begin + begin + + + + B + 4 + + 1 + 1 + 16th + up + continue + continue + + + + A + 4 + + 1 + 1 + 16th + up + continue + continue + + + + B + 4 + + 1 + 1 + 16th + up + end + end + + + + + + Swing 16ths + + + + 5.25 + 3.33 + 16th + + + + + + A + 4 + + 1 + 1 + 16th + up + begin + begin + + + + B + 4 + + 1 + 1 + 16th + up + continue + continue + + + + A + 4 + + 1 + 1 + 16th + up + continue + continue + + + + B + 4 + + 1 + 1 + 16th + up + end + end + + + + A + 4 + + 1 + 1 + 16th + up + begin + begin + + + + B + 4 + + 1 + 1 + 16th + up + continue + continue + + + + A + 4 + + 1 + 1 + 16th + up + continue + continue + + + + B + 4 + + 1 + 1 + 16th + up + end + end + + + + A + 4 + + 1 + 1 + 16th + up + begin + begin + + + + B + 4 + + 1 + 1 + 16th + up + continue + continue + + + + A + 4 + + 1 + 1 + 16th + up + continue + continue + + + + B + 4 + + 1 + 1 + 16th + up + end + end + + + + A + 4 + + 1 + 1 + 16th + up + begin + begin + + + + B + 4 + + 1 + 1 + 16th + up + continue + continue + + + + A + 4 + + 1 + 1 + 16th + up + continue + continue + + + + B + 4 + + 1 + 1 + 16th + up + end + end + + + + + + Straight + + + + + + + + + + A + 4 + + 1 + 1 + 16th + up + begin + begin + + + + B + 4 + + 1 + 1 + 16th + up + continue + continue + + + + A + 4 + + 1 + 1 + 16th + up + continue + continue + + + + B + 4 + + 1 + 1 + 16th + up + end + end + + + + A + 4 + + 1 + 1 + 16th + up + begin + begin + + + + B + 4 + + 1 + 1 + 16th + up + continue + continue + + + + A + 4 + + 1 + 1 + 16th + up + continue + continue + + + + B + 4 + + 1 + 1 + 16th + up + end + end + + + + A + 4 + + 1 + 1 + 16th + up + begin + begin + + + + B + 4 + + 1 + 1 + 16th + up + continue + continue + + + + A + 4 + + 1 + 1 + 16th + up + continue + continue + + + + B + 4 + + 1 + 1 + 16th + up + end + end + + + + A + 4 + + 1 + 1 + 16th + up + begin + begin + + + + B + 4 + + 1 + 1 + 16th + up + continue + continue + + + + A + 4 + + 1 + 1 + 16th + up + continue + continue + + + + B + 4 + + 1 + 1 + 16th + up + end + end + + + light-heavy + + + + \ No newline at end of file diff --git a/src/importexport/musicxml/tests/musicxml_tests.cpp b/src/importexport/musicxml/tests/musicxml_tests.cpp index e8da35ec3ac96..a9d7d29f277a0 100644 --- a/src/importexport/musicxml/tests/musicxml_tests.cpp +++ b/src/importexport/musicxml/tests/musicxml_tests.cpp @@ -1099,6 +1099,16 @@ TEST_F(MusicXml_Tests, stringVoiceName) { } TEST_F(MusicXml_Tests, swing) { musicXmlIoTest("testSwing"); + + String fileName = String::fromUtf8("testSwingFloat.xml"); + MasterScore* score = readScore(XML_IO_DATA_DIR + fileName); + ASSERT_TRUE(score); + fixupScore(score); + score->doLayout(); + + EXPECT_TRUE(saveCompareMusicXmlScore(score, u"testSwingFloat.xml", u"testSwing.xml")); + + delete score; } TEST_F(MusicXml_Tests, systemBrackets1) { musicXmlIoTest("testSystemBrackets1"); diff --git a/src/notation/view/widgets/stafftextpropertiesdialog.ui b/src/notation/view/widgets/stafftextpropertiesdialog.ui index 285194c77ca4f..8b0f3cab3c516 100644 --- a/src/notation/view/widgets/stafftextpropertiesdialog.ui +++ b/src/notation/view/widgets/stafftextpropertiesdialog.ui @@ -117,7 +117,7 @@ - + true @@ -125,10 +125,16 @@ % - 25 + 0.0 - - 60 + + 100.0 + + + 0.1 + + + 2