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 bach ornaments #306

Merged
merged 3 commits into from
Apr 22, 2013
Merged
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
87 changes: 80 additions & 7 deletions mscore/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ int SlurHandler::findSlur(const Slur* s) const
void SlurHandler::doSlurStart(Chord* chord, Notations& notations, Xml& xml)
{
// search for slur(s) starting at this chord
for(Spanner* sp = chord->spannerFor(); sp; sp = sp->next()) {
for (Spanner* sp = chord->spannerFor(); sp; sp = sp->next()) {
if (sp->type() != Element::SLUR)
continue;
const Slur* s = static_cast<const Slur*>(sp);
Expand Down Expand Up @@ -477,7 +477,7 @@ void SlurHandler::doSlurStart(Chord* chord, Notations& notations, Xml& xml)
void SlurHandler::doSlurStop(Chord* chord, Notations& notations, Xml& xml)
{
// search for slur(s) stopping at this chord but not on slur list yet
for(Spanner* sp = chord->spannerBack(); sp; sp = sp->next()) {
for (Spanner* sp = chord->spannerBack(); sp; sp = sp->next()) {
if (sp->type() != Element::SLUR)
continue;
const Slur* s = static_cast<const Slur*>(sp);
Expand Down Expand Up @@ -712,7 +712,7 @@ static void findTrills(Measure* measure, int strack, int etrack, TrillHash& tril
// loop over all segments in this measure
for (Segment* seg = measure->first(); seg; seg = seg->next()) {
// loop over all spanners in this segment
for(Spanner* e = seg->spannerFor(); e; e = e->next()) {
for (Spanner* e = seg->spannerFor(); e; e = e->next()) {

if (e->type() == Element::TRILL && strack <= e->track() && e->track() < etrack) {

Expand Down Expand Up @@ -1217,7 +1217,7 @@ static QString tick2xml(const int ticks, int* dots)

static Volta* findVolta(Measure* m, bool /*left*/)
{
for(Spanner* el = m->spannerFor(); el; el = el->next()) {
for (Spanner* el = m->spannerFor(); el; el = el->next()) {
if (el->type() != Element::VOLTA)
continue;
return (Volta*) el;
Expand Down Expand Up @@ -1640,6 +1640,15 @@ static void chordAttributes(Chord* chord, Notations& notations, Technical& techn
case Articulation_Trill:
case Articulation_Prall:
case Articulation_Mordent:
case Articulation_PrallPrall:
case Articulation_PrallMordent:
case Articulation_UpPrall:
case Articulation_DownPrall:
case Articulation_UpMordent:
case Articulation_DownMordent:
case Articulation_PrallDown:
case Articulation_PrallUp:
case Articulation_LinePrall:
// ignore, handled with ornaments
break;
case Articulation_Plusstop:
Expand Down Expand Up @@ -1747,6 +1756,70 @@ static void chordAttributes(Chord* chord, Notations& notations, Technical& techn
xml.tagE("mordent");
}
break;
case Articulation_PrallPrall:
{
notations.tag(xml);
ornaments.tag(xml);
xml.tagE("inverted-mordent long=\"yes\"");
}
break;
case Articulation_PrallMordent:
{
notations.tag(xml);
ornaments.tag(xml);
xml.tagE("mordent long=\"yes\"");
}
break;
case Articulation_UpPrall:
{
notations.tag(xml);
ornaments.tag(xml);
xml.tagE("inverted-mordent long=\"yes\" approach=\"below\"");
}
break;
case Articulation_DownPrall:
{
notations.tag(xml);
ornaments.tag(xml);
xml.tagE("inverted-mordent long=\"yes\" approach=\"above\"");
}
break;
case Articulation_UpMordent:
{
notations.tag(xml);
ornaments.tag(xml);
xml.tagE("mordent long=\"yes\" approach=\"below\"");
}
break;
case Articulation_DownMordent:
{
notations.tag(xml);
ornaments.tag(xml);
xml.tagE("mordent long=\"yes\" approach=\"above\"");
}
break;
case Articulation_PrallDown:
{
notations.tag(xml);
ornaments.tag(xml);
xml.tagE("inverted-mordent long=\"yes\" departure=\"below\"");
}
break;
case Articulation_PrallUp:
{
notations.tag(xml);
ornaments.tag(xml);
xml.tagE("inverted-mordent long=\"yes\" departure=\"above\"");
}
break;
case Articulation_LinePrall:
{
// MusicXML 3.0 does not distinguish between downprall and lineprall
notations.tag(xml);
ornaments.tag(xml);
xml.tagE("inverted-mordent long=\"yes\" approach=\"above\"");
}
break;
case Articulation_Schleifer:
{
notations.tag(xml);
Expand Down Expand Up @@ -2984,7 +3057,7 @@ void ExportMusicXml::dynamic(Dynamic const* const dyn, int staff)

directionTag(xml, attr, dyn);
xml.stag("direction-type");
if ( st == Dynamic::DYNAMIC_p
if (st == Dynamic::DYNAMIC_p
|| st == Dynamic::DYNAMIC_pp
|| st == Dynamic::DYNAMIC_ppp
|| st == Dynamic::DYNAMIC_pppp
Expand Down Expand Up @@ -3605,7 +3678,7 @@ static void figuredBass(Xml& xml, int strack, int etrack, int track, const Chord
static void spannerStart(ExportMusicXml* exp, int strack, int etrack, int track, int sstaff, Segment* seg)
{
if (seg->segmentType() == Segment::SegChordRest) {
for(Spanner* e = seg->spannerFor(); e; e = e->next()) {
for (Spanner* e = seg->spannerFor(); e; e = e->next()) {

int wtrack = -1; // track to write spanner

Expand Down Expand Up @@ -3648,7 +3721,7 @@ static void spannerStart(ExportMusicXml* exp, int strack, int etrack, int track,
static void spannerStop(ExportMusicXml* exp, int strack, int etrack, int track, int sstaff, Segment* seg)
{
if (seg->segmentType() == Segment::SegChordRest) {
for(Spanner* e = seg->spannerBack(); e; e = e->next()) {
for (Spanner* e = seg->spannerBack(); e; e = e->next()) {

int wtrack = -1; // track to write spanner

Expand Down
44 changes: 40 additions & 4 deletions mscore/importxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2769,7 +2769,7 @@ void MusicXml::direction(Measure* measure, int staff, QDomElement e)
else {
hairpin = new Hairpin(score);
hairpin->setHairpinType(type == "crescendo"
? Hairpin::CRESCENDO : Hairpin::DECRESCENDO);
? Hairpin::CRESCENDO : Hairpin::DECRESCENDO);
hairpin->setPlacement(placement == "above" ? Element::ABOVE : Element::BELOW);

if (hasYoffset)
Expand Down Expand Up @@ -3815,6 +3815,41 @@ static void addArticulationToChord(ChordRest* cr, ArticulationType articSym, QSt
cr->add(na);
}

//---------------------------------------------------------
// addMordentToChord
//---------------------------------------------------------

/**
Add Mordent to Chord.
*/

static void addMordentToChord(ChordRest* cr, QString name, QString attrLong, QString attrAppr, QString attrDep)
{
ArticulationType articSym = ARTICULATIONS; // legal but impossible ArticulationType value here indicating "not found"
if (name == "inverted-mordent") {
if ((attrLong == "" || attrLong == "no") && attrAppr == "" && attrDep == "") articSym = Articulation_Prall;
else if (attrLong == "yes" && attrAppr == "" && attrDep == "") articSym = Articulation_PrallPrall;
else if (attrLong == "yes" && attrAppr == "below" && attrDep == "") articSym = Articulation_UpPrall;
else if (attrLong == "yes" && attrAppr == "above" && attrDep == "") articSym = Articulation_DownPrall;
else if (attrLong == "yes" && attrAppr == "" && attrDep == "below") articSym = Articulation_PrallDown;
else if (attrLong == "yes" && attrAppr == "" && attrDep == "above") articSym = Articulation_PrallUp;
}
else if (name == "mordent") {
if ((attrLong == "" || attrLong == "no") && attrAppr == "" && attrDep == "") articSym = Articulation_Mordent;
else if (attrLong == "yes" && attrAppr == "" && attrDep == "") articSym = Articulation_PrallMordent;
else if (attrLong == "yes" && attrAppr == "below" && attrDep == "") articSym = Articulation_UpMordent;
else if (attrLong == "yes" && attrAppr == "above" && attrDep == "") articSym = Articulation_DownMordent;
}
if (articSym != ARTICULATIONS) {
Articulation* na = new Articulation(cr->score());
na->setArticulationType(articSym);
cr->add(na);
}
else
qDebug("unknown ornament: name '%s' long '%s' approach '%s' departure '%s'",
qPrintable(name), qPrintable(attrLong), qPrintable(attrAppr), qPrintable(attrDep));
}

//---------------------------------------------------------
// readArticulations
//---------------------------------------------------------
Expand All @@ -3838,8 +3873,6 @@ static bool readArticulations(ChordRest* cr, QString mxmlName)
map["staccato"] = Articulation_Staccato;
map["tenuto"] = Articulation_Tenuto;
map["turn"] = Articulation_Turn;
map["mordent"] = Articulation_Mordent;
map["inverted-mordent"] = Articulation_Prall;
map["inverted-turn"] = Articulation_Reverseturn;
map["stopped"] = Articulation_Plusstop;
map["up-bow"] = Articulation_Upbow;
Expand Down Expand Up @@ -4191,6 +4224,9 @@ void MusicXml::xmlNotations(Note* note, ChordRest* cr, int trk, int ticks, QDomE
else if (eee.tagName() == "delayed-turn")
// TODO: actually this should be offset a bit to the right
addArticulationToChord(cr, Articulation_Turn, "");
else if (eee.tagName() == "inverted-mordent"
|| eee.tagName() == "mordent")
addMordentToChord(cr, eee.tagName(), eee.attribute("long"), eee.attribute("approach"), eee.attribute("departure"));
else
domError(eee);
}
Expand Down Expand Up @@ -4826,7 +4862,7 @@ void MusicXml::xmlNote(Measure* measure, int staff, const QString& partId, Beam*
// get pitch from instrument definition in drumset instead
int pitch = drumsets[partId][instrId].pitch;
note->setPitch(pitch);
// TODO - does this need to be key-aware?
// TODO - does this need to be key-aware?
note->setTpc(pitch2tpc(pitch, KEY_C, PREFER_NEAREST)); // TODO: necessary ?
}
else
Expand Down
91 changes: 91 additions & 0 deletions mtest/musicxml/io/testHarmony3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise>
<work>
<work-number>MuseScore testfile</work-number>
<work-title>Harmony 2</work-title>
</work>
<identification>
<creator type="composer">Leon Vinken</creator>
<encoding>
<software>MuseScore 0.7.0</software>
<encoding-date>2007-09-10</encoding-date>
</encoding>
</identification>
<part-list>
<score-part id="P1">
<part-name>Voice</part-name>
<part-abbreviation>Vo.</part-abbreviation>
<score-instrument id="P1-I3">
<instrument-name>Voice</instrument-name>
</score-instrument>
<midi-instrument id="P1-I3">
<midi-channel>1</midi-channel>
<midi-program>53</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>
<mode>major</mode>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<clef>
<sign>G</sign>
<line>2</line>
</clef>
</attributes>
<harmony>
<root>
<root-step>C</root-step>
</root>
<kind>major</kind>
<frame>
<frame-strings>6</frame-strings>
<frame-frets>4</frame-frets>
<frame-note>
<string>5</string>
<fret>3</fret>
</frame-note>
<frame-note>
<string>4</string>
<fret>2</fret>
</frame-note>
<frame-note>
<string>3</string>
<fret>0</fret>
</frame-note>
<frame-note>
<string>2</string>
<fret>1</fret>
</frame-note>
<frame-note>
<string>1</string>
<fret>0</fret>
</frame-note>
</frame>
</harmony>
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>whole</type>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise>
Loading