Make compress/expand preserve timing data by also adjusting BPM changes between start and end marker. The adjusting part is at TimingData::ScaleRegion.
This commit is contained in:
+1
-7
@@ -3455,7 +3455,7 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, const vector<int> &iAns
|
|||||||
else
|
else
|
||||||
NoteDataUtil::DeleteRows( m_NoteDataEdit, m_NoteFieldEdit.m_iBeginMarker, -iDeltaRows );
|
NoteDataUtil::DeleteRows( m_NoteDataEdit, m_NoteFieldEdit.m_iBeginMarker, -iDeltaRows );
|
||||||
|
|
||||||
m_pSong->m_Timing.ScaleRegion( fScale, m_NoteFieldEdit.m_iBeginMarker, m_NoteFieldEdit.m_iEndMarker );
|
m_pSong->m_Timing.ScaleRegion( fScale, m_NoteFieldEdit.m_iBeginMarker, m_NoteFieldEdit.m_iEndMarker, true );
|
||||||
|
|
||||||
HandleAreaMenuChoice( paste_at_begin_marker );
|
HandleAreaMenuChoice( paste_at_begin_marker );
|
||||||
|
|
||||||
@@ -3479,12 +3479,6 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, const vector<int> &iAns
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_NoteFieldEdit.m_iEndMarker = iNewClipboardEndRow;
|
m_NoteFieldEdit.m_iEndMarker = iNewClipboardEndRow;
|
||||||
|
|
||||||
float fPriorBPM = m_pSong->GetBPMAtBeat( NoteRowToBeat(iNewClipboardEndRow + 1) );
|
|
||||||
float fOldBPM = m_pSong->GetBPMAtBeat( NoteRowToBeat(m_NoteFieldEdit.m_iBeginMarker) );
|
|
||||||
float fNewBPM = fOldBPM * fScale;
|
|
||||||
m_pSong->m_Timing.SetBPMAtRow( m_NoteFieldEdit.m_iBeginMarker, fNewBPM );
|
|
||||||
m_pSong->m_Timing.SetBPMAtRow( iNewClipboardEndRow, fPriorBPM );
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case play:
|
case play:
|
||||||
|
|||||||
+26
-1
@@ -611,7 +611,7 @@ float TimingData::GetElapsedTimeFromBeatNoOffset( float fBeat ) const
|
|||||||
return fElapsedTime;
|
return fElapsedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex )
|
void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex, bool bAdjustBPM )
|
||||||
{
|
{
|
||||||
ASSERT( fScale > 0 );
|
ASSERT( fScale > 0 );
|
||||||
ASSERT( iStartIndex >= 0 );
|
ASSERT( iStartIndex >= 0 );
|
||||||
@@ -638,6 +638,31 @@ void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex )
|
|||||||
else
|
else
|
||||||
m_StopSegments[i].m_iStartRow = lrintf((iSegStartRow - iStartIndex) * fScale) + iStartIndex;
|
m_StopSegments[i].m_iStartRow = lrintf((iSegStartRow - iStartIndex) * fScale) + iStartIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// adjust BPM changes to preserve timing
|
||||||
|
if( bAdjustBPM )
|
||||||
|
{
|
||||||
|
int iNewEndIndex = lrintf( (iEndIndex - iStartIndex) * fScale ) + iStartIndex;
|
||||||
|
float fEndBPMBeforeScaling = GetBPMAtRow(iNewEndIndex);
|
||||||
|
|
||||||
|
// adjust BPM changes "between" iStartIndex and iNewEndIndex
|
||||||
|
for ( unsigned i = 0; i < m_BPMSegments.size(); i++ )
|
||||||
|
{
|
||||||
|
const int iSegStart = m_BPMSegments[i].m_iStartRow;
|
||||||
|
if( iSegStart <= iStartIndex )
|
||||||
|
continue;
|
||||||
|
else if( iSegStart >= iNewEndIndex )
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
m_BPMSegments[i].m_fBPS *= fScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set BPM at iStartIndex and iNewEndIndex.
|
||||||
|
SetBPMAtRow( iStartIndex, GetBPMAtRow(iStartIndex) * fScale );
|
||||||
|
SetBPMAtRow( iNewEndIndex, fEndBPMBeforeScaling );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimingData::InsertRows( int iStartRow, int iRowsToAdd )
|
void TimingData::InsertRows( int iStartRow, int iRowsToAdd )
|
||||||
|
|||||||
+1
-1
@@ -1073,7 +1073,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool operator!=( const TimingData &other ) { return !operator==(other); }
|
bool operator!=( const TimingData &other ) { return !operator==(other); }
|
||||||
|
|
||||||
void ScaleRegion( float fScale = 1, int iStartRow = 0, int iEndRow = MAX_NOTE_ROW );
|
void ScaleRegion( float fScale = 1, int iStartRow = 0, int iEndRow = MAX_NOTE_ROW, bool bAdjustBPM = false );
|
||||||
void InsertRows( int iStartRow, int iRowsToAdd );
|
void InsertRows( int iStartRow, int iRowsToAdd );
|
||||||
void DeleteRows( int iStartRow, int iRowsToDelete );
|
void DeleteRows( int iStartRow, int iRowsToDelete );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user