Skip to content
Merged
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
45 changes: 44 additions & 1 deletion src/importexport/musicxml/internal/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ class ExportMusicXml
void credits(XmlWriter& xml);
void moveToTick(const Fraction& t);
void words(TextBase const* const text, staff_idx_t staff);
void systemText(StaffTextBase const* const text, staff_idx_t staff);
void tboxTextAsWords(TextBase const* const text, const staff_idx_t staff, QPointF position);
void rehearsal(RehearsalMark const* const rmk, staff_idx_t staff);
void hairpin(Hairpin const* const hp, staff_idx_t staff, const Fraction& tick);
Expand Down Expand Up @@ -4838,6 +4839,46 @@ void ExportMusicXml::words(TextBase const* const text, staff_idx_t staff)
directionETag(_xml, staff);
}

//---------------------------------------------------------
// systemText
//---------------------------------------------------------

void ExportMusicXml::systemText(StaffTextBase const* const text, staff_idx_t staff)
{
const auto offset = calculateTimeDeltaInDivisions(text->tick(), tick(), div);

if (text->plainText() == "") {
// sometimes empty Texts are present, exporting would result
// in invalid MusicXML (as an empty direction-type would be created)
return;
}

directionTag(_xml, _attr, text);
wordsMetronome(_xml, _score->style(), text, offset);

if (text->swing()) {
_xml.startElement("sound");
_xml.startElement("swing");
if (!text->swingParameters().swingUnit) {
_xml.tag("straight");
} else {
const int swingPercentage = text->swingParameters().swingRatio;
const int swingDivisor = std::gcd(text->swingParameters().swingRatio, 100);
_xml.tag("first", 100 / swingDivisor);
_xml.tag("second", swingPercentage / swingDivisor);
if (text->swingParameters().swingUnit == Constants::DIVISION / 2) {
_xml.tag("swing-type", TConv::toXml(DurationType::V_EIGHTH));
} else {
_xml.tag("swing-type", TConv::toXml(DurationType::V_16TH));
}
}
_xml.endElement();
_xml.endElement();
}

directionETag(_xml, staff);
}

//---------------------------------------------------------
// positioningAttributesForTboxText
//---------------------------------------------------------
Expand Down Expand Up @@ -6095,14 +6136,16 @@ static bool commonAnnotations(ExportMusicXml* exp, const EngravingItem* e, staff
exp->symbol(toSymbol(e), sstaff);
} else if (e->isTempoText()) {
exp->tempoText(toTempoText(e), sstaff);
} else if (e->isPlayTechAnnotation() || e->isCapo() || e->isStringTunings() || e->isStaffText() || e->isSystemText()
} else if (e->isPlayTechAnnotation() || e->isCapo() || e->isStringTunings() || e->isStaffText()
|| e->isTripletFeel() || e->isText()
|| e->isExpression() || (e->isInstrumentChange() && e->visible())) {
exp->words(toTextBase(e), sstaff);
} else if (e->isDynamic()) {
exp->dynamic(toDynamic(e), sstaff);
} else if (e->isRehearsalMark()) {
exp->rehearsal(toRehearsalMark(e), sstaff);
} else if (e->isSystemText()) {
exp->systemText(toStaffTextBase(e), sstaff);
} else {
return instrChangeHandled;
}
Expand Down
Loading