Skip to content
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] Support for notehead names #737

Draft
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Draft
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
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) {
static const 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);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not right. Need to find an equivalent for the original PR's

        StringList matches = String::fromAscii(noteheadName.ascii()).search(nameparts, { 1, 2 }, SplitBehavior::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
17 changes: 16 additions & 1 deletion importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6184,10 +6184,25 @@ Note* MusicXMLParserPass2::note(const QString& partId,
if (noteheadValue == "none")
hasHead = false;
else if (noteheadValue == "named" && _pass1.exporterSoftware() == MusicXMLExporterSoftware::NOTEFLIGHT)
headScheme = NoteHead::Scheme::HEAD_PITCHNAME;
headScheme = NoteHead::Scheme::HEAD_PITCHNAME; // NoteHead::Scheme::HEAD_PITCHNAME_GERMAN is not an option here?
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_FIXED;
}
else if (_e.name() == "rest") {
rest = true;
measureRest = _e.attributes().value("measure") == "yes";
Expand Down
Loading