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:
parent
f5d831a023
commit
9c4ac9e97c
5 changed files with 146 additions and 76 deletions
|
@ -243,14 +243,14 @@ public:
|
|||
//---------------------------------------------------------
|
||||
|
||||
class GlissandoHandler {
|
||||
const Chord* glissChrd[MAX_NUMBER_LEVEL];
|
||||
const Chord* slideChrd[MAX_NUMBER_LEVEL];
|
||||
int findChord(const Chord* c, int st) const;
|
||||
const Note* glissNote[MAX_NUMBER_LEVEL];
|
||||
const Note* slideNote[MAX_NUMBER_LEVEL];
|
||||
int findNote(const Note* note, int type) const;
|
||||
|
||||
public:
|
||||
GlissandoHandler();
|
||||
void doGlissandoStart(Chord* chord, Notations& notations, Xml& xml);
|
||||
void doGlissandoStop(Chord* chord, Notations& notations, Xml& xml);
|
||||
void doGlissandoStart(Glissando* gliss, 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()
|
||||
{
|
||||
for (int i = 0; i < MAX_NUMBER_LEVEL; ++i) {
|
||||
glissChrd[i] = 0;
|
||||
slideChrd[i] = 0;
|
||||
glissNote[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
|
||||
//---------------------------------------------------------
|
||||
|
||||
int GlissandoHandler::findChord(const Chord* c, int st) const
|
||||
int GlissandoHandler::findNote(const Note* note, int type) const
|
||||
{
|
||||
if (st != 0 && st != 1) {
|
||||
qDebug("GlissandoHandler::findChord: unknown glissando subtype %d", st);
|
||||
if (type != 0 && type != 1) {
|
||||
qDebug("GlissandoHandler::findNote: unknown glissando subtype %d", type);
|
||||
return -1;
|
||||
}
|
||||
for (int i = 0; i < MAX_NUMBER_LEVEL; ++i) {
|
||||
if (st == 0 && slideChrd[i] == c) return i;
|
||||
if (st == 1 && glissChrd[i] == c) return i;
|
||||
if (type == 0 && slideNote[i] == note) return i;
|
||||
if (type == 1 && glissNote[i] == note) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -664,56 +664,58 @@ int GlissandoHandler::findChord(const Chord* c, int st) const
|
|||
// 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();
|
||||
if (st != Glissando::Type::STRAIGHT && st != Glissando::Type::WAVY) {
|
||||
qDebug("doGlissandoStart: unknown glissando subtype %hhd", st);
|
||||
Glissando::Type type = gliss->glissandoType();
|
||||
if (type != Glissando::Type::STRAIGHT && type != Glissando::Type::WAVY) {
|
||||
qDebug("doGlissandoStart: unknown glissando subtype %hhd", type);
|
||||
return;
|
||||
}
|
||||
Note* note = static_cast<Note*>(gliss->startElement());
|
||||
// check if on chord list
|
||||
int i = findChord(chord, int(st));
|
||||
int i = findNote(note, int(type));
|
||||
if (i >= 0) {
|
||||
// print error and remove from list
|
||||
qDebug("doGlissandoStart: chord %p already on list", chord);
|
||||
if (st == Glissando::Type::STRAIGHT) slideChrd[i] = 0;
|
||||
if (st == Glissando::Type::WAVY) glissChrd[i] = 0;
|
||||
qDebug("doGlissandoStart: note for glissando/slide %p already on list", gliss);
|
||||
if (type == Glissando::Type::STRAIGHT) slideNote[i] = 0;
|
||||
if (type == Glissando::Type::WAVY) glissNote[i] = 0;
|
||||
}
|
||||
// find free slot to store it
|
||||
i = findChord(0, int(st));
|
||||
i = findNote(0, int(type));
|
||||
if (i >= 0) {
|
||||
if (st == Glissando::Type::STRAIGHT) slideChrd[i] = chord;
|
||||
if (st == Glissando::Type::WAVY) glissChrd[i] = chord;
|
||||
glissando(chord->glissando(), i + 1, true, notations, xml);
|
||||
if (type == Glissando::Type::STRAIGHT) slideNote[i] = note;
|
||||
if (type == Glissando::Type::WAVY) glissNote[i] = note;
|
||||
glissando(gliss, i + 1, true, notations, xml);
|
||||
}
|
||||
else
|
||||
qDebug("doGlissandoStart: no free slot"); */
|
||||
qDebug("doGlissandoStart: no free slot");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// 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();
|
||||
if (st != Glissando::Type::STRAIGHT && st != Glissando::Type::WAVY) {
|
||||
qDebug("doGlissandoStart: unknown glissando subtype %hhd", st);
|
||||
Glissando::Type type = gliss->glissandoType();
|
||||
if (type != Glissando::Type::STRAIGHT && type != Glissando::Type::WAVY) {
|
||||
qDebug("doGlissandoStart: unknown glissando subtype %hhd", type);
|
||||
return;
|
||||
}
|
||||
Note* note = static_cast<Note*>(gliss->startElement());
|
||||
for (int i = 0; i < MAX_NUMBER_LEVEL; ++i) {
|
||||
if (st == Glissando::Type::STRAIGHT && slideChrd[i] == chord) {
|
||||
slideChrd[i] = 0;
|
||||
glissando(chord->glissando(), i + 1, false, notations, xml);
|
||||
if (type == Glissando::Type::STRAIGHT && slideNote[i] == note) {
|
||||
slideNote[i] = 0;
|
||||
glissando(gliss, i + 1, false, notations, xml);
|
||||
return;
|
||||
}
|
||||
if (st == Glissando::Type::WAVY && glissChrd[i] == chord) {
|
||||
glissChrd[i] = 0;
|
||||
glissando(chord->glissando(), i + 1, false, notations, xml);
|
||||
if (type == Glissando::Type::WAVY && glissNote[i] == note) {
|
||||
glissNote[i] = 0;
|
||||
glissando(gliss, i + 1, false, notations, xml);
|
||||
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
|
||||
|
||||
/* NO LONGER NEEDED
|
||||
static Chord* nextChord(Chord* ch)
|
||||
{
|
||||
Segment* s = ch->segment();
|
||||
|
@ -2152,7 +2154,7 @@ static Chord* nextChord(Chord* ch)
|
|||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
*/
|
||||
//---------------------------------------------------------
|
||||
// determineTupletNormalTicks
|
||||
//---------------------------------------------------------
|
||||
|
@ -2569,8 +2571,16 @@ void ExportMusicXml::chord(Chord* chord, int staff, const QList<Lyrics*>* ll, bo
|
|||
if (chord->arpeggio()) {
|
||||
arpeggiate(chord->arpeggio(), note == nl.front(), note == nl.back(), xml, notations);
|
||||
}
|
||||
// write glissando (only for last note)
|
||||
/* Chord* ch = nextChord(chord);
|
||||
for (Spanner* spanner : note->spannerFor())
|
||||
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()) {
|
||||
gh.doGlissandoStart(ch, notations, xml);
|
||||
}
|
||||
|
|
|
@ -783,13 +783,15 @@ void MusicXml::initPartState()
|
|||
hairpins[i] = 0;
|
||||
for (int i = 0; i < MAX_NUMBER_LEVEL; ++i)
|
||||
trills[i] = 0;
|
||||
for (int i = 0; i < MAX_NUMBER_LEVEL; ++i)
|
||||
glissandi[i][0] = glissandi[i][1] = 0;
|
||||
pedal = 0;
|
||||
pedalContinue = 0;
|
||||
harmony = 0;
|
||||
tremStart = 0;
|
||||
figBass = 0;
|
||||
glissandoText = "";
|
||||
glissandoColor = "";
|
||||
// glissandoText = "";
|
||||
// glissandoColor = "";
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -4731,7 +4733,7 @@ void MusicXml::xmlNotations(Note* note, ChordRest* cr, int trk, int tick, int ti
|
|||
QString wavyLineType;
|
||||
int wavyLineNo = 0;
|
||||
QString arpeggioType;
|
||||
QString glissandoType;
|
||||
// QString glissandoType;
|
||||
int breath = -1;
|
||||
int tremolo = 0;
|
||||
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")
|
||||
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
|
||||
// but text and color are read at start
|
||||
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
|
||||
domError(ee);
|
||||
domError(ee); */
|
||||
}
|
||||
// no support for arpeggio on rest
|
||||
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
|
||||
cr->add(a);
|
||||
}
|
||||
|
||||
/*
|
||||
if (!glissandoType.isEmpty()) {
|
||||
Glissando* g = new Glissando(score);
|
||||
if (glissandoType == "slide")
|
||||
|
@ -5040,14 +5088,14 @@ void MusicXml::xmlNotations(Note* note, ChordRest* cr, int trk, int tick, int ti
|
|||
glissandoColor = "";
|
||||
}
|
||||
}
|
||||
/* if ((static_cast<Chord*>(cr))->glissando()) {
|
||||
if ((static_cast<Chord*>(cr))->glissando()) {
|
||||
// there can be only one
|
||||
delete g;
|
||||
g = 0;
|
||||
}
|
||||
else
|
||||
cr->add(g); */
|
||||
}
|
||||
cr->add(g);
|
||||
} */
|
||||
|
||||
if (!wavyLineType.isEmpty()) {
|
||||
int n = wavyLineNo - 1;
|
||||
|
|
|
@ -34,27 +34,28 @@
|
|||
|
||||
namespace Ms {
|
||||
|
||||
class Beam;
|
||||
class Chord;
|
||||
class ChordRest;
|
||||
class FiguredBass;
|
||||
class Glissando;
|
||||
class Hairpin;
|
||||
class Harmony;
|
||||
class Instrument;
|
||||
class Lyrics;
|
||||
class Measure;
|
||||
class Tuplet;
|
||||
class Tie;
|
||||
class Slur;
|
||||
class Part;
|
||||
class Score;
|
||||
class Note;
|
||||
class Ottava;
|
||||
class Trill;
|
||||
class Part;
|
||||
class Pedal;
|
||||
class Volta;
|
||||
class TextLine;
|
||||
class Chord;
|
||||
class Harmony;
|
||||
class Hairpin;
|
||||
class Score;
|
||||
class Slur;
|
||||
class Spanner;
|
||||
class Lyrics;
|
||||
class ChordRest;
|
||||
class Beam;
|
||||
class FiguredBass;
|
||||
class TextLine;
|
||||
class Tie;
|
||||
class Trill;
|
||||
class Tuplet;
|
||||
class Volta;
|
||||
enum class StaffTypes : char;
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -182,6 +183,7 @@ class MusicXml {
|
|||
Ottava* ottavas[MAX_NUMBER_LEVEL]; ///< Current ottavas
|
||||
Hairpin* hairpins[MAX_NUMBER_LEVEL]; ///< Current hairpins
|
||||
Trill* trills[MAX_NUMBER_LEVEL]; ///< Current trills
|
||||
Glissando* glissandi[MAX_NUMBER_LEVEL][2]; ///< Current slides ([0]) / glissandi ([1])
|
||||
|
||||
Tie* tie;
|
||||
Volta* lastVolta;
|
||||
|
@ -211,8 +213,8 @@ class MusicXml {
|
|||
FiguredBass* figBass; ///< Current figured bass element (to attach to next note)
|
||||
QVector<FiguredBass*> figBassList; ///< List of figured bass elements under a single note
|
||||
Beam::Mode beamMode; ///< Current beam mode
|
||||
QString glissandoText; ///< Glissando text at glissando start
|
||||
QString glissandoColor; ///< Glissando color at glissando start
|
||||
// QString glissandoText; ///< Glissando text at glissando start
|
||||
// QString glissandoColor; ///< Glissando color at glissando start
|
||||
|
||||
int pageWidth; ///< Page width read from defaults
|
||||
int pageHeight; ///< Page height read from defaults
|
||||
|
|
|
@ -10,6 +10,14 @@
|
|||
<track>0</track>
|
||||
<pitch>72</pitch>
|
||||
<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>
|
||||
</Chord>
|
||||
<Chord>
|
||||
|
@ -19,12 +27,8 @@
|
|||
<track>0</track>
|
||||
<pitch>60</pitch>
|
||||
<tpc>14</tpc>
|
||||
<endSpanner id="2"/>
|
||||
</Note>
|
||||
<Glissando>
|
||||
<text>gliss.</text>
|
||||
<subtype>0</subtype>
|
||||
<track>0</track>
|
||||
</Glissando>
|
||||
</Chord>
|
||||
<Chord>
|
||||
<track>0</track>
|
||||
|
@ -33,6 +37,14 @@
|
|||
<track>0</track>
|
||||
<pitch>67</pitch>
|
||||
<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>
|
||||
</Chord>
|
||||
<Chord>
|
||||
|
@ -42,12 +54,8 @@
|
|||
<track>0</track>
|
||||
<pitch>79</pitch>
|
||||
<tpc>15</tpc>
|
||||
<endSpanner id="3"/>
|
||||
</Note>
|
||||
<Glissando>
|
||||
<text>gliss.</text>
|
||||
<subtype>1</subtype>
|
||||
<track>0</track>
|
||||
</Glissando>
|
||||
</Chord>
|
||||
</Staff>
|
||||
</StaffList>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<track>0</track>
|
||||
<pitch>60</pitch>
|
||||
<tpc>14</tpc>
|
||||
<endSpanner id="2"/>
|
||||
</Note>
|
||||
</Chord>
|
||||
<Chord>
|
||||
|
@ -37,6 +38,7 @@
|
|||
<track>0</track>
|
||||
<pitch>79</pitch>
|
||||
<tpc>15</tpc>
|
||||
<endSpanner id="3"/>
|
||||
</Note>
|
||||
</Chord>
|
||||
</Staff>
|
||||
|
|
Loading…
Reference in a new issue