Skip to content

Commit

Permalink
Fix #21732- Support for changing tempo in GP4 and GP5 files
Browse files Browse the repository at this point in the history
  • Loading branch information
jpirie committed Apr 29, 2014
1 parent a2a0748 commit c2d555b
Show file tree
Hide file tree
Showing 10 changed files with 2,067 additions and 11 deletions.
28 changes: 19 additions & 9 deletions mscore/importgtp.cpp
Expand Up @@ -715,7 +715,7 @@ void GuitarPro::setTempo(int tempo, Measure* measure)
tt->setTrack(0);
Segment* segment = measure->getSegment(Segment::SegChordRest, measure->tick());
segment->add(tt);
score->setTempo(measure->tick(),tt->tempo());
score->setTempo(measure->tick(), tt->tempo());
}

//---------------------------------------------------------
Expand Down Expand Up @@ -1596,7 +1596,7 @@ void GuitarPro3::read(QFile* fp)
}
}
}
setTempo(tempo,score->firstMeasure());
setTempo(tempo, score->firstMeasure());
}

int GuitarPro3::readBeatEffects(int track, Segment* segment)
Expand Down Expand Up @@ -1665,7 +1665,7 @@ void GuitarPro4::readBend()
// readMixChange
//---------------------------------------------------------

void GuitarPro4::readMixChange()
void GuitarPro4::readMixChange(Measure* measure)
{
/*char patch =*/ readChar();
char volume = readChar();
Expand All @@ -1688,8 +1688,14 @@ void GuitarPro4::readMixChange()
readChar();
if (tremolo >= 0)
readChar();
if (tempo >= 0)
if (tempo >= 0) {
if (tempo != previousTempo) {
previousTempo = tempo;
setTempo(tempo, measure);
}
readChar();
}

readChar(); // bitmask: what should be applied to all tracks
}

Expand Down Expand Up @@ -2233,7 +2239,7 @@ void GuitarPro4::read(QFile* fp)
if (beatBits & 0x8)
readBeatEffects(staffIdx * VOICES, segment);
if (beatBits & 0x10)
readMixChange();
readMixChange(measure);
int strings = readUChar(); // used strings mask
Fraction l = len2fraction(len);

Expand Down Expand Up @@ -2321,7 +2327,7 @@ void GuitarPro4::read(QFile* fp)
}
}
}
setTempo(tempo,score->firstMeasure());
setTempo(tempo, score->firstMeasure());
}

//---------------------------------------------------------
Expand Down Expand Up @@ -2791,7 +2797,7 @@ int GuitarPro5::readBeat(int tick, int voice, Measure* measure, int staffIdx, Tu
if (beatBits & 0x8)
beatEffects = readBeatEffects(staffIdx * VOICES + voice, segment);
if (beatBits & 0x10)
readMixChange();
readMixChange(measure);

int strings = readUChar(); // used strings mask

Expand Down Expand Up @@ -2897,7 +2903,7 @@ void GuitarPro5::readMeasure(Measure* measure, int staffIdx, Tuplet** tuplets)
// readMixChange
//---------------------------------------------------------

void GuitarPro5::readMixChange()
void GuitarPro5::readMixChange(Measure* measure)
{
/*char patch =*/ readChar();
skip(16);
Expand All @@ -2924,6 +2930,10 @@ void GuitarPro5::readMixChange()
if (tremolo >= 0)
readChar();
if (tempo >= 0) {
if (tempo != previousTempo) {
previousTempo = tempo;
setTempo(tempo, measure);
}
readChar();
if (version > 500)
readChar();
Expand Down Expand Up @@ -3166,7 +3176,7 @@ void GuitarPro5::read(QFile* fp)
createMeasures();
readTracks();
readMeasures();
setTempo(tempo,score->firstMeasure());
setTempo(tempo, score->firstMeasure());
}

//---------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions mscore/importgtp.h
Expand Up @@ -177,7 +177,7 @@ class GuitarPro4 : public GuitarPro {
void readNote(int string, Note* note, GpNote*);
virtual void readChord(Segment*, int track);
virtual int readBeatEffects(int track, Segment* segment);
virtual void readMixChange();
virtual void readMixChange(Measure* measure);
virtual void readBend();

public:
Expand All @@ -196,7 +196,7 @@ class GuitarPro5 : public GuitarPro {
virtual int readBeatEffects(int track, Segment* segment);
virtual void readBend(Note*);
void readNote(int string, Note* note);
virtual void readMixChange();
virtual void readMixChange(Measure* measure);
virtual void readChord(Segment*, int track);
void readMeasure(Measure* measure, int staffIdx, Tuplet*[]);
void readArtificialHarmonic();
Expand Down
Binary file added mtest/guitarpro/tempo.gp3
Binary file not shown.

0 comments on commit c2d555b

Please sign in to comment.