Skip to content

Commit

Permalink
[MusicXML] Support for notehead names
Browse files Browse the repository at this point in the history
Backport of musescore#25916
  • Loading branch information
rettinghaus authored and Jojo-Schmitz committed Dec 24, 2024
1 parent 41f2dd8 commit 992a02c
Show file tree
Hide file tree
Showing 5 changed files with 1,381 additions and 0 deletions.
18 changes: 18 additions & 0 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3648,6 +3648,24 @@ static void writeNotehead(XmlWriter& xml, const Note* const note)
noteheadTagname += QString(" smufl=\"%1\"").arg(noteheadName);
xml.tag(noteheadTagname, "other");
}

if (note->headScheme() == NoteHead::Scheme::HEAD_PITCHNAME
|| note->headScheme() == NoteHead::Scheme::HEAD_PITCHNAME_GERMAN
|| note->headScheme() == NoteHead::Scheme::HEAD_SOLFEGE
|| note->headScheme() == NoteHead::Scheme::HEAD_SOLFEGE_FIXED) {
QRegExp nameparts("^note([A-Z][a-z]*)(Sharp|Flat)?");
const char* noteheadName = Sym::id2name(note->noteHead());
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
QStringList matches = QString::fromLatin1(noteheadName).split(nameparts, Qt::SkipEmptyParts);
#else
QStringList matches = QString::fromLatin1(noteheadName).split(nameparts, QString::SkipEmptyParts);
#endif
xml.stag("notehead-text");
xml.tag("display-text", matches.at(0));
if (matches.size() > 1)
xml.tag("accidental-text", matches.at(1).toLower());
xml.etag();
}
}

//---------------------------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6188,6 +6188,21 @@ Note* MusicXMLParserPass2::note(const QString& partId,
else
headGroup = convertNotehead(noteheadValue);
}
else if (_e.name() == "notehead-text") {
QString noteheadText;
while (_e.readNextStartElement()) {
if (_e.name() == "display-text")
noteheadText = _e.readElementText();
else if (_e.name() == "accidental-text")
_e.skipCurrentElement();
else
skipLogCurrElem();
}
if (noteheadText.size() == 1)
headScheme = (noteheadText == "H") ? NoteHead::Scheme::HEAD_PITCHNAME_GERMAN : NoteHead::Scheme::HEAD_PITCHNAME;
else
headScheme = NoteHead::Scheme::HEAD_SOLFEGE;
}
else if (_e.name() == "rest") {
rest = true;
measureRest = _e.attributes().value("measure") == "yes";
Expand Down
Loading

0 comments on commit 992a02c

Please sign in to comment.