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 a0d2662
Show file tree
Hide file tree
Showing 5 changed files with 1,377 additions and 0 deletions.
14 changes: 14 additions & 0 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3648,6 +3648,20 @@ 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());
QStringList matches = QString::fromLatin1(noteheadName).split(nameparts, Qt::SkipEmptyParts);
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 a0d2662

Please sign in to comment.