Skip to content
Permalink
Browse files

fix #88036: In a multivoices context, Voices 2-3-4 are lost in the .g…

…px format
  • Loading branch information...
lasconic committed Jan 23, 2016
1 parent ba5401a commit b4e12c5fd6a33deaeab017188a0c1f0a61a82232
@@ -741,8 +741,9 @@ void GuitarPro6::makeTie(Note* note) {
}
}

int GuitarPro6::readBeats(QString beats, GPPartInfo* partInfo, Measure* measure, int tick, int staffIdx, int voiceNum, Tuplet* tuplets[], int measureCounter)
int GuitarPro6::readBeats(QString beats, GPPartInfo* partInfo, Measure* measure, int startTick, int staffIdx, int voiceNum, Tuplet* tuplets[], int measureCounter)
{
int beatsTick = 0;
// we must count from the start of the bar, so declare a fraction to track this
Fraction fermataIndex(0,1);
int track = staffIdx * VOICES + voiceNum;
@@ -755,8 +756,8 @@ int GuitarPro6::readBeats(QString beats, GPPartInfo* partInfo, Measure* measure,
Fraction l;
int dotted = 0;
QDomNode beat = getNode(*currentBeat, partInfo->beats);

Segment* segment = measure->getSegment(Segment::Type::ChordRest, tick);
int currentTick = startTick + beatsTick;
Segment* segment = measure->getSegment(Segment::Type::ChordRest, currentTick);
QDomNode currentNode = beat.firstChild();
bool noteSpecified = false;
ChordRest* cr = segment->cr(track);
@@ -1341,12 +1342,12 @@ int GuitarPro6::readBeats(QString beats, GPPartInfo* partInfo, Measure* measure,
bool isCrec = !currentNode.toElement().text().compare("Crescendo");
if (seg && hairpins[staffIdx]) {
if (hairpins[staffIdx]->tick2() == seg->tick())
hairpins[staffIdx]->setTick2(tick);
hairpins[staffIdx]->setTick2(currentTick);
else
createCrecDim(staffIdx, track, tick, isCrec);
createCrecDim(staffIdx, track, currentTick, isCrec);
}
else
createCrecDim(staffIdx, track, tick, isCrec);
createCrecDim(staffIdx, track, currentTick, isCrec);
}
else if (!currentNode.nodeName().compare("Properties")) {
QDomNode currentProperty = currentNode.firstChild();
@@ -1409,9 +1410,9 @@ int GuitarPro6::readBeats(QString beats, GPPartInfo* partInfo, Measure* measure,
}
}
}
tick += cr->actualTicks();
beatsTick += cr->actualTicks();
}
return tick;
return beatsTick;
}

//---------------------------------------------------------
@@ -1481,41 +1482,48 @@ void GuitarPro6::readBars(QDomNode* barList, Measure* measure, ClefType oldClefI
// new voice specification
else if (!currentNode.nodeName().compare("Voices")) {
QString voicesString = currentNode.toElement().text();
auto currentVoice = voicesString.split(" ").first();
// if the voice is not -1 then we set voice
if (currentVoice.compare("-1"))
voice = getNode(currentVoice, partInfo->voices);
auto voices = voicesString.split(" ");
bool contentAdded = false;
int voiceNum = -1;
for (auto currentVoice : voices) {
// if the voice is not -1 then we set voice
if (currentVoice.compare("-1"))
voice = getNode(currentVoice, partInfo->voices);
voiceNum +=1;
if (currentVoice.toInt() == - 1) {
if (contentAdded) continue;
Fraction l = Fraction(1,1);
// add a rest with length of l
ChordRest* cr = new Rest(score);
cr->setTrack(staffIdx * VOICES + voiceNum);
TDuration d(l);
cr->setDuration(l);
if (cr->type() == Element::Type::REST && l >= measure->len()) {
cr->setDurationType(TDuration::DurationType::V_MEASURE);
cr->setDuration(measure->len());
}
else
cr->setDurationType(d);

Segment* segment = measure->getSegment(Segment::Type::ChordRest, tick);
if(!segment->cr(staffIdx * VOICES + voiceNum))
segment->add(cr);
tick += cr->actualTicks();
staffIdx++;
contentAdded = true;
continue;
}

// read the beats that occur in the bar
int ticks = readBeats(voice.firstChild().toElement().text(), partInfo, measure, tick, staffIdx, voiceNum, tuplets, measureCounter);
if (ticks > 0)
contentAdded = true;
}
}
else if (!currentNode.nodeName().compare("XProperties")) {}
// go to the next node in the tree
currentNode = currentNode.nextSibling();
}

