Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/importexport/musicxml/internal/export/exportmusicxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,8 @@ static void pitch2xml(const Note* note, String& s, int& alter, int& octave)
// correct for ottava lines
int ottava = 0;
switch (note->ppitch() - note->pitch()) {
case 36: ottava = 3;
break;
case 24: ottava = 2;
break;
case 12: ottava = 1;
Expand All @@ -1685,6 +1687,8 @@ static void pitch2xml(const Note* note, String& s, int& alter, int& octave)
break;
case -24: ottava = -2;
break;
case -36: ottava = -3;
break;
default: LOGD("pitch2xml() tick=%d pitch()=%d ppitch()=%d",
tick.ticks(), note->pitch(), note->ppitch());
}
Expand Down Expand Up @@ -5648,6 +5652,10 @@ void ExportMusicXml::ottava(Ottava const* const ot, staff_idx_t staff, const Fra
sz = u"15";
tp = u"down";
break;
case OttavaType::OTTAVA_22MA:
sz = u"22";
tp = u"down";
break;
case OttavaType::OTTAVA_8VB:
sz = u"8";
tp = u"up";
Expand All @@ -5656,6 +5664,10 @@ void ExportMusicXml::ottava(Ottava const* const ot, staff_idx_t staff, const Fra
sz = u"15";
tp = u"up";
break;
case OttavaType::OTTAVA_22MB:
sz = u"22";
tp = u"up";
break;
default:
LOGD("ottava subtype %d not understood", int(st));
}
Expand All @@ -5667,6 +5679,8 @@ void ExportMusicXml::ottava(Ottava const* const ot, staff_idx_t staff, const Fra
octaveShiftXml = String(u"octave-shift type=\"stop\" size=\"8\" number=\"%1\"").arg(n + 1);
} else if (st == OttavaType::OTTAVA_15MA || st == OttavaType::OTTAVA_15MB) {
octaveShiftXml = String(u"octave-shift type=\"stop\" size=\"15\" number=\"%1\"").arg(n + 1);
} else if (st == OttavaType::OTTAVA_22MA || st == OttavaType::OTTAVA_22MB) {
octaveShiftXml = String(u"octave-shift type=\"stop\" size=\"22\" number=\"%1\"").arg(n + 1);
} else {
LOGD("ottava subtype %d not understood", int(st));
}
Expand All @@ -5677,7 +5691,7 @@ void ExportMusicXml::ottava(Ottava const* const ot, staff_idx_t staff, const Fra
const Fraction tickToWrite = isStart ? ot->tick() : ot->tick2();
moveToTickIfNeed(tickToWrite, ot->track(), measureStart);

directionTag(m_xml, m_attr, ot);
directionTag(m_xml, m_attr, nullptr);
m_xml.startElement("direction-type");
octaveShiftXml += color2xml(ot);
octaveShiftXml += positioningAttributes(ot, ot->tick() == tick);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3287,13 +3287,13 @@ void MusicXmlParserPass1::handleOctaveShift(const Fraction& cTime,
short sz = 0;

switch (size) {
case 8: sz = 1;
case 22: sz = 3;
break;
case 15: sz = 2;
case 15: sz = 2;
break;
case 8:
default:
m_logger->logError(String(u"invalid octave-shift size %1").arg(size), &m_e);
return;
sz = 1;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

if (!cTime.isValid() || cTime < Fraction(0, 1)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5286,7 +5286,7 @@ void MusicXmlParserDirection::octaveShift(const String& type, const int number,
return;
}
int ottavasize = m_e.intAttribute("size");
if (!(ottavasize == 8 || ottavasize == 15)) {
if (!(ottavasize == 8 || ottavasize == 15 || ottavasize == 22)) {
m_logger->logError(String(u"unknown octave-shift size %1").arg(ottavasize), &m_e);
} else {
Ottava* o = spdesc.isStopped ? toOttava(spdesc.sp) : Factory::createOttava(m_score->dummy());
Expand All @@ -5297,13 +5297,17 @@ void MusicXmlParserDirection::octaveShift(const String& type, const int number,
o->setOttavaType(OttavaType::OTTAVA_8VA);
} else if (ottavasize == 15) {
o->setOttavaType(OttavaType::OTTAVA_15MA);
} else if (ottavasize == 22) {
o->setOttavaType(OttavaType::OTTAVA_22MA);
}
} else if (type == u"up") {
m_placement = m_placement.empty() ? u"below" : m_placement;
if (ottavasize == 8) {
o->setOttavaType(OttavaType::OTTAVA_8VB);
} else if (ottavasize == 15) {
o->setOttavaType(OttavaType::OTTAVA_15MB);
} else if (ottavasize == 22) {
o->setOttavaType(OttavaType::OTTAVA_22MB);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/importexport/musicxml/tests/data/testColorExport_ref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
<words color="#945200" font-style="italic">Ausdruck</words>
</direction-type>
</direction>
<direction placement="below">
<direction>
<direction-type>
<octave-shift type="up" size="8" number="1" color="#73FCD6"/>
</direction-type>
Expand Down Expand Up @@ -363,7 +363,7 @@
<voice>1</voice>
<type>quarter</type>
</note>
<direction placement="below">
<direction>
<direction-type>
<octave-shift type="stop" size="8" number="1" color="#73FCD6"/>
</direction-type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@
</direction>
</measure>
<measure number="9">
<direction placement="above">
<direction>
<direction-type>
<octave-shift type="down" size="8" number="1"/>
</direction-type>
Expand Down Expand Up @@ -568,14 +568,14 @@
<type>quarter</type>
<stem>up</stem>
</note>
<direction placement="above">
<direction>
<direction-type>
<octave-shift type="stop" size="8" number="1"/>
</direction-type>
</direction>
</measure>
<measure number="10">
<direction placement="above">
<direction>
<direction-type>
<octave-shift type="down" size="8" number="1"/>
</direction-type>
Expand Down Expand Up @@ -620,7 +620,7 @@
<type>quarter</type>
<stem>up</stem>
</note>
<direction placement="above">
<direction>
<direction-type>
<octave-shift type="stop" size="8" number="1"/>
</direction-type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
</note>
</measure>
<measure number="9">
<direction placement="above">
<direction>
<direction-type>
<octave-shift type="down" size="8" number="1"/>
</direction-type>
Expand Down Expand Up @@ -519,7 +519,7 @@
<type>quarter</type>
<stem>up</stem>
</note>
<direction placement="above">
<direction>
<direction-type>
<octave-shift type="stop" size="8" number="1"/>
</direction-type>
Expand Down
4 changes: 2 additions & 2 deletions src/importexport/musicxml/tests/data/testLayout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
<backup>
<duration>4</duration>
</backup>
<direction placement="above">
<direction>
<direction-type>
<octave-shift type="down" size="8" number="1" default-y="24.09"/>
</direction-type>
Expand Down Expand Up @@ -177,7 +177,7 @@
<stem>down</stem>
<staff>2</staff>
</note>
<direction placement="above">
<direction>
<direction-type>
<octave-shift type="stop" size="8" number="1"/>
</direction-type>
Expand Down
16 changes: 8 additions & 8 deletions src/importexport/musicxml/tests/data/testLines1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<type>quarter</type>
<stem>up</stem>
</note>
<direction placement="above">
<direction>
<direction-type>
<octave-shift type="down" size="8" number="1"/>
</direction-type>
Expand All @@ -84,7 +84,7 @@
<type>quarter</type>
<stem>up</stem>
</note>
<direction placement="above">
<direction>
<direction-type>
<octave-shift type="stop" size="8" number="1"/>
</direction-type>
Expand All @@ -111,7 +111,7 @@
<type>quarter</type>
<stem>down</stem>
</note>
<direction placement="below">
<direction>
<direction-type>
<octave-shift type="up" size="8" number="1"/>
</direction-type>
Expand All @@ -136,7 +136,7 @@
<type>quarter</type>
<stem>down</stem>
</note>
<direction placement="below">
<direction>
<direction-type>
<octave-shift type="stop" size="8" number="1"/>
</direction-type>
Expand All @@ -163,7 +163,7 @@
<type>quarter</type>
<stem>up</stem>
</note>
<direction placement="below">
<direction>
<direction-type>
<octave-shift type="up" size="15" number="1"/>
</direction-type>
Expand Down Expand Up @@ -198,7 +198,7 @@
<type>quarter</type>
<stem>up</stem>
</note>
<direction placement="below">
<direction>
<direction-type>
<octave-shift type="stop" size="15" number="1"/>
</direction-type>
Expand All @@ -215,7 +215,7 @@
<type>quarter</type>
<stem>down</stem>
</note>
<direction placement="above">
<direction>
<direction-type>
<octave-shift type="down" size="15" number="1"/>
</direction-type>
Expand Down Expand Up @@ -250,7 +250,7 @@
<type>quarter</type>
<stem>down</stem>
</note>
<direction placement="above">
<direction>
<direction-type>
<octave-shift type="stop" size="15" number="1"/>
</direction-type>
Expand Down
Loading
Loading