diff --git a/src/TimingData.cpp b/src/TimingData.cpp index 8b9bdf9531..5e1644b5fa 100644 --- a/src/TimingData.cpp +++ b/src/TimingData.cpp @@ -1332,12 +1332,7 @@ void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex, bool m_LabelSegments[i].Scale( iStartIndex, length, newLength ); for ( unsigned i = 0; i < m_SpeedSegments.size(); i++ ) - { - SpeedSegment &s = m_SpeedSegments[i]; - s.Scale( iStartIndex, length, newLength ); - if (s.GetUnit() == 0) // beats - s.SetLength(s.GetLength() * fScale); - } + m_SpeedSegments[i].Scale( iStartIndex, length, newLength ); for( unsigned i = 0; i < m_FakeSegments.size(); i++ ) m_FakeSegments[i].Scale( iStartIndex, length, newLength ); diff --git a/src/TimingSegments.cpp b/src/TimingSegments.cpp index 6a0e0eec57..0d241da25d 100644 --- a/src/TimingSegments.cpp +++ b/src/TimingSegments.cpp @@ -250,6 +250,20 @@ void SpeedSegment::SetUnit(const int i) this->unit = static_cast(i); } +void SpeedSegment::Scale( int start, int length, int newLength ) +{ + if( GetUnit() == 0 ) + { + // XXX: this function is duplicated, there should be a better way + float startBeat = GetBeat(); + float endBeat = startBeat + GetLength(); + float newStartBeat = ScalePosition( NoteRowToBeat(start), NoteRowToBeat(length), NoteRowToBeat(newLength), startBeat ); + float newEndBeat = ScalePosition( NoteRowToBeat(start), NoteRowToBeat(length), NoteRowToBeat(newLength), endBeat ); + SetLength( newEndBeat - newStartBeat ); + } + TimingSegment::Scale( start, length, newLength ); +} + bool SpeedSegment::operator<( const SpeedSegment &other ) const { LTCOMPARE(GetRow()); diff --git a/src/TimingSegments.h b/src/TimingSegments.h index 4acbe60350..e18e881886 100644 --- a/src/TimingSegments.h +++ b/src/TimingSegments.h @@ -681,6 +681,8 @@ struct SpeedSegment : public TimingSegment * @param i the unit. */ void SetUnit(const int i); + void Scale( int start, int length, int newLength ); + /** * @brief Compares two SpeedSegments to see if one is less than the other. * @param other the other SpeedSegment to compare to.