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] Add full support for hand bells #25934

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ class ExportMusicXml : public muse::Injectable
static String fermataPosition(const Fermata* const fermata);

private:

int findBracket(const TextLineBase* tl) const;
int findDashes(const TextLineBase* tl) const;
int findHairpin(const Hairpin* tl) const;
Expand Down Expand Up @@ -3331,7 +3330,7 @@ static String symIdToTechn(const SymId sid)
return u"smear";
break;
case SymId::brassMuteOpen:
// return "open-string";
// return u"open-string";
return u"open";
break;
case SymId::brassMuteHalfClosed:
Expand All @@ -3346,6 +3345,42 @@ static String symIdToTechn(const SymId sid)
case SymId::guitarGolpe:
return u"golpe";
break;
case SymId::handbellsBelltree:
return u"belltree";
break;
case SymId::handbellsDamp3:
return u"damp";
break;
case SymId::handbellsEcho1:
return u"echo";
break;
case SymId::handbellsGyro:
return u"gyro";
break;
case SymId::handbellsHandMartellato:
return u"hand martellato";
break;
case SymId::handbellsMalletLft:
return u"mallet lift";
break;
case SymId::handbellsMalletBellOnTable:
return u"mallet table";
break;
case SymId::handbellsMartellato:
return u"martellato";
break;
case SymId::handbellsMartellatoLift:
return u"martellato lift";
break;
case SymId::handbellsMutedMartellato:
return u"muted martellato";
break;
case SymId::handbellsPluckLift:
return u"pluck lift";
break;
case SymId::handbellsSwing:
return u"swing";
break;
default:
; // nothing
break;
Expand Down Expand Up @@ -3587,6 +3622,14 @@ void ExportMusicXml::chordAttributes(Chord* chord, Notations& notations, Technic
m_xml.startElementRaw(mxmlTechn);
m_xml.tag("natural");
m_xml.endElement();
} else if (String::fromAscii(SymNames::nameForSymId(sid).ascii()).startsWith(u"handbells")) {
rettinghaus marked this conversation as resolved.
Show resolved Hide resolved
String handbell = u"handbell";
handbell += color2xml(a);
handbell += ExportMusicXml::positioningAttributes(a);
if (!placement.empty()) {
handbell += String(u" placement=\"%1\"").arg(placement);
}
m_xml.tagRaw(handbell, symIdToTechn(sid));
} else if (mxmlTechn.startsWith(u"harmon")) {
m_xml.startElementRaw(mxmlTechn);
XmlWriter::Attributes location = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,20 @@ static bool convertArticulationToSymId(const String& mxmlName, SymId& id)
{ u"brass-bend", SymId::brassBend },
{ u"flip", SymId::brassFlip },
{ u"smear", SymId::brassSmear },
{ u"open", SymId::brassMuteOpen }
{ u"open", SymId::brassMuteOpen },

{ u"belltree", SymId::handbellsBelltree },
{ u"damp", SymId::handbellsDamp3 },
{ u"echo", SymId::handbellsEcho1 },
{ u"gyro", SymId::handbellsGyro },
{ u"hand martellato", SymId::handbellsHandMartellato },
{ u"mallet lift", SymId::handbellsMalletLft },
{ u"mallet table", SymId::handbellsMalletBellOnTable },
{ u"martellato", SymId::handbellsMartellato },
{ u"martellato lift", SymId::handbellsMartellatoLift },
{ u"muted martellato", SymId::handbellsMutedMartellato },
{ u"pluck lift", SymId::handbellsPluckLift },
{ u"swing", SymId::handbellsSwing }
};

auto it = map.find(mxmlName);
Expand Down Expand Up @@ -8149,6 +8162,11 @@ void MusicXmlParserNotations::technical()
m_notations.push_back(notation);
} else if (m_e.name() == "harmonic") {
harmonic();
} else if (m_e.name() == "handbell") {
const std::vector<XmlStreamReader::Attribute> attributes = m_e.attributes();
convertArticulationToSymId(m_e.readText(), id);
m_notations.push_back(Notation::notationWithAttributes(String::fromAscii(m_e.name().ascii()),
attributes, u"technical", id));
rettinghaus marked this conversation as resolved.
Show resolved Hide resolved
} else if (m_e.name() == "harmon-mute") {
harmonMute();
} else if (m_e.name() == "other-technical") {
Expand Down
236 changes: 236 additions & 0 deletions src/importexport/musicxml/tests/data/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>
3 changes: 3 additions & 0 deletions src/importexport/musicxml/tests/musicxml_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@ TEST_F(MusicXml_Tests, harpPedals) {
TEST_F(MusicXml_Tests, hairpinDynamics) {
musicXmlMscxExportTestRef("testHairpinDynamics");
}
TEST_F(MusicXml_Tests, handbells) {
musicXmlIoTest("testHandbells");
}
TEST_F(MusicXml_Tests, harmony1) {
musicXmlIoTest("testHarmony1");
}
Expand Down