From c5907f880c4331092e7a33d7fd1c651f96cf9276 Mon Sep 17 00:00:00 2001 From: Marc Sabatella Date: Thu, 1 Aug 2019 09:00:38 -0600 Subject: [PATCH] MusicXML import/export for RNA/Nashville --- libmscore/harmony.h | 1 + mscore/exportxml.cpp | 35 +++++++++++++++++++++++------------ mscore/importmxmlpass2.cpp | 9 +++++---- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/libmscore/harmony.h b/libmscore/harmony.h index 241453cb4d..f99ab02894 100644 --- a/libmscore/harmony.h +++ b/libmscore/harmony.h @@ -146,6 +146,7 @@ class Harmony final : public TextBase { int rootTpc() const { return _rootTpc; } void setRootTpc(int val) { _rootTpc = val; } void setTextName(const QString& s) { _textName = s; } + void setFunction(const QString& s) { _function = s; } QString rootName(); QString baseName(); void addDegree(const HDegree& d); diff --git a/mscore/exportxml.cpp b/mscore/exportxml.cpp index bd27573857..e5daebb60a 100644 --- a/mscore/exportxml.cpp +++ b/mscore/exportxml.cpp @@ -5811,18 +5811,29 @@ void ExportMusicXml::harmony(Harmony const* const h, FretDiagram const* const fd _xml.stag(QString("harmony print-frame=\"yes\"")); // .append(relative)); else _xml.stag(QString("harmony print-frame=\"no\"")); // .append(relative)); - if (h->harmonyType() == HarmonyType::STANDARD) { - _xml.stag("root"); - _xml.tag("root-step text=\"\"", "C"); - _xml.etag(); // root - QString k = "kind text=\"" + h->hTextName() + "\""; - _xml.tag(k, "none"); - } - else { - // TODO: parse? - _xml.tag("function", h->hTextName()); - QString k = "kind text=\"" + h->hTextName() + "\""; - _xml.tag(k, "none"); + switch (h->harmonyType()) { + case HarmonyType::NASHVILLE: { + _xml.tag("function", h->hFunction()); + QString k = "kind text=\"" + h->hTextName() + "\""; + _xml.tag(k, "none"); + } + break; + case HarmonyType::ROMAN: { + // TODO: parse? + _xml.tag("function", h->hTextName()); + QString k = "kind text=\"\""; + _xml.tag(k, "none"); + } + break; + case HarmonyType::STANDARD: + default: { + _xml.stag("root"); + _xml.tag("root-step text=\"\"", "C"); + _xml.etag(); // root + QString k = "kind text=\"" + h->hTextName() + "\""; + _xml.tag(k, "none"); + } + break; } _xml.etag(); // harmony #if 0 diff --git a/mscore/importmxmlpass2.cpp b/mscore/importmxmlpass2.cpp index 2160bd1bac..fbcf8e4ed3 100644 --- a/mscore/importmxmlpass2.cpp +++ b/mscore/importmxmlpass2.cpp @@ -4881,7 +4881,7 @@ void MusicXMLParserPass2::harmony(const QString& partId, Measure* measure, const QString printFrame = _e.attributes().value("print-frame").toString(); QString printStyle = _e.attributes().value("print-style").toString(); - QString kind, kindText, symbols, parens; + QString kind, kindText, functionText, symbols, parens; QList degreeList; /* TODO ? @@ -4930,9 +4930,9 @@ void MusicXMLParserPass2::harmony(const QString& partId, Measure* measure, const // attributes: print-style ha->setRootTpc(Tpc::TPC_INVALID); ha->setBaseTpc(Tpc::TPC_INVALID); + functionText = _e.readElementText(); + // TODO: parse to decide between ROMAN and NASHVILLE ha->setHarmonyType(HarmonyType::ROMAN); - QString text = _e.readElementText(); - ha->setHarmony(text); } else if (_e.name() == "kind") { // attributes: use-symbols yes-no @@ -5032,7 +5032,8 @@ void MusicXMLParserPass2::harmony(const QString& partId, Measure* measure, const } else { ha->setId(-1); - ha->setTextName(kindText); + QString textName = functionText + kindText; + ha->setTextName(textName); } ha->render();