Skip to content

Commit

Permalink
[MusicXML] Add full support for hand bells
Browse files Browse the repository at this point in the history
Backport of musescore#25934
  • Loading branch information
Jojo-Schmitz committed Dec 28, 2024
1 parent a904e30 commit 21dbbe2
Show file tree
Hide file tree
Showing 4 changed files with 303 additions and 2 deletions.
45 changes: 45 additions & 0 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3100,6 +3100,42 @@ static QString symIdToTechn(const SymId sid)
case SymId::guitarGolpe:
return "golpe";
break;
case SymId::handbellsBelltree:
return "belltree";
break;
case SymId::handbellsDamp3:
return "damp";
break;
case SymId::handbellsEcho1:
return "echo";
break;
case SymId::handbellsGyro:
return "gyro";
break;
case SymId::handbellsHandMartellato:
return "hand martellato";
break;
case SymId::handbellsMalletLft:
return "mallet lift";
break;
case SymId::handbellsMalletBellOnTable:
return "mallet table";
break;
case SymId::handbellsMartellato:
return "martellato";
break;
case SymId::handbellsMartellatoLift:
return "martellato lift";
break;
case SymId::handbellsMutedMartellato:
return "muted martellato";
break;
case SymId::handbellsPluckLift:
return "pluck lift";
break;
case SymId::handbellsSwing:
return "swing";
break;
default:
; // nothing
break;
Expand Down Expand Up @@ -3332,6 +3368,15 @@ void ExportMusicXml::chordAttributes(Chord* chord, Notations& notations, Technic
_xml.tagE("natural");
_xml.etag();
}
else if (QString(Sym::id2name(sid)).startsWith("handbells")) {
QString handbell = "handbell";
handbell += color2xml(a);
handbell += positioningAttributes(a);
if (!placement.isEmpty()) {
handbell += QString(" placement=\"%1\"").arg(placement);
}
_xml.tag(handbell, symIdToTechn(sid));
}
else if (mxmlTechn.startsWith("harmon")) {
_xml.stag(mxmlTechn);
QString location = {};
Expand Down
23 changes: 21 additions & 2 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,19 @@ static bool convertArticulationToSymId(const QString& mxmlName, SymId& id)
map["smear"] = SymId::brassSmear ;
map["open"] = SymId::brassMuteOpen;

map["belltree"] = SymId::handbellsBelltree;
map["damp"] = SymId::handbellsDamp3;
map["echo"] = SymId::handbellsEcho1;
map["gyro"] = SymId::handbellsGyro;
map["hand martellato"] = SymId::handbellsHandMartellato;
map["mallet lift"] = SymId::handbellsMalletLft;
map["mallet table"] = SymId::handbellsMalletBellOnTable;
map["martellato"] = SymId::handbellsMartellato;
map["martellato lift"] = SymId::handbellsMartellatoLift;
map["muted martellato"] = SymId::handbellsMutedMartellato;
map["pluck lift"] = SymId::handbellsPluckLift;
map["swing"] = SymId::handbellsSwing;

if (map.contains(mxmlName)) {
id = map.value(mxmlName);
return true;
Expand Down Expand Up @@ -7687,7 +7700,7 @@ void MusicXMLParserNotations::ornaments()
void MusicXMLParserNotations::technical()
{
while (_e.readNextStartElement()) {
SymId id { SymId::noSym };
SymId id = SymId::noSym;
if (convertArticulationToSymId(_e.name().toString(), id)) {
Notation notation = Notation::notationWithAttributes(_e.name().toString(),
_e.attributes(), "technical", id);
Expand All @@ -7702,10 +7715,16 @@ void MusicXMLParserNotations::technical()
}
else if (_e.name() == "harmonic")
harmonic();
else if (_e.name() == "handbell") {
QXmlStreamAttributes attributes = _e.attributes();
convertArticulationToSymId(_e.readElementText(), id);
_notations.push_back(Notation::notationWithAttributes(_e.name().toString(),
attributes, "technical", id));
}
else if (_e.name() == "harmon-mute")
harmonMute();
else if (_e.name() == "other-technical")
otherTechnical();
otherTechnical();
else
skipLogCurrElem();
}
Expand Down
236 changes: 236 additions & 0 deletions mtest/musicxml/io/testHandbells.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 4.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="4.0">
<work>
<work-title>Hand bell symbols test</work-title>
</work>
<identification>
<creator type="composer">Klaus Rettinghaus</creator>
<encoding>
<software>MuseScore 0.7.0</software>
<encoding-date>2007-09-10</encoding-date>
<supports element="accidental" type="yes"/>
<supports element="beam" type="yes"/>
<supports element="print" attribute="new-page" type="no"/>
<supports element="print" attribute="new-system" type="no"/>
<supports element="stem" type="yes"/>
</encoding>
</identification>
<part-list>
<score-part id="P1">
<part-name>Hand Bells</part-name>
<part-abbreviation>Ha. Be.</part-abbreviation>
<score-instrument id="P1-I1">
<instrument-name>Hand Bells</instrument-name>
</score-instrument>
<midi-device id="P1-I1" port="1"></midi-device>
<midi-instrument id="P1-I1">
<midi-channel>2</midi-channel>
<midi-program>113</midi-program>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
</part-list>
<part id="P1">
<measure number="1">
<attributes>
<divisions>1</divisions>
<key>
<fifths>0</fifths>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<staves>2</staves>
<clef number="1">
<sign>G</sign>
<line>2</line>
</clef>
<clef number="2">
<sign>F</sign>
<line>4</line>
</clef>
<transpose>
<diatonic>0</diatonic>
<chromatic>0</chromatic>
<octave-change>1</octave-change>
</transpose>
</attributes>
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
<staff>1</staff>
</note>
<backup>
<duration>4</duration>
</backup>
<note>
<pitch>
<step>F</step>
<octave>3</octave>
</pitch>
<duration>2</duration>
<voice>5</voice>
<type>half</type>
<stem>down</stem>
<staff>2</staff>
<notations>
<technical>
<handbell>belltree</handbell>
</technical>
</notations>
</note>
<note>
<pitch>
<step>A</step>
<octave>3</octave>
</pitch>
<duration>2</duration>
<voice>5</voice>
<type>half</type>
<stem>down</stem>
<staff>2</staff>
<notations>
<technical>
<handbell>damp</handbell>
</technical>
</notations>
</note>
</measure>
<measure number="2">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
<staff>1</staff>
</note>
<backup>
<duration>4</duration>
</backup>
<note>
<pitch>
<step>G</step>
<octave>3</octave>
</pitch>
<duration>2</duration>
<voice>5</voice>
<type>half</type>
<stem>down</stem>
<staff>2</staff>
<notations>
<technical>
<handbell placement="below">echo</handbell>
</technical>
</notations>
</note>
<note>
<pitch>
<step>C</step>
<octave>3</octave>
</pitch>
<duration>2</duration>
<voice>5</voice>
<type>half</type>
<stem>up</stem>
<staff>2</staff>
<notations>
<technical>
<handbell color="#FF00FF" placement="below">gyro</handbell>
</technical>
</notations>
</note>
</measure>
<measure number="3">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
<staff>1</staff>
</note>
<backup>
<duration>4</duration>
</backup>
<note>
<pitch>
<step>C</step>
<octave>3</octave>
</pitch>
<duration>2</duration>
<voice>5</voice>
<type>half</type>
<stem>up</stem>
<staff>2</staff>
<notations>
<technical>
<handbell placement="above">hand martellato</handbell>
</technical>
</notations>
</note>
<note>
<pitch>
<step>G</step>
<octave>3</octave>
</pitch>
<duration>2</duration>
<voice>5</voice>
<type>half</type>
<stem>down</stem>
<staff>2</staff>
<notations>
<technical>
<handbell placement="above">mallet lift</handbell>
</technical>
</notations>
</note>
</measure>
<measure number="4">
<note>
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
<staff>1</staff>
</note>
<backup>
<duration>4</duration>
</backup>
<note>
<pitch>
<step>A</step>
<octave>3</octave>
</pitch>
<duration>2</duration>
<voice>5</voice>
<type>half</type>
<stem>down</stem>
<staff>2</staff>
<notations>
<technical>
<handbell>mallet table</handbell>
</technical>
</notations>
</note>
<note>
<pitch>
<step>F</step>
<octave>3</octave>
</pitch>
<duration>2</duration>
<voice>5</voice>
<type>half</type>
<stem>down</stem>
<staff>2</staff>
<notations>
<technical>
<handbell>martellato</handbell>
</technical>
</notations>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise>
1 change: 1 addition & 0 deletions mtest/musicxml/io/tst_mxml_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ private slots:
void grace2() { mxmlIoTest("testGrace2"); }
void grace3() { mxmlIoTest("testGrace3"); }
void hairpinDynamics() { mxmlMscxExportTestRef("testHairpinDynamics"); }
void handbells() { mxmlIoTest("testHandbells"); }
void harmony1() { mxmlIoTest("testHarmony1"); }
void harmony2() { mxmlIoTest("testHarmony2"); }
void harmony3() { mxmlIoTest("testHarmony3"); }
Expand Down

0 comments on commit 21dbbe2

Please sign in to comment.