-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MusicXML: add support for numerals #24174
base: master
Are you sure you want to change the base?
Changes from all commits
d33d472
9118ea1
75c0c1d
f1f7227
f83d366
901a9b3
a3ac0c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7299,7 +7299,7 @@ void MusicXMLParserPass2::harmony(const String& partId, Measure* measure, const | |
const String placement = m_e.attribute("placement"); | ||
const bool printObject = m_e.asciiAttribute("print-object") != "no"; | ||
|
||
String kind, kindText, functionText, symbols, parens; | ||
String kind, kindText, functionText, inversionText, symbols, parens; | ||
std::list<HDegree> degreeList; | ||
|
||
FretDiagram* fd = nullptr; | ||
|
@@ -7342,8 +7342,33 @@ void MusicXMLParserPass2::harmony(const String& partId, Measure* measure, const | |
ha->setRootTpc(Tpc::TPC_INVALID); | ||
ha->setBaseTpc(Tpc::TPC_INVALID); | ||
functionText = m_e.readText(); | ||
// TODO: parse to decide between ROMAN and NASHVILLE | ||
ha->setHarmonyType(HarmonyType::ROMAN); | ||
} else if (m_e.name() == "numeral") { | ||
ha->setRootTpc(Tpc::TPC_INVALID); | ||
ha->setBaseTpc(Tpc::TPC_INVALID); | ||
while (m_e.readNextStartElement()) { | ||
if (m_e.name() == "numeral-root") { | ||
String numeralRoot = m_e.readText(); | ||
String numeralRootText = m_e.attribute("text"); | ||
// TODO analyze text and import as roman numerals | ||
ha->setHarmonyType(HarmonyType::NASHVILLE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We appear to have just switched the problem around - previously nashville numbers were imported as roman numerals, now roman numerals are imported as nashville numbers. It would be great if we could recognise numerals here, as we've lost export/import consistency for numerals with this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is not entirely true, because the |
||
ha->setFunction(numeralRoot); | ||
} else if (m_e.name() == "numeral-alter") { | ||
const int alter = m_e.readText().toInt(); | ||
switch (alter) { | ||
case -1: | ||
ha->setFunction(u"b" + ha->hFunction()); | ||
break; | ||
case 1: | ||
ha->setFunction(u"#" + ha->hFunction()); | ||
break; | ||
default: | ||
break; | ||
} | ||
} else { | ||
skipLogCurrElem(); | ||
} | ||
} | ||
} else if (m_e.name() == "kind") { | ||
// attributes: use-symbols yes-no | ||
// text, stack-degrees, parentheses-degree, bracket-degrees, | ||
|
@@ -7356,8 +7381,16 @@ void MusicXMLParserPass2::harmony(const String& partId, Measure* measure, const | |
ha->setRootTpc(Tpc::TPC_INVALID); | ||
} | ||
} else if (m_e.name() == "inversion") { | ||
// attributes: print-style | ||
skipLogCurrElem(); | ||
const int inversion = m_e.readText().toInt(); | ||
switch (inversion) { | ||
case 1: inversionText = u"6"; | ||
break; | ||
case 2: inversionText = u"64"; | ||
break; | ||
default: | ||
inversionText = u""; | ||
break; | ||
} | ||
} else if (m_e.name() == "bass") { | ||
String step; | ||
int alter = 0; | ||
|
@@ -7425,15 +7458,15 @@ void MusicXMLParserPass2::harmony(const String& partId, Measure* measure, const | |
} | ||
|
||
const ChordDescription* d = nullptr; | ||
if (ha->rootTpc() != Tpc::TPC_INVALID) { | ||
if (ha->rootTpc() != Tpc::TPC_INVALID || !ha->hFunction().empty()) { | ||
d = ha->fromXml(kind, kindText, symbols, parens, degreeList); | ||
} | ||
if (d) { | ||
ha->setId(d->id); | ||
ha->setTextName(d->names.front()); | ||
} else { | ||
ha->setId(-1); | ||
String textName = functionText + kindText; | ||
String textName = functionText + kindText + inversionText; | ||
ha->setTextName(textName); | ||
} | ||
ha->render(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could modify the code you've written below to read inversions to write them here.