int voiceNum = 0;
if (voice.isNull()) {
Fraction l = Fraction(1,1);
// add a rest with length of l
ChordRest* cr = new Rest(score);
cr->setTrack(staffIdx * VOICES + voiceNum);
TDuration d(l);
cr->setDuration(l);
if (cr->type() == Element::Type::REST && l >= measure->len()) {
cr->setDurationType(TDuration::DurationType::V_MEASURE);
cr->setDuration(measure->len());
}
else
cr->setDurationType(d);

Segment* segment = measure->getSegment(Segment::Type::ChordRest, tick);
if(!segment->cr(staffIdx * VOICES + voiceNum))
segment->add(cr);
tick += cr->actualTicks();
staffIdx++;
continue;
}

// read the beats that occur in the bar
tick = readBeats(voice.firstChild().toElement().text(), partInfo, measure, tick, staffIdx, voiceNum, tuplets, measureCounter);
// increment the counter for parts
staffIdx++;
}
@@ -166,8 +166,8 @@ class GuitarPro {
static const int LEGATO_SLIDE = 2;
static const int SLIDE_OUT_DOWN = 4;
static const int SLIDE_OUT_UP = 8;
static const int SLIDE_IN_BELOW = 16;
static const int SLIDE_IN_ABOVE = 32;
static const int SLIDE_IN_ABOVE = 16;
static const int SLIDE_IN_BELOW = 32;

static const int MAX_PITCH = 127;
static const char* errmsg[];
@@ -367,7 +367,7 @@ class GuitarPro6 : public GuitarPro {
int findNumMeasures(GPPartInfo* partInfo);
void readMasterTracks(QDomNode* masterTrack);
void readDrumNote(Note* note, int element, int variation);
int readBeats(QString beats, GPPartInfo* partInfo, Measure* measure, int tick, int staffIdx, int voiceNum, Tuplet* tuplets[], int measureCounter);
int readBeats(QString beats, GPPartInfo* partInfo, Measure* measure, int startTick, int staffIdx, int voiceNum, Tuplet* tuplets[], int measureCounter);
void readBars(QDomNode* barList, Measure* measure, ClefType oldClefId[], GPPartInfo* partInfo, int measureCounter);
void readTracks(QDomNode* tracks);
void readMasterBars(GPPartInfo* partInfo);
@@ -140,7 +140,7 @@
<lid>6</lid>
</Dynamic>
<Slur id="2">
<lid>15</lid>
<lid>19</lid>
<track>0</track>
</Slur>
<Chord>
@@ -188,6 +188,27 @@
<subtype>end</subtype>
<span>1</span>
</BarLine>
<tick>0</tick>
<Rest>
<lid>14</lid>
<track>1</track>
<durationType>quarter</durationType>
</Rest>
<Rest>
<lid>15</lid>
<track>1</track>
<durationType>quarter</durationType>
</Rest>
<Rest>
<lid>16</lid>
<track>1</track>
<durationType>quarter</durationType>
</Rest>
<Rest>
<lid>17</lid>
<track>1</track>
<durationType>quarter</durationType>
</Rest>
</Measure>
</Staff>
<Score>
@@ -351,7 +372,7 @@
<lid>6</lid>
</Dynamic>
<Slur id="4">
<lid>15</lid>
<lid>19</lid>
<track>0</track>
</Slur>
<Chord>
@@ -399,6 +420,27 @@
<subtype>end</subtype>
<span>1</span>
</BarLine>
<tick>0</tick>
<Rest>
<lid>14</lid>
<track>1</track>
<durationType>quarter</durationType>
</Rest>
<Rest>
<lid>15</lid>
<track>1</track>
<durationType>quarter</durationType>
</Rest>
<Rest>
<lid>16</lid>
<track>1</track>
<durationType>quarter</durationType>
</Rest>
<Rest>
<lid>17</lid>
<track>1</track>
<durationType>quarter</durationType>
</Rest>
</Measure>
</Staff>
<Staff id="2">
@@ -412,7 +454,7 @@
<durationType>quarter</durationType>
</Rest>
<Slur id="6">
<lid>15</lid>
<lid>19</lid>
<track>4</track>
</Slur>
<Chord>
@@ -455,6 +497,27 @@
<subtype>end</subtype>
<span>1</span>
</BarLine>
<tick>0</tick>
<Rest>
<lid>14</lid>
<track>5</track>
<durationType>quarter</durationType>
</Rest>
<Rest>
<lid>15</lid>
<track>5</track>
<durationType>quarter</durationType>
</Rest>
<Rest>
<lid>16</lid>
<track>5</track>
<durationType>quarter</durationType>
</Rest>
<Rest>
<lid>17</lid>
<track>5</track>
<durationType>quarter</durationType>
</Rest>
</Measure>
</Staff>
<name>S-Gt</name>
Binary file not shown.

0 comments on commit b4e12c5

Please sign in to comment.
You can’t perform that action at this time.