Add changes from mattmcclinch to fix regression tests for musicxml and gtp import and scripting.

This commit is contained in:
ws 2019-02-18 09:58:34 +01:00
parent 684cde1d45
commit 9efd301242
11 changed files with 32 additions and 26 deletions

View file

@ -1126,7 +1126,6 @@ void Spanner::layoutSystemsDone()
// fraction
//---------------------------------------------------------
#if 0
static Fraction fraction(const XmlWriter& xml, const Element* current, const Fraction& t)
{
Fraction tick(t);
@ -1137,14 +1136,14 @@ static Fraction fraction(const XmlWriter& xml, const Element* current, const Fra
}
return tick;
}
#endif
//--------------------------------------------------
// Spanner::writeSpannerStart
//---------------------------------------------------------
void Spanner::writeSpannerStart(XmlWriter& xml, const Element* current, int track, Fraction frac) const
void Spanner::writeSpannerStart(XmlWriter& xml, const Element* current, int track, Fraction tick) const
{
Fraction frac = fraction(xml, current, tick);
SpannerWriter w(xml, current, this, track, frac, true);
w.write();
}
@ -1153,8 +1152,9 @@ void Spanner::writeSpannerStart(XmlWriter& xml, const Element* current, int trac
// Spanner::writeSpannerEnd
//---------------------------------------------------------
void Spanner::writeSpannerEnd(XmlWriter& xml, const Element* current, int track, Fraction frac) const
void Spanner::writeSpannerEnd(XmlWriter& xml, const Element* current, int track, Fraction tick) const
{
Fraction frac = fraction(xml, current, tick);
SpannerWriter w(xml, current, this, track, frac, false);
w.write();
}

View file

@ -74,6 +74,7 @@ class XmlReader : public QXmlStreamReader {
// Score read context (for read optimizations):
Fraction _tick { Fraction(0, 1) };
Fraction _tickOffset { Fraction(0, 1) };
int _intTick { 0 };
int _track { 0 };
int _trackOffset { 0 };
bool _pasteMode { false }; // modifies read behaviour on paste operation
@ -130,7 +131,7 @@ class XmlReader : public QXmlStreamReader {
int readIntHex() { return readElementText().toInt(0, 16); }
double readDouble() { return readElementText().toDouble(); }
qlonglong readLongLong() { return readElementText().toLongLong(); }
double readDouble(double min, double max);
bool readBool();
QPointF readPoint();

View file

@ -261,6 +261,12 @@ void XmlReader::setLocation(const Location& l)
if (l.isRelative()) {
Location newLoc = l;
newLoc.toAbsolute(location());
int intTicks = l.frac().ticks();
if (_tick == Fraction::fromTicks(_intTick + intTicks)) {
_intTick += intTicks;
setTrack(newLoc.track() - _trackOffset);
return;
}
setLocation(newLoc); // recursion
return;
}
@ -738,6 +744,7 @@ Fraction XmlReader::rtick() const
void XmlReader::setTick(const Fraction& f)
{
_tick = f.reduced();
_intTick = _tick.ticks();
}
//---------------------------------------------------------
@ -748,6 +755,7 @@ void XmlReader::incTick(const Fraction& f)
{
_tick += f;
_tick.reduce();
_intTick += f.ticks();
}
}

View file

@ -901,7 +901,7 @@ bool GuitarPro4::read(QFile* fp)
if(!segment->cr(track))
cr = new Chord(score);
}
cr->setParent(segment);
cr->setTrack(track);
if (lyrics)
cr->add(lyrics);

View file

@ -284,6 +284,7 @@ Fraction GuitarPro5::readBeat(const Fraction& tick, int voice, Measure* measure,
if (!cr)
cr = new Chord(score);
}
cr->setParent(segment);
cr->setTrack(track);
TDuration d(l);

View file

@ -1650,6 +1650,7 @@ Fraction GuitarPro6::readBeats(QString beats, GPPartInfo* partInfo, Measure* mea
else if (currentNode1.nodeName() == "PrimaryTuplet") {
tupletSet = true;
cr = new Chord(score);
cr->setParent(segment);
cr->setTrack(track);
if ((tuplet == 0) || (tuplet->elementsDuration() == tuplet->baseLen().fraction() * tuplet->ratio().numerator())) {
tuplet = new Tuplet(score);
@ -2370,6 +2371,9 @@ void GuitarPro6::readMasterBars(GPPartInfo* partInfo)
else if (!masterBarElement.nodeName().compare("Bars") && stave == staves - 1) {
readBars(&masterBarElement, measure, &oldClefId[0], partInfo, measureCounter);
for (int i = 0; i < staves * VOICES; ++i) {
Ottava* o = ottava.at(i);
if (o && o->ticks().isZero())
o->setTick2(score->endTick());
Slur* slur = legatos[i];
if (slur) {
if (measure->prevMeasure() && !measure->hasVoice(i)) {

View file

@ -241,7 +241,7 @@ subdirs (
zerberus/opcodeparse
zerberus/inputControls
zerberus/loop
# testscript ws:disabled during fraction migration
testscript
)

View file

@ -283,15 +283,11 @@
</Ottava>
<next>
<location>
<measures>2</measures>
<fractions>1/1</fractions>
</location>
</next>
</Spanner>
<Spanner type="Ottava">
<prev>
<location>
</location>
</prev>
</Spanner>
<Chord>
<linkedMain/>
<durationType>whole</durationType>
@ -327,6 +323,14 @@
<durationType>measure</durationType>
<duration>4/4</duration>
</Rest>
<Spanner type="Ottava">
<prev>
<location>
<measures>-2</measures>
<fractions>-1/1</fractions>
</location>
</prev>
</Spanner>
</voice>
</Measure>
</Staff>

View file

@ -64,12 +64,6 @@
<duration>11586</duration>
<type>quarter</type>
</note>
<forward>
<duration>1</duration>
</forward>
<forward>
<duration>1</duration>
</forward>
<note>
<pitch>
<step>C</step>

View file

@ -372,9 +372,6 @@
<duration>9240</duration>
<type>quarter</type>
</note>
<forward>
<duration>1</duration>
</forward>
<direction>
<direction-type>
<dynamics>
@ -382,9 +379,6 @@
</dynamics>
</direction-type>
</direction>
<backup>
<duration>1</duration>
</backup>
<note>
<pitch>
<step>C</step>

View file

@ -16,7 +16,7 @@ MuseScore {
while (cursor.segment) {
var e = cursor.element;
if (e) {
log2("found:", e.name + " (" + e.type + ") at " + e.tick);
log2("found:", e.name + " (" + e.type + ") at " + e.tick.ticks);
if (e.type == Element.CHORD) {
// log2(" durationType:", e.durationType); // TODO: some wrapper/string conversion?
log2(" beamMode:", e.beamMode);