Skip to content

Commit

Permalink
Fix fermata time stretch handling on partial re-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrio95 committed Jan 10, 2019
1 parent 6d522ee commit 2bd75bb
Show file tree
Hide file tree
Showing 6 changed files with 393 additions and 11 deletions.
4 changes: 3 additions & 1 deletion libmscore/fraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class Fraction {
Fraction operator+(const Fraction& v) const { return Fraction(*this) += v; }
Fraction operator-(const Fraction& v) const { return Fraction(*this) -= v; }
Fraction operator*(const Fraction& v) const { return Fraction(*this) *= v; }
Fraction operator*(int v) const { return Fraction(*this) *= v; }
Fraction operator/(const Fraction& v) const { return Fraction(*this) /= v; }
Fraction operator/(int v) const { return Fraction(*this) /= v; }

Expand All @@ -79,6 +78,9 @@ class Fraction {
operator QVariant() const { return QVariant::fromValue(*this); }
};

inline Fraction operator*(const Fraction& f, int v) { return Fraction(f) *= v; }
inline Fraction operator*(int v, const Fraction& f) { return Fraction(f) *= v; }

#ifdef SCRIPT_INTERFACE

//---------------------------------------------------------
Expand Down
12 changes: 6 additions & 6 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2657,6 +2657,11 @@ void Score::getNextMeasure(LayoutContext& lc)
}

measure->computeTicks();

// Reset tempo to set correct time stretch for fermata.
if (isMaster())
resetTempoRange(measure->tick(), measure->endTick());

for (Segment& segment : measure->segments()) {
if (segment.isBreathType()) {
qreal length = 0.0;
Expand Down Expand Up @@ -2709,7 +2714,7 @@ void Score::getNextMeasure(LayoutContext& lc)
if (e->isFermata())
stretch = qMax(stretch, toFermata(e)->timeStretch());
else if (e->isTempoText()) {
if (score()->isMaster()) {
if (isMaster()) {
TempoText* tt = toTempoText(e);
setTempo(tt->segment(), tt->tempo());
}
Expand Down Expand Up @@ -4187,11 +4192,6 @@ void Score::doLayoutRange(int stick, int etick)

lc.prevMeasure = 0;

// we need to reset tempo because fermata is setted
//inside getNextMeasure and it lead to twice timeStretch
if (isMaster())
resetTempoRange(stick, etick);

getNextMeasure(lc);
lc.curSystem = collectSystem(lc);

Expand Down
5 changes: 3 additions & 2 deletions libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3315,11 +3315,12 @@ void Score::resetTempo()

void Score::resetTempoRange(int tick1, int tick2)
{
const bool zeroInRange = (tick1 <= 0 && tick2 > 0);
tempomap()->clearRange(tick1, tick2);
if (tempomap()->empty())
if (zeroInRange)
tempomap()->setTempo(0, _defaultTempo);
sigmap()->clearRange(tick1, tick2);
if (sigmap()->empty()) {
if (zeroInRange) {
Measure* m = firstMeasure();
if (m)
sigmap()->add(0, SigEvent(m->len(), m->timesig(), 0));
Expand Down
Binary file added mtest/libmscore/midi/testTimeStretchFermata-ref.mid
Binary file not shown.
Loading

0 comments on commit 2bd75bb

Please sign in to comment.