Skip to content

Commit

Permalink
MusicXML: Add export for smufl noteheads
Browse files Browse the repository at this point in the history
Adresses notehead issue from musescore#17553

Backport of musescore#19506
  • Loading branch information
rettinghaus authored and Jojo-Schmitz committed Oct 1, 2023
1 parent fef847e commit 64575bd
Show file tree
Hide file tree
Showing 5 changed files with 739 additions and 0 deletions.
7 changes: 7 additions & 0 deletions importexport/musicxml/exportxml.cpp
Expand Up @@ -3269,6 +3269,8 @@ static void writeNotehead(XmlWriter& xml, const Note* const note)
xml.tag(noteheadTagname, "cross");
else if (note->headGroup() == NoteHead::Group::HEAD_CROSS)
xml.tag(noteheadTagname, "x");
else if (note->headGroup() == NoteHead::Group::HEAD_CIRCLED)
xml.tag(noteheadTagname, "circled");
else if (note->headGroup() == NoteHead::Group::HEAD_XCIRCLE)
xml.tag(noteheadTagname, "circle-x");
else if (note->headGroup() == NoteHead::Group::HEAD_TRIANGLE_DOWN)
Expand Down Expand Up @@ -3299,6 +3301,11 @@ static void writeNotehead(XmlWriter& xml, const Note* const note)
xml.tag(noteheadTagname, "normal");
else if (note->headType() != NoteHead::Type::HEAD_AUTO)
xml.tag(noteheadTagname, "normal");
else if (note->headGroup() != NoteHead::Group::HEAD_NORMAL) {
const char* noteheadName = Sym::id2name(note->noteHead(note->chord()->up(), note->headGroup(), note->headType()));
noteheadTagname += QString(" smufl=\"%1\"").arg(noteheadName);
xml.tag(noteheadTagname, "other");
}
}

//---------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions importexport/musicxml/importmxmlpass2.cpp
Expand Up @@ -1249,10 +1249,12 @@ static NoteHead::Group convertNotehead(QString mxmlName)
map["cross"] = int(NoteHead::Group::HEAD_PLUS);
map["x"] = int(NoteHead::Group::HEAD_CROSS);
map["circle-x"] = int(NoteHead::Group::HEAD_XCIRCLE);
map["circled"] = int(NoteHead::Group::HEAD_CIRCLED);
map["inverted triangle"] = int(NoteHead::Group::HEAD_TRIANGLE_DOWN);
map["slashed"] = int(NoteHead::Group::HEAD_SLASHED1);
map["back slashed"] = int(NoteHead::Group::HEAD_SLASHED2);
map["normal"] = int(NoteHead::Group::HEAD_NORMAL);
map["rectangle"] = int(NoteHead::Group::HEAD_LA);
map["do"] = int(NoteHead::Group::HEAD_DO);
map["re"] = int(NoteHead::Group::HEAD_RE);
map["mi"] = int(NoteHead::Group::HEAD_MI);
Expand Down
365 changes: 365 additions & 0 deletions mtest/musicxml/io/testNoteheads2.mscx
@@ -0,0 +1,365 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="4.20">
<programVersion>4.2.0</programVersion>
<programRevision>3fc7989</programRevision>
<Score>
<Division>480</Division>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<open>1</open>
<metaTag name="arranger"></metaTag>
<metaTag name="composer">Klaus Rettinghaus</metaTag>
<metaTag name="copyright"></metaTag>
<metaTag name="creationDate">2023-09-30</metaTag>
<metaTag name="lyricist"></metaTag>
<metaTag name="platform"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="subtitle"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workTitle">Full range of noteheads</metaTag>
<Part id="1">
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Piano</trackName>
<Instrument id="piano">
<longName>Piano</longName>
<trackName>Piano</trackName>
<minPitchP>21</minPitchP>
<maxPitchP>108</maxPitchP>
<minPitchA>21</minPitchA>
<maxPitchA>108</maxPitchA>
<instrumentId>keyboard.piano</instrumentId>
<clef staff="2">F</clef>
<Articulation>
<velocity>100</velocity>
<gateTime>95</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>150</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="sforzatoStaccato">
<velocity>150</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoStaccato">
<velocity>120</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoTenuto">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="0"/>
<controller ctrl="10" value="63"/>
<synti>Fluid</synti>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<VBox>
<height>5</height>
<boxAutoSize>0</boxAutoSize>
<Text>
<style>title</style>
<text>Full range of noteheads</text>
</Text>
</VBox>
<Measure>
<voice>
<Clef>
<concertClefType>G</concertClefType>
<transposingClefType>G</transposingClefType>
<isHeader>1</isHeader>
</Clef>
<TimeSig>
<sigN>2</sigN>
<sigD>4</sigD>
</TimeSig>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>cross</head>
<dead>1</dead>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>plus</head>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>xcircle</head>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>withx</head>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>triangle-up</head>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>triangle-down</head>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>slashed1</head>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>slashed2</head>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>diamond</head>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>diamond-old</head>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>circled</head>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>circled-large</head>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>large-arrow</head>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>altbrevis</head>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>slash</head>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>large-diamond</head>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>sol</head>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>la</head>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>fa</head>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>mi</head>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>do</head>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>re</head>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>ti</head>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>heavy-cross</head>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<head>heavy-cross-hat</head>
</Note>
</Chord>
</voice>
</Measure>
</Staff>
</Score>
</museScore>

0 comments on commit 64575bd

Please sign in to comment.