Intermediate fix: MXML I/O and Selection Filter tests

- MXML I/O code has been adapted to the new glissando code.
- Ref. scores for Selection filter tests have been updated.

Guitar Pro: import code needs to be adapted to the new glissando code and I have no idea how to do that.
This commit is contained in:
Maurizio M. Gavioli 2014-12-21 09:34:24 +01:00
parent f5d831a023
commit 9c4ac9e97c
5 changed files with 146 additions and 76 deletions

View file

@ -243,14 +243,14 @@ public:
//--------------------------------------------------------- //---------------------------------------------------------
class GlissandoHandler { class GlissandoHandler {
const Chord* glissChrd[MAX_NUMBER_LEVEL]; const Note* glissNote[MAX_NUMBER_LEVEL];
const Chord* slideChrd[MAX_NUMBER_LEVEL]; const Note* slideNote[MAX_NUMBER_LEVEL];
int findChord(const Chord* c, int st) const; int findNote(const Note* note, int type) const;
public: public:
GlissandoHandler(); GlissandoHandler();
void doGlissandoStart(Chord* chord, Notations& notations, Xml& xml); void doGlissandoStart(Glissando* gliss, Notations& notations, Xml& xml);
void doGlissandoStop(Chord* chord, Notations& notations, Xml& xml); void doGlissandoStop(Glissando* gliss, Notations& notations, Xml& xml);
}; };
//--------------------------------------------------------- //---------------------------------------------------------
@ -637,25 +637,25 @@ static void glissando(const Glissando* gli, int number, bool start, Notations& n
GlissandoHandler::GlissandoHandler() GlissandoHandler::GlissandoHandler()
{ {
for (int i = 0; i < MAX_NUMBER_LEVEL; ++i) { for (int i = 0; i < MAX_NUMBER_LEVEL; ++i) {
glissChrd[i] = 0; glissNote[i] = 0;
slideChrd[i] = 0; slideNote[i] = 0;
} }
} }
//--------------------------------------------------------- //---------------------------------------------------------
// findChord -- get index of chord in chord table for subtype st // findNote -- get index of Note in note table for subtype type
// return -1 if not found // return -1 if not found
//--------------------------------------------------------- //---------------------------------------------------------
int GlissandoHandler::findChord(const Chord* c, int st) const int GlissandoHandler::findNote(const Note* note, int type) const
{ {
if (st != 0 && st != 1) { if (type != 0 && type != 1) {
qDebug("GlissandoHandler::findChord: unknown glissando subtype %d", st); qDebug("GlissandoHandler::findNote: unknown glissando subtype %d", type);
return -1; return -1;
} }
for (int i = 0; i < MAX_NUMBER_LEVEL; ++i) { for (int i = 0; i < MAX_NUMBER_LEVEL; ++i) {
if (st == 0 && slideChrd[i] == c) return i; if (type == 0 && slideNote[i] == note) return i;
if (st == 1 && glissChrd[i] == c) return i; if (type == 1 && glissNote[i] == note) return i;
} }
return -1; return -1;
} }
@ -664,56 +664,58 @@ int GlissandoHandler::findChord(const Chord* c, int st) const
// doGlissandoStart // doGlissandoStart
//--------------------------------------------------------- //---------------------------------------------------------
void GlissandoHandler::doGlissandoStart(Chord* chord, Notations& notations, Xml& xml) void GlissandoHandler::doGlissandoStart(Glissando* gliss, Notations& notations, Xml& xml)
{ {
/* Glissando::Type st = chord->glissando()->glissandoType(); Glissando::Type type = gliss->glissandoType();
if (st != Glissando::Type::STRAIGHT && st != Glissando::Type::WAVY) { if (type != Glissando::Type::STRAIGHT && type != Glissando::Type::WAVY) {
qDebug("doGlissandoStart: unknown glissando subtype %hhd", st); qDebug("doGlissandoStart: unknown glissando subtype %hhd", type);
return; return;
} }
Note* note = static_cast<Note*>(gliss->startElement());
// check if on chord list // check if on chord list
int i = findChord(chord, int(st)); int i = findNote(note, int(type));
if (i >= 0) { if (i >= 0) {
// print error and remove from list // print error and remove from list
qDebug("doGlissandoStart: chord %p already on list", chord); qDebug("doGlissandoStart: note for glissando/slide %p already on list", gliss);
if (st == Glissando::Type::STRAIGHT) slideChrd[i] = 0; if (type == Glissando::Type::STRAIGHT) slideNote[i] = 0;
if (st == Glissando::Type::WAVY) glissChrd[i] = 0; if (type == Glissando::Type::WAVY) glissNote[i] = 0;
} }
// find free slot to store it // find free slot to store it
i = findChord(0, int(st)); i = findNote(0, int(type));
if (i >= 0) { if (i >= 0) {
if (st == Glissando::Type::STRAIGHT) slideChrd[i] = chord; if (type == Glissando::Type::STRAIGHT) slideNote[i] = note;
if (st == Glissando::Type::WAVY) glissChrd[i] = chord; if (type == Glissando::Type::WAVY) glissNote[i] = note;
glissando(chord->glissando(), i + 1, true, notations, xml); glissando(gliss, i + 1, true, notations, xml);
} }
else else
qDebug("doGlissandoStart: no free slot"); */ qDebug("doGlissandoStart: no free slot");
} }
//--------------------------------------------------------- //---------------------------------------------------------
// doGlissandoStop // doGlissandoStop
//--------------------------------------------------------- //---------------------------------------------------------
void GlissandoHandler::doGlissandoStop(Chord* chord, Notations& notations, Xml& xml) void GlissandoHandler::doGlissandoStop(Glissando* gliss, Notations& notations, Xml& xml)
{ {
/* Glissando::Type st = chord->glissando()->glissandoType(); Glissando::Type type = gliss->glissandoType();
if (st != Glissando::Type::STRAIGHT && st != Glissando::Type::WAVY) { if (type != Glissando::Type::STRAIGHT && type != Glissando::Type::WAVY) {
qDebug("doGlissandoStart: unknown glissando subtype %hhd", st); qDebug("doGlissandoStart: unknown glissando subtype %hhd", type);
return; return;
} }
Note* note = static_cast<Note*>(gliss->startElement());
for (int i = 0; i < MAX_NUMBER_LEVEL; ++i) { for (int i = 0; i < MAX_NUMBER_LEVEL; ++i) {
if (st == Glissando::Type::STRAIGHT && slideChrd[i] == chord) { if (type == Glissando::Type::STRAIGHT && slideNote[i] == note) {
slideChrd[i] = 0; slideNote[i] = 0;
glissando(chord->glissando(), i + 1, false, notations, xml); glissando(gliss, i + 1, false, notations, xml);
return; return;
} }
if (st == Glissando::Type::WAVY && glissChrd[i] == chord) { if (type == Glissando::Type::WAVY && glissNote[i] == note) {
glissChrd[i] = 0; glissNote[i] = 0;
glissando(chord->glissando(), i + 1, false, notations, xml); glissando(gliss, i + 1, false, notations, xml);
return; return;
} }
} }
qDebug("doGlissandoStop: glissando chord %p not found", chord); */ qDebug("doGlissandoStop: glissando note %p not found", note);
} }
//--------------------------------------------------------- //---------------------------------------------------------
@ -2131,7 +2133,7 @@ static void arpeggiate(Arpeggio* arp, bool front, bool back, Xml& xml, Notations
} }
// find the next chord in the same track // find the next chord in the same track
/* NO LONGER NEEDED
static Chord* nextChord(Chord* ch) static Chord* nextChord(Chord* ch)
{ {
Segment* s = ch->segment(); Segment* s = ch->segment();
@ -2152,7 +2154,7 @@ static Chord* nextChord(Chord* ch)
} }
return c; return c;
} }
*/
//--------------------------------------------------------- //---------------------------------------------------------
// determineTupletNormalTicks // determineTupletNormalTicks
//--------------------------------------------------------- //---------------------------------------------------------
@ -2569,8 +2571,16 @@ void ExportMusicXml::chord(Chord* chord, int staff, const QList<Lyrics*>* ll, bo
if (chord->arpeggio()) { if (chord->arpeggio()) {
arpeggiate(chord->arpeggio(), note == nl.front(), note == nl.back(), xml, notations); arpeggiate(chord->arpeggio(), note == nl.front(), note == nl.back(), xml, notations);
} }
// write glissando (only for last note) for (Spanner* spanner : note->spannerFor())
/* Chord* ch = nextChord(chord); if (spanner->type() == Element::Type::GLISSANDO) {
gh.doGlissandoStart(static_cast<Glissando*>(spanner), notations, xml);
}
for (Spanner* spanner : note->spannerBack())
if (spanner->type() == Element::Type::GLISSANDO) {
gh.doGlissandoStop(static_cast<Glissando*>(spanner), notations, xml);
}
/* // write glissando (only for last note)
Chord* ch = nextChord(chord);
if ((note == nl.back()) && ch && ch->glissando()) { if ((note == nl.back()) && ch && ch->glissando()) {
gh.doGlissandoStart(ch, notations, xml); gh.doGlissandoStart(ch, notations, xml);
} }

View file

@ -783,13 +783,15 @@ void MusicXml::initPartState()
hairpins[i] = 0; hairpins[i] = 0;
for (int i = 0; i < MAX_NUMBER_LEVEL; ++i) for (int i = 0; i < MAX_NUMBER_LEVEL; ++i)
trills[i] = 0; trills[i] = 0;
for (int i = 0; i < MAX_NUMBER_LEVEL; ++i)
glissandi[i][0] = glissandi[i][1] = 0;
pedal = 0; pedal = 0;
pedalContinue = 0; pedalContinue = 0;
harmony = 0; harmony = 0;
tremStart = 0; tremStart = 0;
figBass = 0; figBass = 0;
glissandoText = ""; // glissandoText = "";
glissandoColor = ""; // glissandoColor = "";
} }
//--------------------------------------------------------- //---------------------------------------------------------
@ -4731,7 +4733,7 @@ void MusicXml::xmlNotations(Note* note, ChordRest* cr, int trk, int tick, int ti
QString wavyLineType; QString wavyLineType;
int wavyLineNo = 0; int wavyLineNo = 0;
QString arpeggioType; QString arpeggioType;
QString glissandoType; // QString glissandoType;
int breath = -1; int breath = -1;
int tremolo = 0; int tremolo = 0;
QString tremoloType; QString tremoloType;
@ -4970,6 +4972,52 @@ void MusicXml::xmlNotations(Note* note, ChordRest* cr, int trk, int tick, int ti
} }
else if (ee.tagName() == "non-arpeggiate") else if (ee.tagName() == "non-arpeggiate")
arpeggioType = "non-arpeggiate"; arpeggioType = "non-arpeggiate";
if (ee.tagName() == "glissando" || ee.tagName() == "slide") {
int n = ee.attribute(QString("number"), "1").toInt() - 1;
QString spannerType = ee.attribute(QString("type"));
int tag = ee.tagName() == "slide" ? 0 : 1;
// QString lineType = ee.attribute(QString("line-type"), "solid");
Glissando*& gliss = glissandi[n][tag];
if (spannerType == "start") {
if (gliss) {
qDebug("overlapping glissando/slide %d not supported", n+1);
delete gliss;
gliss = 0;
}
else {
gliss = new Glissando(score);
gliss->setAnchor(Spanner::Anchor::NOTE);
gliss->setStartElement(note);
gliss->setTick(tick);
gliss->setTrack(track);
gliss->setParent(note);
gliss->setText(ee.text());
QColor color(ee.attribute("color"));
if (color.isValid())
gliss->setColor(color);
gliss->setGlissandoType(tag == 0 ? Glissando::Type::STRAIGHT : Glissando::Type::WAVY);
spanners[gliss] = QPair<int, int>(tick, -1);
// qDebug("glissando/slide=%p inserted at first tick %d", gliss, tick);
}
}
else if (spannerType == "stop") {
if (!gliss) {
qDebug("glissando/slide %d stop without start", n+1);
}
else {
spanners[gliss].second = tick + ticks;
gliss->setEndElement(note);
gliss->setTick2(tick);
gliss->setTrack2(track);
// qDebug("glissando/slide=%p second tick %d", gliss, tick);
gliss = 0;
}
}
else
qDebug("unknown glissando/slide type %s", qPrintable(spannerType));
}
/*
// glissando and slide are added to the "stop" chord only // glissando and slide are added to the "stop" chord only
// but text and color are read at start // but text and color are read at start
else if (ee.tagName() == "glissando") { else if (ee.tagName() == "glissando") {
@ -4987,7 +5035,7 @@ void MusicXml::xmlNotations(Note* note, ChordRest* cr, int trk, int tick, int ti
else if (ee.attribute("type") == "stop") glissandoType = "slide"; else if (ee.attribute("type") == "stop") glissandoType = "slide";
} }
else else
domError(ee); domError(ee); */
} }
// no support for arpeggio on rest // no support for arpeggio on rest
if (!arpeggioType.isEmpty() && cr->type() == Element::Type::CHORD) { if (!arpeggioType.isEmpty() && cr->type() == Element::Type::CHORD) {
@ -5013,7 +5061,7 @@ void MusicXml::xmlNotations(Note* note, ChordRest* cr, int trk, int tick, int ti
else else
cr->add(a); cr->add(a);
} }
/*
if (!glissandoType.isEmpty()) { if (!glissandoType.isEmpty()) {
Glissando* g = new Glissando(score); Glissando* g = new Glissando(score);
if (glissandoType == "slide") if (glissandoType == "slide")
@ -5040,14 +5088,14 @@ void MusicXml::xmlNotations(Note* note, ChordRest* cr, int trk, int tick, int ti
glissandoColor = ""; glissandoColor = "";
} }
} }
/* if ((static_cast<Chord*>(cr))->glissando()) { if ((static_cast<Chord*>(cr))->glissando()) {
// there can be only one // there can be only one
delete g; delete g;
g = 0; g = 0;
} }
else else
cr->add(g); */ cr->add(g);
} } */
if (!wavyLineType.isEmpty()) { if (!wavyLineType.isEmpty()) {
int n = wavyLineNo - 1; int n = wavyLineNo - 1;

View file

@ -34,27 +34,28 @@
namespace Ms { namespace Ms {
class Beam;
class Chord;
class ChordRest;
class FiguredBass;
class Glissando;
class Hairpin;
class Harmony;
class Instrument; class Instrument;
class Lyrics;
class Measure; class Measure;
class Tuplet;
class Tie;
class Slur;
class Part;
class Score;
class Note; class Note;
class Ottava; class Ottava;
class Trill; class Part;
class Pedal; class Pedal;
class Volta; class Score;
class TextLine; class Slur;
class Chord;
class Harmony;
class Hairpin;
class Spanner; class Spanner;
class Lyrics; class TextLine;
class ChordRest; class Tie;
class Beam; class Trill;
class FiguredBass; class Tuplet;
class Volta;
enum class StaffTypes : char; enum class StaffTypes : char;
//--------------------------------------------------------- //---------------------------------------------------------
@ -182,6 +183,7 @@ class MusicXml {
Ottava* ottavas[MAX_NUMBER_LEVEL]; ///< Current ottavas Ottava* ottavas[MAX_NUMBER_LEVEL]; ///< Current ottavas
Hairpin* hairpins[MAX_NUMBER_LEVEL]; ///< Current hairpins Hairpin* hairpins[MAX_NUMBER_LEVEL]; ///< Current hairpins
Trill* trills[MAX_NUMBER_LEVEL]; ///< Current trills Trill* trills[MAX_NUMBER_LEVEL]; ///< Current trills
Glissando* glissandi[MAX_NUMBER_LEVEL][2]; ///< Current slides ([0]) / glissandi ([1])
Tie* tie; Tie* tie;
Volta* lastVolta; Volta* lastVolta;
@ -211,8 +213,8 @@ class MusicXml {
FiguredBass* figBass; ///< Current figured bass element (to attach to next note) FiguredBass* figBass; ///< Current figured bass element (to attach to next note)
QVector<FiguredBass*> figBassList; ///< List of figured bass elements under a single note QVector<FiguredBass*> figBassList; ///< List of figured bass elements under a single note
Beam::Mode beamMode; ///< Current beam mode Beam::Mode beamMode; ///< Current beam mode
QString glissandoText; ///< Glissando text at glissando start // QString glissandoText; ///< Glissando text at glissando start
QString glissandoColor; ///< Glissando color at glissando start // QString glissandoColor; ///< Glissando color at glissando start
int pageWidth; ///< Page width read from defaults int pageWidth; ///< Page width read from defaults
int pageHeight; ///< Page height read from defaults int pageHeight; ///< Page height read from defaults

View file

@ -10,6 +10,14 @@
<track>0</track> <track>0</track>
<pitch>72</pitch> <pitch>72</pitch>
<tpc>14</tpc> <tpc>14</tpc>
<Glissando id="2">
<text>gliss.</text>
<subtype>0</subtype>
<track>0</track>
<diagonal>1</diagonal>
<lineWidth>0.15</lineWidth>
<anchor>3</anchor>
</Glissando>
</Note> </Note>
</Chord> </Chord>
<Chord> <Chord>
@ -19,12 +27,8 @@
<track>0</track> <track>0</track>
<pitch>60</pitch> <pitch>60</pitch>
<tpc>14</tpc> <tpc>14</tpc>
<endSpanner id="2"/>
</Note> </Note>
<Glissando>
<text>gliss.</text>
<subtype>0</subtype>
<track>0</track>
</Glissando>
</Chord> </Chord>
<Chord> <Chord>
<track>0</track> <track>0</track>
@ -33,6 +37,14 @@
<track>0</track> <track>0</track>
<pitch>67</pitch> <pitch>67</pitch>
<tpc>15</tpc> <tpc>15</tpc>
<Glissando id="3">
<text>gliss.</text>
<subtype>1</subtype>
<track>0</track>
<diagonal>1</diagonal>
<lineWidth>0.15</lineWidth>
<anchor>3</anchor>
</Glissando>
</Note> </Note>
</Chord> </Chord>
<Chord> <Chord>
@ -42,12 +54,8 @@
<track>0</track> <track>0</track>
<pitch>79</pitch> <pitch>79</pitch>
<tpc>15</tpc> <tpc>15</tpc>
<endSpanner id="3"/>
</Note> </Note>
<Glissando>
<text>gliss.</text>
<subtype>1</subtype>
<track>0</track>
</Glissando>
</Chord> </Chord>
</Staff> </Staff>
</StaffList> </StaffList>

View file

@ -19,6 +19,7 @@
<track>0</track> <track>0</track>
<pitch>60</pitch> <pitch>60</pitch>
<tpc>14</tpc> <tpc>14</tpc>
<endSpanner id="2"/>
</Note> </Note>
</Chord> </Chord>
<Chord> <Chord>
@ -37,6 +38,7 @@
<track>0</track> <track>0</track>
<pitch>79</pitch> <pitch>79</pitch>
<tpc>15</tpc> <tpc>15</tpc>
<endSpanner id="3"/>
</Note> </Note>
</Chord> </Chord>
</Staff> </Staff>