[splittiming] Warps and Fakes are relative timed.

theDtTvB, time to scrutinize my work. ;)
This commit is contained in:
Jason Felds
2011-05-16 10:24:59 -04:00
parent 79135b3179
commit b3c16e3dee
2 changed files with 35 additions and 39 deletions
+23 -27
View File
@@ -176,7 +176,7 @@ void TimingData::SetWarpAtRow( int iRow, float fNew )
for( i=0; i<m_WarpSegments.size(); i++ )
if( m_WarpSegments[i].m_iStartRow == iRow )
break;
bool valid = iRow > 0 && NoteRowToBeat(iRow) < fNew;
bool valid = iRow > 0 && fNew > 0;
if( i == m_WarpSegments.size() )
{
if( valid )
@@ -513,7 +513,7 @@ bool TimingData::IsWarpAtRow( int iNoteRow ) const
int i = GetWarpSegmentIndexAtRow( iNoteRow );
const WarpSegment& s = m_WarpSegments[i];
if( s.m_iStartRow <= iNoteRow && iNoteRow < BeatToNoteRow(s.m_fEndBeat) )
if( s.m_iStartRow <= iNoteRow && iNoteRow < (s.m_iStartRow + BeatToNoteRow(s.m_fEndBeat) ) )
{
if( m_StopSegments.empty() )
{
@@ -535,7 +535,7 @@ bool TimingData::IsFakeAtRow( int iNoteRow ) const
int i = GetFakeSegmentIndexAtRow( iNoteRow );
const FakeSegment& s = m_FakeSegments[i];
if( s.m_iStartRow <= iNoteRow && iNoteRow < BeatToNoteRow(s.m_fEndBeat) )
if( s.m_iStartRow <= iNoteRow && iNoteRow < ( s.m_iStartRow + BeatToNoteRow(s.m_fEndBeat) ) )
{
return true;
}
@@ -829,15 +829,18 @@ void TimingData::GetBeatAndBPSFromElapsedTimeNoOffset( float fElapsedTime, float
}
break;
case FOUND_WARP:
bIsWarping = true;
if( itWS->m_fEndBeat > fWarpDestination )
{
fWarpDestination = itWS->m_fEndBeat;
bIsWarping = true;
float fWarpSum = itWS->m_fEndBeat + NoteRowToBeat( itWS->m_iStartRow );
if( fWarpSum > fWarpDestination )
{
fWarpDestination = itWS->m_fEndBeat;
}
iWarpBeginOut = iEventRow;
fWarpDestinationOut = fWarpDestination;
itWS ++;
break;
}
iWarpBeginOut = iEventRow;
fWarpDestinationOut = fWarpDestination;
itWS ++;
break;
}
iLastRow = iEventRow;
}
@@ -921,13 +924,16 @@ float TimingData::GetElapsedTimeFromBeatNoOffset( float fBeat ) const
case FOUND_MARKER:
return fLastTime;
case FOUND_WARP:
bIsWarping = true;
if( itWS->m_fEndBeat > fWarpDestination )
{
fWarpDestination = itWS->m_fEndBeat;
bIsWarping = true;
float fWarpSum = itWS->m_fEndBeat + NoteRowToBeat( itWS->m_iStartRow );
if( fWarpSum > fWarpDestination )
{
fWarpDestination = itWS->m_fEndBeat;
}
itWS ++;
break;
}
itWS ++;
break;
}
iLastRow = iEventRow;
}
@@ -967,7 +973,7 @@ void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex, bool
for( unsigned i = 0; i < m_WarpSegments.size(); i++ )
{
const int iSegStartRow = m_WarpSegments[i].m_iStartRow;
const int iSegEndRow = BeatToNoteRow( m_WarpSegments[i].m_fEndBeat );
const int iSegEndRow = iSegStartRow + BeatToNoteRow( m_WarpSegments[i].m_fEndBeat );
if( iSegEndRow >= iStartIndex )
{
if( iSegEndRow > iEndIndex )
@@ -1030,7 +1036,7 @@ void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex, bool
for( unsigned i = 0; i < m_FakeSegments.size(); i++ )
{
const int iSegStartRow = m_FakeSegments[i].m_iStartRow;
const int iSegEndRow = BeatToNoteRow( m_FakeSegments[i].m_fEndBeat );
const int iSegEndRow = iSegStartRow + BeatToNoteRow( m_FakeSegments[i].m_fEndBeat );
if( iSegEndRow >= iStartIndex )
{
if( iSegEndRow > iEndIndex )
@@ -1093,8 +1099,6 @@ void TimingData::InsertRows( int iStartRow, int iRowsToAdd )
for( unsigned i = 0; i < m_WarpSegments.size(); i++ )
{
WarpSegment &warp = m_WarpSegments[i];
if( BeatToNoteRow(warp.m_fEndBeat) >= iStartRow )
warp.m_fEndBeat += NoteRowToBeat(iRowsToAdd);
if( warp.m_iStartRow < iStartRow )
continue;
warp.m_iStartRow += iRowsToAdd;
@@ -1142,8 +1146,6 @@ void TimingData::InsertRows( int iStartRow, int iRowsToAdd )
for( unsigned i = 0; i < m_FakeSegments.size(); i++ )
{
FakeSegment &fake = m_FakeSegments[i];
if( BeatToNoteRow(fake.m_fEndBeat) >= iStartRow )
fake.m_fEndBeat += NoteRowToBeat(iRowsToAdd);
if( fake.m_iStartRow < iStartRow )
continue;
fake.m_iStartRow += iRowsToAdd;
@@ -1210,9 +1212,6 @@ void TimingData::DeleteRows( int iStartRow, int iRowsToDelete )
{
WarpSegment &warp = m_WarpSegments[i];
if( BeatToNoteRow(warp.m_fEndBeat) >= iStartRow )
warp.m_fEndBeat = max( NoteRowToBeat(iStartRow), warp.m_fEndBeat - NoteRowToBeat(iRowsToDelete) );
if( warp.m_iStartRow < iStartRow )
continue;
@@ -1326,9 +1325,6 @@ void TimingData::DeleteRows( int iStartRow, int iRowsToDelete )
{
FakeSegment &fake = m_FakeSegments[i];
if( BeatToNoteRow(fake.m_fEndBeat) >= iStartRow )
fake.m_fEndBeat = max( NoteRowToBeat(iStartRow), fake.m_fEndBeat - NoteRowToBeat(iRowsToDelete) );
if( fake.m_iStartRow < iStartRow )
continue;
+12 -12
View File
@@ -313,8 +313,8 @@ struct TimeSignatureSegment
*
* A warp segment is used to replicate the effects of Negative BPMs without
* abusing negative BPMs. Negative BPMs should be converted to warp segments.
* WarpAt=WarpTo is the format, where both are in beats. (Technically they're
* both rows though.) */
* WarpAt=WarpToRelative is the format, where both are in beats.
* (Technically they're both rows though.) */
struct WarpSegment
{
/**
@@ -326,21 +326,21 @@ struct WarpSegment
/**
* @brief Create a Warp Segment with the specified starting row and row to warp to.
* @param s the starting row of this segment.
* @param r the row to warp to.
* @param r the number of rows to jump ahead.
*/
WarpSegment( int s, int r ): m_iStartRow(max(0, (s < r ? s : r))),
m_fEndBeat(max(0, NoteRowToBeat((r > s ? r : s)))) {}
/**
* @brief Creates a Warp Segment with the specified starting row and beat to warp to.
* @param s the starting row of this segment.
* @param b the beat to warp to.
* @param b the number of beats to jump ahead.
*/
WarpSegment( int s, float b ): m_iStartRow(max(0, s)),
m_fEndBeat(max(0, b)) {}
/**
* @brief Create a Warp Segment with the specified starting beat and row to warp to.
* @param s the starting beat in this segment.
* @param r the row to warp to.
* @param r the number of rows to jump ahead.
*/
WarpSegment( float s, int r ):
m_iStartRow(max(0, BeatToNoteRow(s))),
@@ -348,7 +348,7 @@ struct WarpSegment
/**
* @brief Creates a Warp Segment with the specified starting beat and beat to warp to.
* @param s the starting beat of this segment.
* @param b the beat to warp to.
* @param b the number of beats to jump ahead.
*/
WarpSegment( float s, float b ):
m_iStartRow(max(0, BeatToNoteRow((s < b ? s : b)))),
@@ -358,7 +358,7 @@ struct WarpSegment
*/
int m_iStartRow;
/**
* @brief The beat to warp to.
* @brief The number of beats to warp ahead by.
*/
float m_fEndBeat;
/**
@@ -799,21 +799,21 @@ struct FakeSegment
/**
* @brief Create a Fake Segment with the specified values.
* @param s the starting row of this segment.
* @param r the row to be real again.
* @param r the number of rows this segment lasts.
*/
FakeSegment( int s, int r ): m_iStartRow(max(0, (s < r ? s : r))),
m_fEndBeat(max(0, NoteRowToBeat((r > s ? r : s)))) {}
/**
* @brief Creates a Fake Segment with the specified values.
* @param s the starting row of this segment.
* @param b the beat to be real again.
* @param b the number of beats this segment lasts.
*/
FakeSegment( int s, float b ): m_iStartRow(max(0, s)),
m_fEndBeat(max(0, b)) {}
/**
* @brief Create a Fake Segment with the specified values.
* @param s the starting beat in this segment.
* @param r the row to be real again.
* @param r the number of rows this segment lasts.
*/
FakeSegment( float s, int r ):
m_iStartRow(max(0, BeatToNoteRow(s))),
@@ -821,7 +821,7 @@ struct FakeSegment
/**
* @brief Creates a Fake Segment with the specified values.
* @param s the starting beat of this segment.
* @param b the beat to be real again.
* @param b the number of beats this segment lasts.
*/
FakeSegment( float s, float b ):
m_iStartRow(max(0, BeatToNoteRow((s < b ? s : b)))),
@@ -831,7 +831,7 @@ struct FakeSegment
*/
int m_iStartRow;
/**
* @brief The beat that ends the FakeSegment.
* @brief The number of beats the FakeSegment is alive for.
*/
float m_fEndBeat;
/**