2011-03-17 01:47:30 -04:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "TimingData.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "NoteTypes.h"
|
|
|
|
|
#include "Foreach.h"
|
|
|
|
|
#include <float.h>
|
|
|
|
|
|
|
|
|
|
|
2011-05-09 23:16:56 -04:00
|
|
|
TimingData::TimingData() :
|
|
|
|
|
m_fBeat0OffsetInSeconds(0),
|
|
|
|
|
m_bHasNegativeBpms(false)
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-05-09 23:16:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TimingData::TimingData(float fOffset) :
|
|
|
|
|
m_fBeat0OffsetInSeconds(fOffset),
|
|
|
|
|
m_bHasNegativeBpms(false)
|
|
|
|
|
{
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimingData::GetActualBPM( float &fMinBPMOut, float &fMaxBPMOut ) const
|
|
|
|
|
{
|
|
|
|
|
fMinBPMOut = FLT_MAX;
|
|
|
|
|
fMaxBPMOut = 0;
|
|
|
|
|
FOREACH_CONST( BPMSegment, m_BPMSegments, seg )
|
|
|
|
|
{
|
|
|
|
|
const float fBPM = seg->GetBPM();
|
|
|
|
|
fMaxBPMOut = max( fBPM, fMaxBPMOut );
|
|
|
|
|
fMinBPMOut = min( fBPM, fMinBPMOut );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TimingData::AddBPMSegment( const BPMSegment &seg )
|
|
|
|
|
{
|
|
|
|
|
m_BPMSegments.insert( upper_bound(m_BPMSegments.begin(), m_BPMSegments.end(), seg), seg );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimingData::AddStopSegment( const StopSegment &seg )
|
|
|
|
|
{
|
|
|
|
|
m_StopSegments.insert( upper_bound(m_StopSegments.begin(), m_StopSegments.end(), seg), seg );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimingData::AddTimeSignatureSegment( const TimeSignatureSegment &seg )
|
|
|
|
|
{
|
|
|
|
|
m_vTimeSignatureSegments.insert( upper_bound(m_vTimeSignatureSegments.begin(), m_vTimeSignatureSegments.end(), seg), seg );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimingData::AddWarpSegment( const WarpSegment &seg )
|
|
|
|
|
{
|
|
|
|
|
m_WarpSegments.insert( upper_bound(m_WarpSegments.begin(), m_WarpSegments.end(), seg), seg );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimingData::AddTickcountSegment( const TickcountSegment &seg )
|
|
|
|
|
{
|
|
|
|
|
m_TickcountSegments.insert( upper_bound(m_TickcountSegments.begin(), m_TickcountSegments.end(), seg), seg );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimingData::AddComboSegment( const ComboSegment &seg )
|
|
|
|
|
{
|
|
|
|
|
m_ComboSegments.insert( upper_bound(m_ComboSegments.begin(), m_ComboSegments.end(), seg), seg );
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-04 22:47:59 -04:00
|
|
|
void TimingData::AddLabelSegment( const LabelSegment &seg )
|
|
|
|
|
{
|
|
|
|
|
m_LabelSegments.insert( upper_bound(m_LabelSegments.begin(), m_LabelSegments.end(), seg), seg );
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-15 13:48:10 -04:00
|
|
|
void TimingData::AddSpeedSegment( const SpeedSegment &seg )
|
|
|
|
|
{
|
|
|
|
|
m_SpeedSegments.insert( upper_bound(m_SpeedSegments.begin(), m_SpeedSegments.end(), seg), seg );
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-25 22:44:41 +07:00
|
|
|
void TimingData::AddScrollSegment( const ScrollSegment &seg )
|
|
|
|
|
{
|
|
|
|
|
m_ScrollSegments.insert( upper_bound(m_ScrollSegments.begin(), m_ScrollSegments.end(), seg), seg );
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-16 02:00:17 -04:00
|
|
|
void TimingData::AddFakeSegment( const FakeSegment &seg )
|
|
|
|
|
{
|
|
|
|
|
m_FakeSegments.insert( upper_bound(m_FakeSegments.begin(), m_FakeSegments.end(), seg), seg );
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
/* Change an existing BPM segment, merge identical segments together or insert a new one. */
|
|
|
|
|
void TimingData::SetBPMAtRow( int iNoteRow, float fBPM )
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_BPMSegments.size(); i++ )
|
2011-05-31 23:41:39 +07:00
|
|
|
if( m_BPMSegments[i].GetRow() >= iNoteRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
break;
|
|
|
|
|
|
2011-05-31 23:41:39 +07:00
|
|
|
if( i == m_BPMSegments.size() || m_BPMSegments[i].GetRow() != iNoteRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
// There is no BPMSegment at the specified beat. If the BPM being set differs
|
|
|
|
|
// from the last BPMSegment's BPM, create a new BPMSegment.
|
2011-05-31 23:41:39 +07:00
|
|
|
if( i == 0 || fabsf(m_BPMSegments[i-1].GetBPM() - fBPM) > 1e-5f )
|
2011-03-17 01:47:30 -04:00
|
|
|
AddBPMSegment( BPMSegment(iNoteRow, fBPM) );
|
|
|
|
|
}
|
|
|
|
|
else // BPMSegment being modified is m_BPMSegments[i]
|
|
|
|
|
{
|
2011-05-31 23:41:39 +07:00
|
|
|
if( i > 0 && fabsf(m_BPMSegments[i-1].GetBPM() - fBPM) < 1e-5f )
|
2011-03-17 01:47:30 -04:00
|
|
|
m_BPMSegments.erase( m_BPMSegments.begin()+i, m_BPMSegments.begin()+i+1 );
|
|
|
|
|
else
|
2011-05-31 23:41:39 +07:00
|
|
|
m_BPMSegments[i].SetBPM(fBPM);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimingData::SetStopAtRow( int iRow, float fSeconds, bool bDelay )
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_StopSegments.size(); i++ )
|
2011-06-01 09:50:34 -04:00
|
|
|
if( m_StopSegments[i].GetRow() == iRow && m_StopSegments[i].GetDelay() == bDelay )
|
2011-03-17 01:47:30 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if( i == m_StopSegments.size() ) // there is no Stop/Delay Segment at the current beat
|
|
|
|
|
{
|
|
|
|
|
// create a new StopSegment
|
2011-04-05 14:28:08 -04:00
|
|
|
if( fSeconds > 0 )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
AddStopSegment( StopSegment(iRow, fSeconds, bDelay) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // StopSegment being modified is m_StopSegments[i]
|
|
|
|
|
{
|
2011-04-05 14:28:08 -04:00
|
|
|
if( fSeconds > 0 )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-06-01 09:50:34 -04:00
|
|
|
m_StopSegments[i].SetPause(fSeconds);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
m_StopSegments.erase( m_StopSegments.begin()+i, m_StopSegments.begin()+i+1 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimingData::SetTimeSignatureAtRow( int iRow, int iNumerator, int iDenominator )
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i = 0; i < m_vTimeSignatureSegments.size(); i++ )
|
|
|
|
|
{
|
2011-05-31 14:27:55 -04:00
|
|
|
if( m_vTimeSignatureSegments[i].GetRow() >= iRow)
|
2011-03-17 01:47:30 -04:00
|
|
|
break; // We found our segment.
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-31 14:27:55 -04:00
|
|
|
if ( i == m_vTimeSignatureSegments.size() || m_vTimeSignatureSegments[i].GetRow() != iRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
// No specific segmeent here: place one if it differs.
|
|
|
|
|
if( i == 0 ||
|
2011-05-31 14:27:55 -04:00
|
|
|
( m_vTimeSignatureSegments[i-1].GetNum() != iNumerator
|
|
|
|
|
|| m_vTimeSignatureSegments[i-1].GetDen() != iDenominator ) )
|
2011-03-17 01:47:30 -04:00
|
|
|
AddTimeSignatureSegment( TimeSignatureSegment(iRow, iNumerator, iDenominator) );
|
|
|
|
|
}
|
|
|
|
|
else // TimeSignatureSegment being modified is m_vTimeSignatureSegments[i]
|
|
|
|
|
{
|
2011-05-31 14:27:55 -04:00
|
|
|
if( i > 0 && m_vTimeSignatureSegments[i-1].GetNum() == iNumerator
|
|
|
|
|
&& m_vTimeSignatureSegments[i-1].GetDen() == iDenominator )
|
2011-03-17 01:47:30 -04:00
|
|
|
m_vTimeSignatureSegments.erase( m_vTimeSignatureSegments.begin()+i,
|
|
|
|
|
m_vTimeSignatureSegments.begin()+i+1 );
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-05-31 14:27:55 -04:00
|
|
|
m_vTimeSignatureSegments[i].SetNum(iNumerator);
|
|
|
|
|
m_vTimeSignatureSegments[i].SetDen(iDenominator);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimingData::SetTimeSignatureNumeratorAtRow( int iRow, int iNumerator )
|
|
|
|
|
{
|
2011-05-31 14:27:55 -04:00
|
|
|
SetTimeSignatureAtRow( iRow, iNumerator, GetTimeSignatureSegmentAtBeat( NoteRowToBeat( iRow ) ).GetDen() );
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimingData::SetTimeSignatureDenominatorAtRow( int iRow, int iDenominator )
|
|
|
|
|
{
|
2011-05-31 14:27:55 -04:00
|
|
|
SetTimeSignatureAtRow( iRow, GetTimeSignatureSegmentAtBeat( NoteRowToBeat( iRow ) ).GetNum(), iDenominator );
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
2011-03-25 00:54:33 -04:00
|
|
|
void TimingData::SetWarpAtRow( int iRow, float fNew )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-03-25 00:54:33 -04:00
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_WarpSegments.size(); i++ )
|
2011-05-31 10:59:18 -04:00
|
|
|
if( m_WarpSegments[i].GetRow() == iRow )
|
2011-03-25 00:54:33 -04:00
|
|
|
break;
|
2011-05-16 10:24:59 -04:00
|
|
|
bool valid = iRow > 0 && fNew > 0;
|
2011-03-25 00:54:33 -04:00
|
|
|
if( i == m_WarpSegments.size() )
|
|
|
|
|
{
|
|
|
|
|
if( valid )
|
|
|
|
|
{
|
|
|
|
|
AddWarpSegment( WarpSegment(iRow, fNew) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if( valid )
|
|
|
|
|
{
|
2011-05-31 10:59:18 -04:00
|
|
|
m_WarpSegments[i].SetLength(fNew);
|
2011-03-25 00:54:33 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
m_WarpSegments.erase( m_WarpSegments.begin()+i, m_WarpSegments.begin()+i+1 );
|
|
|
|
|
}
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Change an existing Tickcount segment, merge identical segments together or insert a new one. */
|
|
|
|
|
void TimingData::SetTickcountAtRow( int iRow, int iTicks )
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_TickcountSegments.size(); i++ )
|
2011-05-31 01:20:22 -04:00
|
|
|
if( m_TickcountSegments[i].GetRow() >= iRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
break;
|
|
|
|
|
|
2011-05-31 01:20:22 -04:00
|
|
|
if( i == m_TickcountSegments.size() || m_TickcountSegments[i].GetRow() != iRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
// No TickcountSegment here. Make a new segment if required.
|
2011-05-31 01:20:22 -04:00
|
|
|
if( i == 0 || m_TickcountSegments[i-1].GetTicks() != iTicks )
|
2011-03-17 01:47:30 -04:00
|
|
|
AddTickcountSegment( TickcountSegment(iRow, iTicks ) );
|
|
|
|
|
}
|
|
|
|
|
else // TickcountSegment being modified is m_TickcountSegments[i]
|
|
|
|
|
{
|
2011-05-31 01:20:22 -04:00
|
|
|
if( i > 0 && m_TickcountSegments[i-1].GetTicks() == iTicks )
|
2011-03-17 01:47:30 -04:00
|
|
|
m_TickcountSegments.erase( m_TickcountSegments.begin()+i, m_TickcountSegments.begin()+i+1 );
|
|
|
|
|
else
|
2011-05-31 01:20:22 -04:00
|
|
|
m_TickcountSegments[i].SetTicks(iTicks);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimingData::SetComboAtRow( int iRow, int iCombo )
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_ComboSegments.size(); i++ )
|
2011-05-31 11:45:25 -04:00
|
|
|
if( m_ComboSegments[i].GetRow() >= iRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
break;
|
|
|
|
|
|
2011-05-31 11:45:25 -04:00
|
|
|
if( i == m_ComboSegments.size() || m_ComboSegments[i].GetRow() != iRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-05-31 11:45:25 -04:00
|
|
|
if( i == 0 || m_ComboSegments[i-1].GetCombo() != iCombo )
|
2011-03-17 01:47:30 -04:00
|
|
|
AddComboSegment( ComboSegment(iRow, iCombo ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-05-31 11:45:25 -04:00
|
|
|
if( i > 0 && m_ComboSegments[i-1].GetCombo() == iCombo )
|
2011-03-17 01:47:30 -04:00
|
|
|
m_ComboSegments.erase( m_ComboSegments.begin()+i, m_ComboSegments.begin()+i+1 );
|
|
|
|
|
else
|
2011-05-31 11:45:25 -04:00
|
|
|
m_ComboSegments[i].SetCombo(iCombo);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-04 23:03:10 -04:00
|
|
|
void TimingData::SetLabelAtRow( int iRow, const RString sLabel )
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_LabelSegments.size(); i++ )
|
2011-05-31 11:22:21 -04:00
|
|
|
if( m_LabelSegments[i].GetRow() >= iRow )
|
2011-04-04 23:03:10 -04:00
|
|
|
break;
|
|
|
|
|
|
2011-05-31 11:22:21 -04:00
|
|
|
if( i == m_LabelSegments.size() || m_LabelSegments[i].GetRow() != iRow )
|
2011-04-04 23:03:10 -04:00
|
|
|
{
|
2011-05-31 11:22:21 -04:00
|
|
|
if( i == 0 || m_LabelSegments[i-1].GetLabel() != sLabel )
|
2011-04-04 23:03:10 -04:00
|
|
|
AddLabelSegment( LabelSegment(iRow, sLabel ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-05-31 11:22:21 -04:00
|
|
|
if( i > 0 && ( m_LabelSegments[i-1].GetLabel() == sLabel || sLabel == "" ) )
|
2011-04-04 23:03:10 -04:00
|
|
|
m_LabelSegments.erase( m_LabelSegments.begin()+i, m_LabelSegments.begin()+i+1 );
|
|
|
|
|
else
|
2011-05-31 11:22:21 -04:00
|
|
|
m_LabelSegments[i].SetLabel(sLabel);
|
2011-04-04 23:03:10 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-15 23:48:03 -04:00
|
|
|
void TimingData::SetSpeedAtRow( int iRow, float fPercent, float fWait, unsigned short usMode )
|
2011-05-15 13:48:10 -04:00
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i = 0; i < m_SpeedSegments.size(); i++ )
|
|
|
|
|
{
|
2011-05-31 15:27:27 -04:00
|
|
|
if( m_SpeedSegments[i].GetRow() >= iRow)
|
2011-05-15 13:48:10 -04:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-31 15:27:27 -04:00
|
|
|
if ( i == m_SpeedSegments.size() || m_SpeedSegments[i].GetRow() != iRow )
|
2011-05-15 13:48:10 -04:00
|
|
|
{
|
2011-05-16 09:44:07 -04:00
|
|
|
// the core mod itself matters the most for comparisons.
|
2011-05-31 15:27:27 -04:00
|
|
|
if( i == 0 || m_SpeedSegments[i-1].GetRatio() != fPercent )
|
2011-05-15 23:48:03 -04:00
|
|
|
AddSpeedSegment( SpeedSegment(iRow, fPercent, fWait, usMode) );
|
2011-05-15 13:48:10 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-05-16 09:44:07 -04:00
|
|
|
// The others aren't compared: only the mod itself matters.
|
2011-05-31 15:27:27 -04:00
|
|
|
if( i > 0 && m_SpeedSegments[i-1].GetRatio() == fPercent )
|
2011-05-15 13:48:10 -04:00
|
|
|
m_SpeedSegments.erase( m_SpeedSegments.begin()+i,
|
|
|
|
|
m_SpeedSegments.begin()+i+1 );
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-05-31 15:27:27 -04:00
|
|
|
m_SpeedSegments[i].SetRatio(fPercent);
|
|
|
|
|
m_SpeedSegments[i].SetLength(fWait);
|
|
|
|
|
m_SpeedSegments[i].SetUnit(usMode);
|
2011-05-15 13:48:10 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-25 22:44:41 +07:00
|
|
|
void TimingData::SetScrollAtRow( int iRow, float fPercent )
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i = 0; i < m_ScrollSegments.size(); i++ )
|
|
|
|
|
{
|
2011-06-01 08:44:09 -04:00
|
|
|
if( m_ScrollSegments[i].GetRow() >= iRow)
|
2011-05-25 22:44:41 +07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-01 08:44:09 -04:00
|
|
|
if ( i == m_ScrollSegments.size() || m_ScrollSegments[i].GetRow() != iRow )
|
2011-05-25 22:44:41 +07:00
|
|
|
{
|
|
|
|
|
// the core mod itself matters the most for comparisons.
|
2011-06-01 08:44:09 -04:00
|
|
|
if( i == 0 || m_ScrollSegments[i-1].GetRatio() != fPercent )
|
2011-05-25 22:44:41 +07:00
|
|
|
AddScrollSegment( ScrollSegment(iRow, fPercent) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// The others aren't compared: only the mod itself matters.
|
2011-06-01 08:44:09 -04:00
|
|
|
if( i > 0 && m_ScrollSegments[i-1].GetRatio() == fPercent )
|
2011-05-25 22:44:41 +07:00
|
|
|
m_ScrollSegments.erase( m_ScrollSegments.begin()+i,
|
|
|
|
|
m_ScrollSegments.begin()+i+1 );
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-06-01 08:44:09 -04:00
|
|
|
m_ScrollSegments[i].SetRatio(fPercent);
|
2011-05-25 22:44:41 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-16 02:00:17 -04:00
|
|
|
void TimingData::SetFakeAtRow( int iRow, float fNew )
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_FakeSegments.size(); i++ )
|
2011-05-31 00:51:25 -04:00
|
|
|
if( m_FakeSegments[i].GetRow() == iRow )
|
2011-05-16 02:00:17 -04:00
|
|
|
break;
|
2011-05-16 16:17:34 -04:00
|
|
|
bool valid = iRow > 0 && fNew > 0;
|
2011-05-16 02:00:17 -04:00
|
|
|
if( i == m_FakeSegments.size() )
|
|
|
|
|
{
|
|
|
|
|
if( valid )
|
|
|
|
|
{
|
|
|
|
|
AddFakeSegment( FakeSegment(iRow, fNew) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if( valid )
|
|
|
|
|
{
|
2011-05-31 00:51:25 -04:00
|
|
|
m_FakeSegments[i].SetLength(fNew);
|
2011-05-16 02:00:17 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
m_FakeSegments.erase( m_FakeSegments.begin()+i, m_FakeSegments.begin()+i+1 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-15 13:48:10 -04:00
|
|
|
void TimingData::SetSpeedPercentAtRow( int iRow, float fPercent )
|
|
|
|
|
{
|
2011-05-15 23:48:03 -04:00
|
|
|
SetSpeedAtRow( iRow,
|
|
|
|
|
fPercent,
|
2011-05-31 15:27:27 -04:00
|
|
|
GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).GetLength(),
|
|
|
|
|
GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).GetUnit());
|
2011-05-15 13:48:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimingData::SetSpeedWaitAtRow( int iRow, float fWait )
|
|
|
|
|
{
|
2011-05-15 23:48:03 -04:00
|
|
|
SetSpeedAtRow( iRow,
|
2011-05-31 15:27:27 -04:00
|
|
|
GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).GetRatio(),
|
2011-05-15 23:48:03 -04:00
|
|
|
fWait,
|
2011-05-31 15:27:27 -04:00
|
|
|
GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).GetUnit());
|
2011-05-15 23:48:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimingData::SetSpeedModeAtRow( int iRow, unsigned short usMode )
|
|
|
|
|
{
|
|
|
|
|
SetSpeedAtRow( iRow,
|
2011-05-31 15:27:27 -04:00
|
|
|
GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).GetRatio(),
|
|
|
|
|
GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).GetLength(),
|
2011-05-15 23:48:03 -04:00
|
|
|
usMode );
|
2011-05-15 13:48:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
float TimingData::GetStopAtRow( int iNoteRow, bool bDelay ) const
|
|
|
|
|
{
|
|
|
|
|
for( unsigned i=0; i<m_StopSegments.size(); i++ )
|
|
|
|
|
{
|
2011-06-01 09:50:34 -04:00
|
|
|
const StopSegment &s = m_StopSegments[i];
|
|
|
|
|
if( s.GetDelay() == bDelay && s.GetRow() == iNoteRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-06-01 09:50:34 -04:00
|
|
|
return s.GetPause();
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetStopAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
return GetStopAtRow( iRow, false );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float TimingData::GetDelayAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
return GetStopAtRow( iRow, true );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TimingData::GetComboAtRow( int iNoteRow ) const
|
|
|
|
|
{
|
2011-05-31 11:45:25 -04:00
|
|
|
return m_ComboSegments[GetComboSegmentIndexAtRow( iNoteRow )].GetCombo();
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
2011-04-04 23:03:10 -04:00
|
|
|
RString TimingData::GetLabelAtRow( int iRow ) const
|
|
|
|
|
{
|
2011-05-31 11:22:21 -04:00
|
|
|
return m_LabelSegments[GetLabelSegmentIndexAtRow( iRow )].GetLabel();
|
2011-04-04 23:03:10 -04:00
|
|
|
}
|
|
|
|
|
|
2011-03-25 00:54:33 -04:00
|
|
|
float TimingData::GetWarpAtRow( int iWarpRow ) const
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
for( unsigned i=0; i<m_WarpSegments.size(); i++ )
|
|
|
|
|
{
|
2011-05-31 10:59:18 -04:00
|
|
|
if( m_WarpSegments[i].GetRow() == iWarpRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-05-31 10:59:18 -04:00
|
|
|
return m_WarpSegments[i].GetLength();
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-15 13:48:10 -04:00
|
|
|
float TimingData::GetSpeedPercentAtRow( int iRow )
|
|
|
|
|
{
|
2011-05-31 15:27:27 -04:00
|
|
|
return GetSpeedSegmentAtRow( iRow ).GetRatio();
|
2011-05-15 13:48:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetSpeedWaitAtRow( int iRow )
|
|
|
|
|
{
|
2011-05-31 15:27:27 -04:00
|
|
|
return GetSpeedSegmentAtRow( iRow ).GetLength();
|
2011-05-15 13:48:10 -04:00
|
|
|
}
|
|
|
|
|
|
2011-05-15 23:48:03 -04:00
|
|
|
unsigned short TimingData::GetSpeedModeAtRow( int iRow )
|
|
|
|
|
{
|
2011-05-31 15:27:27 -04:00
|
|
|
return GetSpeedSegmentAtRow( iRow ).GetUnit();
|
2011-05-15 23:48:03 -04:00
|
|
|
}
|
|
|
|
|
|
2011-05-25 22:44:41 +07:00
|
|
|
float TimingData::GetScrollAtRow( int iRow )
|
|
|
|
|
{
|
2011-06-01 08:44:09 -04:00
|
|
|
return GetScrollSegmentAtRow( iRow ).GetRatio();
|
2011-05-25 22:44:41 +07:00
|
|
|
}
|
|
|
|
|
|
2011-05-16 02:00:17 -04:00
|
|
|
float TimingData::GetFakeAtRow( int iFakeRow ) const
|
|
|
|
|
{
|
|
|
|
|
for( unsigned i=0; i<m_FakeSegments.size(); i++ )
|
|
|
|
|
{
|
2011-05-31 00:51:25 -04:00
|
|
|
if( m_FakeSegments[i].GetRow() == iFakeRow )
|
2011-05-16 02:00:17 -04:00
|
|
|
{
|
2011-05-31 00:51:25 -04:00
|
|
|
return m_FakeSegments[i].GetLength();
|
2011-05-16 02:00:17 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
// Multiply the BPM in the range [fStartBeat,fEndBeat) by fFactor.
|
|
|
|
|
void TimingData::MultiplyBPMInBeatRange( int iStartIndex, int iEndIndex, float fFactor )
|
|
|
|
|
{
|
|
|
|
|
// Change all other BPM segments in this range.
|
|
|
|
|
for( unsigned i=0; i<m_BPMSegments.size(); i++ )
|
|
|
|
|
{
|
2011-05-31 23:41:39 +07:00
|
|
|
const int iStartIndexThisSegment = m_BPMSegments[i].GetRow();
|
2011-03-17 01:47:30 -04:00
|
|
|
const bool bIsLastBPMSegment = i==m_BPMSegments.size()-1;
|
2011-05-31 23:41:39 +07:00
|
|
|
const int iStartIndexNextSegment = bIsLastBPMSegment ? INT_MAX : m_BPMSegments[i+1].GetRow();
|
2011-03-17 01:47:30 -04:00
|
|
|
|
|
|
|
|
if( iStartIndexThisSegment <= iStartIndex && iStartIndexNextSegment <= iStartIndex )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* If this BPM segment crosses the beginning of the range,
|
|
|
|
|
* split it into two. */
|
|
|
|
|
if( iStartIndexThisSegment < iStartIndex && iStartIndexNextSegment > iStartIndex )
|
|
|
|
|
{
|
|
|
|
|
BPMSegment b = m_BPMSegments[i];
|
2011-05-31 23:41:39 +07:00
|
|
|
b.SetRow(iStartIndexNextSegment);
|
2011-03-17 01:47:30 -04:00
|
|
|
m_BPMSegments.insert( m_BPMSegments.begin()+i+1, b );
|
|
|
|
|
|
|
|
|
|
/* Don't apply the BPM change to the first half of the segment we
|
|
|
|
|
* just split, since it lies outside the range. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If this BPM segment crosses the end of the range, split it into two.
|
|
|
|
|
if( iStartIndexThisSegment < iEndIndex && iStartIndexNextSegment > iEndIndex )
|
|
|
|
|
{
|
|
|
|
|
BPMSegment b = m_BPMSegments[i];
|
2011-05-31 23:41:39 +07:00
|
|
|
b.SetRow(iEndIndex);
|
2011-03-17 01:47:30 -04:00
|
|
|
m_BPMSegments.insert( m_BPMSegments.begin()+i+1, b );
|
|
|
|
|
}
|
|
|
|
|
else if( iStartIndexNextSegment > iEndIndex )
|
|
|
|
|
continue;
|
|
|
|
|
|
2011-05-31 23:41:39 +07:00
|
|
|
m_BPMSegments[i].SetBPM(m_BPMSegments[i].GetBPM() * fFactor);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetBPMAtRow( int iNoteRow ) const
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_BPMSegments.size()-1; i++ )
|
2011-05-31 23:41:39 +07:00
|
|
|
if( m_BPMSegments[i+1].GetRow() > iNoteRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
break;
|
|
|
|
|
return m_BPMSegments[i].GetBPM();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TimingData::GetBPMSegmentIndexAtRow( int iNoteRow ) const
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_BPMSegments.size()-1; i++ )
|
2011-05-31 23:41:39 +07:00
|
|
|
if( m_BPMSegments[i+1].GetRow() > iNoteRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
break;
|
2011-03-25 00:54:33 -04:00
|
|
|
return static_cast<int>(i);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TimingData::GetStopSegmentIndexAtRow( int iNoteRow, bool bDelay ) const
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_StopSegments.size()-1; i++ )
|
|
|
|
|
{
|
|
|
|
|
const StopSegment& s = m_StopSegments[i+1];
|
2011-06-01 09:50:34 -04:00
|
|
|
if( s.GetRow() > iNoteRow && s.GetDelay() == bDelay )
|
2011-03-17 01:47:30 -04:00
|
|
|
break;
|
|
|
|
|
}
|
2011-03-25 00:54:33 -04:00
|
|
|
return static_cast<int>(i);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
2011-03-25 00:54:33 -04:00
|
|
|
int TimingData::GetWarpSegmentIndexAtRow( int iNoteRow ) const
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-03-25 00:54:33 -04:00
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_WarpSegments.size()-1; i++ )
|
|
|
|
|
{
|
|
|
|
|
const WarpSegment& s = m_WarpSegments[i+1];
|
2011-05-31 10:59:18 -04:00
|
|
|
if( s.GetRow() > iNoteRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
break;
|
2011-03-25 00:54:33 -04:00
|
|
|
}
|
|
|
|
|
return static_cast<int>(i);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
2011-05-16 02:00:17 -04:00
|
|
|
int TimingData::GetFakeSegmentIndexAtRow( int iNoteRow ) const
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_FakeSegments.size()-1; i++ )
|
|
|
|
|
{
|
|
|
|
|
const FakeSegment& s = m_FakeSegments[i+1];
|
2011-05-31 00:51:25 -04:00
|
|
|
if( s.GetRow() > iNoteRow )
|
2011-05-16 02:00:17 -04:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return static_cast<int>(i);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-25 23:19:31 +07:00
|
|
|
bool TimingData::IsWarpAtRow( int iNoteRow ) const
|
|
|
|
|
{
|
2011-03-25 23:40:03 +07:00
|
|
|
if( m_WarpSegments.empty() )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
int i = GetWarpSegmentIndexAtRow( iNoteRow );
|
|
|
|
|
const WarpSegment& s = m_WarpSegments[i];
|
2011-05-31 10:59:18 -04:00
|
|
|
float beatRow = NoteRowToBeat(iNoteRow);
|
|
|
|
|
if( s.GetBeat() <= beatRow && beatRow < (s.GetBeat() + s.GetLength() ) )
|
2011-03-26 22:07:24 +07:00
|
|
|
{
|
2011-05-24 13:07:59 +07:00
|
|
|
// Allow stops inside warps to allow things like stop, warp, stop, warp, stop, and so on.
|
2011-03-26 22:07:24 +07:00
|
|
|
if( m_StopSegments.empty() )
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2011-03-27 15:56:40 +07:00
|
|
|
if( GetStopAtRow(iNoteRow) != 0.0f || GetDelayAtRow(iNoteRow) != 0.0f )
|
2011-03-26 22:07:24 +07:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2011-03-25 23:19:31 +07:00
|
|
|
}
|
|
|
|
|
|
2011-05-16 02:00:17 -04:00
|
|
|
bool TimingData::IsFakeAtRow( int iNoteRow ) const
|
|
|
|
|
{
|
|
|
|
|
if( m_FakeSegments.empty() )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
int i = GetFakeSegmentIndexAtRow( iNoteRow );
|
|
|
|
|
const FakeSegment& s = m_FakeSegments[i];
|
2011-05-31 00:51:25 -04:00
|
|
|
float beatRow = NoteRowToBeat(iNoteRow);
|
|
|
|
|
if( s.GetBeat() <= beatRow && beatRow < ( s.GetBeat() + s.GetLength() ) )
|
2011-05-16 02:00:17 -04:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-25 00:54:33 -04:00
|
|
|
int TimingData::GetTimeSignatureSegmentIndexAtRow( int iRow ) const
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
unsigned i;
|
2011-03-25 00:54:33 -04:00
|
|
|
for (i=0; i < m_vTimeSignatureSegments.size() - 1; i++ )
|
2011-05-31 14:27:55 -04:00
|
|
|
if( m_vTimeSignatureSegments[i+1].GetRow() > iRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
break;
|
2011-03-25 00:54:33 -04:00
|
|
|
return static_cast<int>(i);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TimingData::GetComboSegmentIndexAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_ComboSegments.size()-1; i++ )
|
|
|
|
|
{
|
|
|
|
|
const ComboSegment& s = m_ComboSegments[i+1];
|
2011-05-31 11:45:25 -04:00
|
|
|
if( s.GetRow() > iRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
break;
|
|
|
|
|
}
|
2011-03-25 00:54:33 -04:00
|
|
|
return static_cast<int>(i);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
2011-04-04 23:03:10 -04:00
|
|
|
int TimingData::GetLabelSegmentIndexAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_LabelSegments.size()-1; i++ )
|
|
|
|
|
{
|
|
|
|
|
const LabelSegment& s = m_LabelSegments[i+1];
|
2011-05-31 11:22:21 -04:00
|
|
|
if( s.GetRow() > iRow )
|
2011-04-04 23:03:10 -04:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return static_cast<int>(i);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-15 13:48:10 -04:00
|
|
|
int TimingData::GetSpeedSegmentIndexAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for (i=0; i < m_SpeedSegments.size() - 1; i++ )
|
2011-05-31 15:27:27 -04:00
|
|
|
if( m_SpeedSegments[i+1].GetRow() > iRow )
|
2011-05-15 13:48:10 -04:00
|
|
|
break;
|
|
|
|
|
return static_cast<int>(i);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-25 22:44:41 +07:00
|
|
|
int TimingData::GetScrollSegmentIndexAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for (i=0; i < m_ScrollSegments.size() - 1; i++ )
|
2011-06-01 08:44:09 -04:00
|
|
|
if( m_ScrollSegments[i+1].GetRow() > iRow )
|
2011-05-25 22:44:41 +07:00
|
|
|
break;
|
|
|
|
|
return static_cast<int>(i);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
BPMSegment& TimingData::GetBPMSegmentAtRow( int iNoteRow )
|
|
|
|
|
{
|
|
|
|
|
static BPMSegment empty;
|
|
|
|
|
if( m_BPMSegments.empty() )
|
|
|
|
|
return empty;
|
|
|
|
|
|
|
|
|
|
int i = GetBPMSegmentIndexAtRow( iNoteRow );
|
|
|
|
|
return m_BPMSegments[i];
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-25 00:54:33 -04:00
|
|
|
TimeSignatureSegment& TimingData::GetTimeSignatureSegmentAtRow( int iRow )
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_vTimeSignatureSegments.size()-1; i++ )
|
2011-05-31 14:27:55 -04:00
|
|
|
if( m_vTimeSignatureSegments[i+1].GetRow() > iRow )
|
2011-03-25 00:54:33 -04:00
|
|
|
break;
|
|
|
|
|
return m_vTimeSignatureSegments[i];
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-15 13:48:10 -04:00
|
|
|
SpeedSegment& TimingData::GetSpeedSegmentAtRow( int iRow )
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_SpeedSegments.size()-1; i++ )
|
2011-05-31 15:27:27 -04:00
|
|
|
if( m_SpeedSegments[i+1].GetRow() > iRow )
|
2011-05-15 13:48:10 -04:00
|
|
|
break;
|
|
|
|
|
return m_SpeedSegments[i];
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-25 22:44:41 +07:00
|
|
|
ScrollSegment& TimingData::GetScrollSegmentAtRow( int iRow )
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_ScrollSegments.size()-1; i++ )
|
2011-06-01 08:44:09 -04:00
|
|
|
if( m_ScrollSegments[i+1].GetRow() > iRow )
|
2011-05-25 22:44:41 +07:00
|
|
|
break;
|
|
|
|
|
return m_ScrollSegments[i];
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-25 00:54:33 -04:00
|
|
|
int TimingData::GetTimeSignatureNumeratorAtRow( int iRow )
|
|
|
|
|
{
|
2011-05-31 14:27:55 -04:00
|
|
|
return GetTimeSignatureSegmentAtRow( iRow ).GetNum();
|
2011-03-25 00:54:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TimingData::GetTimeSignatureDenominatorAtRow( int iRow )
|
|
|
|
|
{
|
2011-05-31 14:27:55 -04:00
|
|
|
return GetTimeSignatureSegmentAtRow( iRow ).GetDen();
|
2011-03-25 00:54:33 -04:00
|
|
|
}
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
ComboSegment& TimingData::GetComboSegmentAtRow( int iRow )
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_ComboSegments.size()-1; i++ )
|
2011-05-31 11:45:25 -04:00
|
|
|
if( m_ComboSegments[i+1].GetRow() > iRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
break;
|
|
|
|
|
return m_ComboSegments[i];
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-04 23:03:10 -04:00
|
|
|
LabelSegment& TimingData::GetLabelSegmentAtRow( int iRow )
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i=0; i<m_LabelSegments.size()-1; i++ )
|
2011-05-31 11:22:21 -04:00
|
|
|
if( m_LabelSegments[i+1].GetRow() > iRow )
|
2011-04-04 23:03:10 -04:00
|
|
|
break;
|
|
|
|
|
return m_LabelSegments[i];
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
StopSegment& TimingData::GetStopSegmentAtRow( int iNoteRow, bool bDelay )
|
|
|
|
|
{
|
|
|
|
|
static StopSegment empty;
|
|
|
|
|
if( m_StopSegments.empty() )
|
|
|
|
|
return empty;
|
|
|
|
|
|
|
|
|
|
int i = GetStopSegmentIndexAtRow( iNoteRow, bDelay );
|
|
|
|
|
return m_StopSegments[i];
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-25 00:54:33 -04:00
|
|
|
WarpSegment& TimingData::GetWarpSegmentAtRow( int iRow )
|
|
|
|
|
{
|
|
|
|
|
static WarpSegment empty;
|
|
|
|
|
if( m_WarpSegments.empty() )
|
|
|
|
|
return empty;
|
|
|
|
|
|
|
|
|
|
int i = GetWarpSegmentIndexAtRow( iRow );
|
|
|
|
|
return m_WarpSegments[i];
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-16 02:00:17 -04:00
|
|
|
FakeSegment& TimingData::GetFakeSegmentAtRow( int iRow )
|
|
|
|
|
{
|
|
|
|
|
static FakeSegment empty;
|
|
|
|
|
if( m_FakeSegments.empty() )
|
|
|
|
|
return empty;
|
|
|
|
|
|
|
|
|
|
int i = GetFakeSegmentIndexAtRow( iRow );
|
|
|
|
|
return m_FakeSegments[i];
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
int TimingData::GetTickcountSegmentIndexAtRow( int iRow ) const
|
|
|
|
|
{
|
2011-04-05 00:35:45 -04:00
|
|
|
unsigned i;
|
|
|
|
|
for (i=0; i < m_TickcountSegments.size() - 1; i++ )
|
2011-05-31 01:20:22 -04:00
|
|
|
if( m_TickcountSegments[i+1].GetRow() > iRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
break;
|
2011-04-05 00:35:45 -04:00
|
|
|
return static_cast<int>(i);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TickcountSegment& TimingData::GetTickcountSegmentAtRow( int iRow )
|
|
|
|
|
{
|
|
|
|
|
static TickcountSegment empty;
|
|
|
|
|
if( m_TickcountSegments.empty() )
|
|
|
|
|
return empty;
|
|
|
|
|
|
|
|
|
|
int i = GetTickcountSegmentIndexAtBeat( iRow );
|
|
|
|
|
return m_TickcountSegments[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TimingData::GetTickcountAtRow( int iRow ) const
|
|
|
|
|
{
|
2011-05-31 01:20:22 -04:00
|
|
|
return m_TickcountSegments[GetTickcountSegmentIndexAtRow( iRow )].GetTicks();
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
2011-06-26 22:24:22 -04:00
|
|
|
float TimingData::GetPreviousBPMSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
float backup = -1;
|
|
|
|
|
for (unsigned i = 0; i < m_BPMSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_BPMSegments[i].GetRow() >= iRow )
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
backup = m_BPMSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return (backup > -1) ? backup : NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetNextBPMSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
for (unsigned i = 0; i < m_BPMSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_BPMSegments[i].GetRow() <= iRow )
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
return m_BPMSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetPreviousStopSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
float backup = -1;
|
|
|
|
|
for (unsigned i = 0; i < m_StopSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
const StopSegment &s = m_StopSegments[i];
|
2011-06-26 22:56:39 -04:00
|
|
|
if( s.GetRow() >= iRow )
|
2011-06-26 22:24:22 -04:00
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-06-26 22:56:39 -04:00
|
|
|
if (!s.GetDelay())
|
|
|
|
|
backup = s.GetBeat();
|
2011-06-26 22:24:22 -04:00
|
|
|
}
|
|
|
|
|
return (backup > -1) ? backup : NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetNextStopSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
for (unsigned i = 0; i < m_StopSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
const StopSegment &s = m_StopSegments[i];
|
2011-06-26 22:56:39 -04:00
|
|
|
if( s.GetRow() <= iRow )
|
2011-06-26 22:24:22 -04:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2011-06-26 22:56:39 -04:00
|
|
|
if (!s.GetDelay())
|
|
|
|
|
return s.GetBeat();
|
2011-06-26 22:24:22 -04:00
|
|
|
}
|
|
|
|
|
return NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetPreviousDelaySegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
float backup = -1;
|
|
|
|
|
for (unsigned i = 0; i < m_StopSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
const StopSegment &s = m_StopSegments[i];
|
2011-06-26 22:56:39 -04:00
|
|
|
if( s.GetRow() >= iRow )
|
2011-06-26 22:24:22 -04:00
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-06-26 22:56:39 -04:00
|
|
|
if (s.GetDelay())
|
|
|
|
|
backup = s.GetBeat();
|
2011-06-26 22:24:22 -04:00
|
|
|
}
|
|
|
|
|
return (backup > -1) ? backup : NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetNextDelaySegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
for (unsigned i = 0; i < m_StopSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
const StopSegment &s = m_StopSegments[i];
|
2011-06-26 22:56:39 -04:00
|
|
|
if( s.GetRow() <= iRow )
|
2011-06-26 22:24:22 -04:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2011-06-26 22:56:39 -04:00
|
|
|
if (s.GetDelay())
|
|
|
|
|
return s.GetBeat();
|
2011-06-26 22:24:22 -04:00
|
|
|
}
|
|
|
|
|
return NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetPreviousTimeSignatureSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
float backup = -1;
|
|
|
|
|
for (unsigned i = 0; i < m_vTimeSignatureSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_vTimeSignatureSegments[i].GetRow() >= iRow )
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
backup = m_vTimeSignatureSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return (backup > -1) ? backup : NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetNextTimeSignatureSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
for (unsigned i = 0; i < m_vTimeSignatureSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_vTimeSignatureSegments[i].GetRow() <= iRow )
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
return m_vTimeSignatureSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float TimingData::GetPreviousTickcountSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
float backup = -1;
|
|
|
|
|
for (unsigned i = 0; i < m_TickcountSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_TickcountSegments[i].GetRow() >= iRow )
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
backup = m_TickcountSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return (backup > -1) ? backup : NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetNextTickcountSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
for (unsigned i = 0; i < m_TickcountSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_TickcountSegments[i].GetRow() <= iRow )
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
return m_TickcountSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetPreviousComboSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
float backup = -1;
|
|
|
|
|
for (unsigned i = 0; i < m_ComboSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_ComboSegments[i].GetRow() >= iRow )
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
backup = m_ComboSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return (backup > -1) ? backup : NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetNextComboSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
for (unsigned i = 0; i < m_ComboSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_ComboSegments[i].GetRow() <= iRow )
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
return m_ComboSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float TimingData::GetPreviousWarpSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
float backup = -1;
|
|
|
|
|
for (unsigned i = 0; i < m_WarpSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_WarpSegments[i].GetRow() >= iRow )
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
backup = m_WarpSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return (backup > -1) ? backup : NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetNextWarpSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
for (unsigned i = 0; i < m_WarpSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_WarpSegments[i].GetRow() <= iRow )
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
return m_WarpSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetPreviousFakeSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
float backup = -1;
|
|
|
|
|
for (unsigned i = 0; i < m_FakeSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_FakeSegments[i].GetRow() >= iRow )
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
backup = m_FakeSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return (backup > -1) ? backup : NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetNextFakeSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
for (unsigned i = 0; i < m_FakeSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_FakeSegments[i].GetRow() <= iRow )
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
return m_FakeSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetPreviousSpeedSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
float backup = -1;
|
|
|
|
|
for (unsigned i = 0; i < m_SpeedSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_SpeedSegments[i].GetRow() >= iRow )
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
backup = m_SpeedSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return (backup > -1) ? backup : NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetNextSpeedSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
for (unsigned i = 0; i < m_SpeedSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_SpeedSegments[i].GetRow() <= iRow )
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
return m_SpeedSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetPreviousScrollSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
float backup = -1;
|
|
|
|
|
for (unsigned i = 0; i < m_ScrollSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_ScrollSegments[i].GetRow() >= iRow )
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
backup = m_ScrollSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return (backup > -1) ? backup : NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetNextScrollSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
for (unsigned i = 0; i < m_ScrollSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if( m_ScrollSegments[i].GetRow() <= iRow )
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
return m_ScrollSegments[i].GetBeat();
|
|
|
|
|
}
|
|
|
|
|
return NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-05 00:35:45 -04:00
|
|
|
float TimingData::GetPreviousLabelSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
float backup = -1;
|
|
|
|
|
for (unsigned i = 0; i < m_LabelSegments.size(); i++ )
|
|
|
|
|
{
|
2011-05-31 11:22:21 -04:00
|
|
|
if( m_LabelSegments[i].GetRow() >= iRow )
|
2011-04-05 00:35:45 -04:00
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-05-31 11:22:21 -04:00
|
|
|
backup = m_LabelSegments[i].GetBeat();
|
2011-04-05 00:35:45 -04:00
|
|
|
}
|
2011-04-05 01:28:06 -04:00
|
|
|
return (backup > -1) ? backup : NoteRowToBeat(iRow);
|
2011-04-05 00:35:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetNextLabelSegmentBeatAtRow( int iRow ) const
|
|
|
|
|
{
|
|
|
|
|
for (unsigned i = 0; i < m_LabelSegments.size(); i++ )
|
|
|
|
|
{
|
2011-05-31 11:22:21 -04:00
|
|
|
if( m_LabelSegments[i].GetRow() <= iRow )
|
2011-04-05 00:35:45 -04:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2011-05-31 11:22:21 -04:00
|
|
|
return m_LabelSegments[i].GetBeat();
|
2011-04-05 00:35:45 -04:00
|
|
|
}
|
|
|
|
|
return NoteRowToBeat(iRow);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-05 14:18:29 -04:00
|
|
|
bool TimingData::DoesLabelExist( RString sLabel ) const
|
|
|
|
|
{
|
|
|
|
|
FOREACH_CONST( LabelSegment, m_LabelSegments, seg )
|
|
|
|
|
{
|
2011-05-31 11:22:21 -04:00
|
|
|
if( seg->GetLabel() == sLabel )
|
2011-04-05 14:18:29 -04:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
void TimingData::GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, float &fBPSOut, bool &bFreezeOut, bool &bDelayOut, int &iWarpBeginOut, float &fWarpLengthOut ) const
|
|
|
|
|
{
|
|
|
|
|
fElapsedTime += PREFSMAN->m_fGlobalOffsetSeconds;
|
|
|
|
|
|
|
|
|
|
GetBeatAndBPSFromElapsedTimeNoOffset( fElapsedTime, fBeatOut, fBPSOut, bFreezeOut, bDelayOut, iWarpBeginOut, fWarpLengthOut );
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-25 23:19:31 +07:00
|
|
|
enum
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-03-25 23:19:31 +07:00
|
|
|
FOUND_WARP,
|
|
|
|
|
FOUND_WARP_DESTINATION,
|
|
|
|
|
FOUND_BPM_CHANGE,
|
|
|
|
|
FOUND_STOP,
|
|
|
|
|
FOUND_MARKER,
|
|
|
|
|
NOT_FOUND
|
|
|
|
|
};
|
2011-03-17 01:47:30 -04:00
|
|
|
|
2011-03-25 23:19:31 +07:00
|
|
|
void TimingData::GetBeatAndBPSFromElapsedTimeNoOffset( float fElapsedTime, float &fBeatOut, float &fBPSOut, bool &bFreezeOut, bool &bDelayOut, int &iWarpBeginOut, float &fWarpDestinationOut ) const
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
vector<BPMSegment>::const_iterator itBPMS = m_BPMSegments.begin();
|
|
|
|
|
vector<WarpSegment>::const_iterator itWS = m_WarpSegments.begin();
|
|
|
|
|
vector<StopSegment>::const_iterator itSS = m_StopSegments.begin();
|
|
|
|
|
|
|
|
|
|
bFreezeOut = false;
|
|
|
|
|
bDelayOut = false;
|
|
|
|
|
|
|
|
|
|
iWarpBeginOut = -1;
|
|
|
|
|
|
|
|
|
|
int iLastRow = 0;
|
|
|
|
|
float fLastTime = -m_fBeat0OffsetInSeconds;
|
2011-06-12 03:37:10 -04:00
|
|
|
float fBPS = GetBPMAtRow(0) / 60.0f;
|
2011-03-25 23:19:31 +07:00
|
|
|
|
|
|
|
|
float bIsWarping = false;
|
2011-06-12 03:37:10 -04:00
|
|
|
float fWarpDestination = 0;
|
2011-03-25 23:19:31 +07:00
|
|
|
|
|
|
|
|
for( ;; )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-03-25 23:19:31 +07:00
|
|
|
int iEventRow = INT_MAX;
|
|
|
|
|
int iEventType = NOT_FOUND;
|
|
|
|
|
if( bIsWarping && BeatToNoteRow(fWarpDestination) < iEventRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-03-25 23:19:31 +07:00
|
|
|
iEventRow = BeatToNoteRow(fWarpDestination);
|
|
|
|
|
iEventType = FOUND_WARP_DESTINATION;
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-05-31 23:41:39 +07:00
|
|
|
if( itBPMS != m_BPMSegments.end() && itBPMS->GetRow() < iEventRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-05-31 23:41:39 +07:00
|
|
|
iEventRow = itBPMS->GetRow();
|
2011-03-25 23:19:31 +07:00
|
|
|
iEventType = FOUND_BPM_CHANGE;
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-06-01 09:50:34 -04:00
|
|
|
if( itSS != m_StopSegments.end() && itSS->GetRow() < iEventRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-06-01 09:50:34 -04:00
|
|
|
iEventRow = itSS->GetRow();
|
2011-03-25 23:19:31 +07:00
|
|
|
iEventType = FOUND_STOP;
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-05-31 10:59:18 -04:00
|
|
|
if( itWS != m_WarpSegments.end() && itWS->GetRow() < iEventRow )
|
2011-03-26 22:07:24 +07:00
|
|
|
{
|
2011-05-31 10:59:18 -04:00
|
|
|
iEventRow = itWS->GetRow();
|
2011-03-26 22:07:24 +07:00
|
|
|
iEventType = FOUND_WARP;
|
|
|
|
|
}
|
2011-03-25 23:19:31 +07:00
|
|
|
if( iEventType == NOT_FOUND )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-03-25 23:19:31 +07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
float fTimeToNextEvent = bIsWarping ? 0 : NoteRowToBeat( iEventRow - iLastRow ) / fBPS;
|
|
|
|
|
float fNextEventTime = fLastTime + fTimeToNextEvent;
|
|
|
|
|
if ( fElapsedTime < fNextEventTime )
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
fLastTime = fNextEventTime;
|
|
|
|
|
switch( iEventType )
|
|
|
|
|
{
|
|
|
|
|
case FOUND_WARP_DESTINATION:
|
|
|
|
|
bIsWarping = false;
|
|
|
|
|
break;
|
|
|
|
|
case FOUND_BPM_CHANGE:
|
2011-05-31 23:41:39 +07:00
|
|
|
fBPS = itBPMS->GetBPS();
|
2011-03-25 23:19:31 +07:00
|
|
|
itBPMS ++;
|
|
|
|
|
break;
|
2011-03-30 21:57:54 -04:00
|
|
|
case FOUND_STOP:
|
2011-03-25 23:19:31 +07:00
|
|
|
{
|
2011-06-01 09:50:34 -04:00
|
|
|
fTimeToNextEvent = itSS->GetPause();
|
2011-03-26 11:59:48 -05:00
|
|
|
fNextEventTime = fLastTime + fTimeToNextEvent;
|
2011-06-01 09:50:34 -04:00
|
|
|
const bool bIsDelay = itSS->GetDelay();
|
2011-03-26 11:59:48 -05:00
|
|
|
if ( fElapsedTime < fNextEventTime )
|
|
|
|
|
{
|
|
|
|
|
bFreezeOut = !bIsDelay;
|
|
|
|
|
bDelayOut = bIsDelay;
|
2011-06-01 09:50:34 -04:00
|
|
|
fBeatOut = itSS->GetBeat();
|
2011-03-26 11:59:48 -05:00
|
|
|
fBPSOut = fBPS;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
fLastTime = fNextEventTime;
|
|
|
|
|
itSS ++;
|
2011-03-25 23:19:31 +07:00
|
|
|
}
|
|
|
|
|
break;
|
2011-03-26 22:07:24 +07:00
|
|
|
case FOUND_WARP:
|
|
|
|
|
{
|
2011-05-16 10:24:59 -04:00
|
|
|
bIsWarping = true;
|
2011-05-31 10:59:18 -04:00
|
|
|
float fWarpSum = itWS->GetLength() + itWS->GetBeat();
|
2011-05-16 10:24:59 -04:00
|
|
|
if( fWarpSum > fWarpDestination )
|
|
|
|
|
{
|
2011-05-16 22:05:23 +07:00
|
|
|
fWarpDestination = fWarpSum;
|
2011-05-16 10:24:59 -04:00
|
|
|
}
|
|
|
|
|
iWarpBeginOut = iEventRow;
|
|
|
|
|
fWarpDestinationOut = fWarpDestination;
|
|
|
|
|
itWS ++;
|
|
|
|
|
break;
|
2011-03-26 22:07:24 +07:00
|
|
|
}
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-03-25 23:19:31 +07:00
|
|
|
iLastRow = iEventRow;
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-03-25 23:19:31 +07:00
|
|
|
|
|
|
|
|
fBeatOut = NoteRowToBeat( iLastRow ) + (fElapsedTime - fLastTime) * fBPS;
|
|
|
|
|
fBPSOut = fBPS;
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetElapsedTimeFromBeat( float fBeat ) const
|
|
|
|
|
{
|
|
|
|
|
return TimingData::GetElapsedTimeFromBeatNoOffset( fBeat ) - PREFSMAN->m_fGlobalOffsetSeconds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float TimingData::GetElapsedTimeFromBeatNoOffset( float fBeat ) const
|
|
|
|
|
{
|
|
|
|
|
|
2011-03-25 23:19:31 +07:00
|
|
|
vector<BPMSegment>::const_iterator itBPMS = m_BPMSegments.begin();
|
|
|
|
|
vector<WarpSegment>::const_iterator itWS = m_WarpSegments.begin();
|
|
|
|
|
vector<StopSegment>::const_iterator itSS = m_StopSegments.begin();
|
|
|
|
|
|
|
|
|
|
int iLastRow = 0;
|
|
|
|
|
float fLastTime = -m_fBeat0OffsetInSeconds;
|
2011-06-12 03:37:10 -04:00
|
|
|
float fBPS = GetBPMAtRow(0) / 60.0f;
|
2011-03-25 23:19:31 +07:00
|
|
|
|
|
|
|
|
float bIsWarping = false;
|
2011-06-12 03:37:10 -04:00
|
|
|
float fWarpDestination = 0;
|
2011-03-25 23:19:31 +07:00
|
|
|
|
|
|
|
|
for( ;; )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-03-25 23:19:31 +07:00
|
|
|
int iEventRow = INT_MAX;
|
|
|
|
|
int iEventType = NOT_FOUND;
|
|
|
|
|
if( bIsWarping && BeatToNoteRow(fWarpDestination) < iEventRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
2011-03-25 23:19:31 +07:00
|
|
|
iEventRow = BeatToNoteRow(fWarpDestination);
|
|
|
|
|
iEventType = FOUND_WARP_DESTINATION;
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-05-31 23:41:39 +07:00
|
|
|
if( itBPMS != m_BPMSegments.end() && itBPMS->GetRow() < iEventRow )
|
2011-03-25 23:19:31 +07:00
|
|
|
{
|
2011-05-31 23:41:39 +07:00
|
|
|
iEventRow = itBPMS->GetRow();
|
2011-03-25 23:19:31 +07:00
|
|
|
iEventType = FOUND_BPM_CHANGE;
|
|
|
|
|
}
|
2011-06-01 09:50:34 -04:00
|
|
|
if( itSS != m_StopSegments.end() && itSS->GetDelay() && itSS->GetRow() < iEventRow ) // delays (come before marker)
|
2011-03-25 23:19:31 +07:00
|
|
|
{
|
2011-06-01 09:50:34 -04:00
|
|
|
iEventRow = itSS->GetRow();
|
2011-03-25 23:19:31 +07:00
|
|
|
iEventType = FOUND_STOP;
|
|
|
|
|
}
|
|
|
|
|
if( BeatToNoteRow(fBeat) < iEventRow )
|
|
|
|
|
{
|
|
|
|
|
iEventRow = BeatToNoteRow(fBeat);
|
|
|
|
|
iEventType = FOUND_MARKER;
|
|
|
|
|
}
|
2011-06-01 09:50:34 -04:00
|
|
|
if( itSS != m_StopSegments.end() && !itSS->GetDelay() && itSS->GetRow() < iEventRow ) // stops (come after marker)
|
2011-03-25 23:19:31 +07:00
|
|
|
{
|
2011-06-01 09:50:34 -04:00
|
|
|
iEventRow = itSS->GetRow();
|
2011-03-25 23:19:31 +07:00
|
|
|
iEventType = FOUND_STOP;
|
|
|
|
|
}
|
2011-05-31 10:59:18 -04:00
|
|
|
if( itWS != m_WarpSegments.end() && itWS->GetRow() < iEventRow )
|
2011-03-26 22:07:24 +07:00
|
|
|
{
|
2011-05-31 10:59:18 -04:00
|
|
|
iEventRow = itWS->GetRow();
|
2011-03-26 22:07:24 +07:00
|
|
|
iEventType = FOUND_WARP;
|
|
|
|
|
}
|
2011-03-25 23:19:31 +07:00
|
|
|
float fTimeToNextEvent = bIsWarping ? 0 : NoteRowToBeat( iEventRow - iLastRow ) / fBPS;
|
|
|
|
|
float fNextEventTime = fLastTime + fTimeToNextEvent;
|
|
|
|
|
fLastTime = fNextEventTime;
|
|
|
|
|
switch( iEventType )
|
|
|
|
|
{
|
|
|
|
|
case FOUND_WARP_DESTINATION:
|
|
|
|
|
bIsWarping = false;
|
|
|
|
|
break;
|
|
|
|
|
case FOUND_BPM_CHANGE:
|
2011-05-31 23:41:39 +07:00
|
|
|
fBPS = itBPMS->GetBPS();
|
2011-03-25 23:19:31 +07:00
|
|
|
itBPMS ++;
|
|
|
|
|
break;
|
|
|
|
|
case FOUND_STOP:
|
2011-06-01 09:50:34 -04:00
|
|
|
fTimeToNextEvent = itSS->GetPause();
|
2011-03-25 23:19:31 +07:00
|
|
|
fNextEventTime = fLastTime + fTimeToNextEvent;
|
|
|
|
|
fLastTime = fNextEventTime;
|
|
|
|
|
itSS ++;
|
|
|
|
|
break;
|
|
|
|
|
case FOUND_MARKER:
|
|
|
|
|
return fLastTime;
|
2011-03-26 22:07:24 +07:00
|
|
|
case FOUND_WARP:
|
|
|
|
|
{
|
2011-05-16 10:24:59 -04:00
|
|
|
bIsWarping = true;
|
2011-05-31 10:59:18 -04:00
|
|
|
float fWarpSum = itWS->GetLength() + itWS->GetBeat();
|
2011-05-16 10:24:59 -04:00
|
|
|
if( fWarpSum > fWarpDestination )
|
|
|
|
|
{
|
2011-05-16 22:05:23 +07:00
|
|
|
fWarpDestination = fWarpSum;
|
2011-05-16 10:24:59 -04:00
|
|
|
}
|
|
|
|
|
itWS ++;
|
|
|
|
|
break;
|
2011-03-26 22:07:24 +07:00
|
|
|
}
|
2011-03-25 23:19:31 +07:00
|
|
|
}
|
|
|
|
|
iLastRow = iEventRow;
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-03-25 23:19:31 +07:00
|
|
|
|
|
|
|
|
// won't reach here, unless BeatToNoteRow(fBeat == INT_MAX) (impossible)
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
2011-05-25 22:44:41 +07:00
|
|
|
float TimingData::GetDisplayedBeat( float fBeat ) const
|
|
|
|
|
{
|
2011-06-04 19:02:45 +07:00
|
|
|
vector<ScrollSegment>::const_iterator it = m_ScrollSegments.begin(), end = m_ScrollSegments.end();
|
2011-06-12 03:37:10 -04:00
|
|
|
float fOutBeat = 0;
|
2011-06-04 19:02:45 +07:00
|
|
|
for( ; it != end; it++ )
|
2011-05-25 22:44:41 +07:00
|
|
|
{
|
2011-06-04 19:18:55 +07:00
|
|
|
if( it+1 == end || fBeat <= (it+1)->GetBeat() )
|
2011-06-04 19:02:45 +07:00
|
|
|
{
|
2011-06-04 19:18:55 +07:00
|
|
|
fOutBeat += ( fBeat - (it)->GetBeat() ) * (it)->GetRatio();
|
2011-06-04 19:02:45 +07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-06-04 19:18:55 +07:00
|
|
|
fOutBeat += ( (it+1)->GetBeat() - (it)->GetBeat() ) * (it)->GetRatio();
|
2011-06-04 19:02:45 +07:00
|
|
|
}
|
2011-05-25 22:44:41 +07:00
|
|
|
}
|
|
|
|
|
return fOutBeat;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-19 18:58:44 +07:00
|
|
|
void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex, bool bAdjustBPM )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
ASSERT( fScale > 0 );
|
|
|
|
|
ASSERT( iStartIndex >= 0 );
|
|
|
|
|
ASSERT( iStartIndex < iEndIndex );
|
2011-03-19 18:58:44 +07:00
|
|
|
|
2011-06-26 13:43:30 +07:00
|
|
|
int length = iEndIndex - iStartIndex;
|
|
|
|
|
int newLength = lrintf( fScale * length );
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
for ( unsigned i = 0; i < m_BPMSegments.size(); i++ )
|
2011-06-26 13:43:30 +07:00
|
|
|
m_BPMSegments[i].Scale( iStartIndex, length, newLength );
|
2011-03-26 14:21:06 +07:00
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
for( unsigned i = 0; i < m_StopSegments.size(); i++ )
|
2011-06-26 13:43:30 +07:00
|
|
|
m_StopSegments[i].Scale( iStartIndex, length, newLength );
|
2011-03-19 18:58:44 +07:00
|
|
|
|
2011-05-26 17:38:31 -04:00
|
|
|
for( unsigned i = 0; i < m_vTimeSignatureSegments.size(); i++ )
|
2011-06-26 13:43:30 +07:00
|
|
|
m_vTimeSignatureSegments[i].Scale( iStartIndex, length, newLength );
|
2011-05-26 17:38:31 -04:00
|
|
|
|
2011-03-26 14:21:06 +07:00
|
|
|
for( unsigned i = 0; i < m_WarpSegments.size(); i++ )
|
2011-06-26 13:43:30 +07:00
|
|
|
m_WarpSegments[i].Scale( iStartIndex, length, newLength );
|
2011-03-26 14:21:06 +07:00
|
|
|
|
2011-05-01 17:28:36 -04:00
|
|
|
for ( unsigned i = 0; i < m_TickcountSegments.size(); i++ )
|
2011-06-26 13:43:30 +07:00
|
|
|
m_TickcountSegments[i].Scale( iStartIndex, length, newLength );
|
2011-05-01 17:28:36 -04:00
|
|
|
|
|
|
|
|
for ( unsigned i = 0; i < m_ComboSegments.size(); i++ )
|
2011-06-26 13:43:30 +07:00
|
|
|
m_ComboSegments[i].Scale( iStartIndex, length, newLength );
|
2011-05-01 17:28:36 -04:00
|
|
|
|
2011-05-03 12:58:08 -04:00
|
|
|
for ( unsigned i = 0; i < m_LabelSegments.size(); i++ )
|
2011-06-26 13:43:30 +07:00
|
|
|
m_LabelSegments[i].Scale( iStartIndex, length, newLength );
|
2011-05-03 12:58:08 -04:00
|
|
|
|
2011-05-15 13:48:10 -04:00
|
|
|
for ( unsigned i = 0; i < m_SpeedSegments.size(); i++ )
|
2011-06-27 14:24:55 -04:00
|
|
|
{
|
|
|
|
|
SpeedSegment &s = m_SpeedSegments[i];
|
|
|
|
|
s.Scale( iStartIndex, length, newLength );
|
|
|
|
|
if (s.GetUnit() == 0) // beats
|
|
|
|
|
s.SetLength(s.GetLength() * fScale);
|
|
|
|
|
}
|
2011-05-15 13:48:10 -04:00
|
|
|
|
2011-05-16 02:00:17 -04:00
|
|
|
for( unsigned i = 0; i < m_FakeSegments.size(); i++ )
|
2011-06-26 13:43:30 +07:00
|
|
|
m_FakeSegments[i].Scale( iStartIndex, length, newLength );
|
2011-05-16 02:00:17 -04:00
|
|
|
|
2011-05-26 17:38:31 -04:00
|
|
|
for( unsigned i = 0; i < m_ScrollSegments.size(); i++ )
|
2011-06-26 13:43:30 +07:00
|
|
|
m_ScrollSegments[i].Scale( iStartIndex, length, newLength );
|
2011-05-26 17:38:31 -04:00
|
|
|
|
2011-03-19 18:58:44 +07:00
|
|
|
// adjust BPM changes to preserve timing
|
|
|
|
|
if( bAdjustBPM )
|
|
|
|
|
{
|
2011-06-26 13:43:30 +07:00
|
|
|
int iNewEndIndex = iStartIndex + newLength;
|
2011-03-19 18:58:44 +07:00
|
|
|
float fEndBPMBeforeScaling = GetBPMAtRow(iNewEndIndex);
|
|
|
|
|
|
|
|
|
|
// adjust BPM changes "between" iStartIndex and iNewEndIndex
|
|
|
|
|
for ( unsigned i = 0; i < m_BPMSegments.size(); i++ )
|
|
|
|
|
{
|
2011-05-31 23:41:39 +07:00
|
|
|
const int iSegStart = m_BPMSegments[i].GetRow();
|
2011-03-19 18:58:44 +07:00
|
|
|
if( iSegStart <= iStartIndex )
|
|
|
|
|
continue;
|
|
|
|
|
else if( iSegStart >= iNewEndIndex )
|
|
|
|
|
continue;
|
|
|
|
|
else
|
2011-05-31 23:41:39 +07:00
|
|
|
m_BPMSegments[i].SetBPM( m_BPMSegments[i].GetBPM() * fScale );
|
2011-03-19 18:58:44 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// set BPM at iStartIndex and iNewEndIndex.
|
|
|
|
|
SetBPMAtRow( iStartIndex, GetBPMAtRow(iStartIndex) * fScale );
|
|
|
|
|
SetBPMAtRow( iNewEndIndex, fEndBPMBeforeScaling );
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TimingData::InsertRows( int iStartRow, int iRowsToAdd )
|
|
|
|
|
{
|
|
|
|
|
for( unsigned i = 0; i < m_BPMSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
BPMSegment &bpm = m_BPMSegments[i];
|
2011-05-31 23:41:39 +07:00
|
|
|
if( bpm.GetRow() < iStartRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
continue;
|
2011-05-31 23:41:39 +07:00
|
|
|
bpm.SetRow( bpm.GetRow() + iRowsToAdd );
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < m_StopSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
StopSegment &stop = m_StopSegments[i];
|
2011-06-01 09:50:34 -04:00
|
|
|
if( stop.GetRow() < iStartRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
continue;
|
2011-06-01 09:50:34 -04:00
|
|
|
stop.SetRow(stop.GetRow() + iRowsToAdd);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
2011-03-24 20:21:43 -04:00
|
|
|
for( unsigned i = 0; i < m_WarpSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
WarpSegment &warp = m_WarpSegments[i];
|
2011-05-31 10:59:18 -04:00
|
|
|
if( warp.GetRow() < iStartRow )
|
2011-03-24 20:21:43 -04:00
|
|
|
continue;
|
2011-05-31 10:59:18 -04:00
|
|
|
warp.SetRow(warp.GetRow() + iRowsToAdd);
|
2011-03-24 20:21:43 -04:00
|
|
|
}
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
for( unsigned i = 0; i < m_vTimeSignatureSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
TimeSignatureSegment &time = m_vTimeSignatureSegments[i];
|
2011-05-31 14:27:55 -04:00
|
|
|
if( time.GetRow() < iStartRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
continue;
|
2011-05-31 14:27:55 -04:00
|
|
|
time.SetRow(time.GetRow() + iRowsToAdd);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < m_TickcountSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
TickcountSegment &tick = m_TickcountSegments[i];
|
2011-05-31 01:20:22 -04:00
|
|
|
if( tick.GetRow() < iStartRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
continue;
|
2011-05-31 01:20:22 -04:00
|
|
|
tick.SetRow(tick.GetRow() + iRowsToAdd);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < m_ComboSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
ComboSegment &comb = m_ComboSegments[i];
|
2011-05-31 11:45:25 -04:00
|
|
|
if( comb.GetRow() < iStartRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
continue;
|
2011-05-31 11:45:25 -04:00
|
|
|
comb.SetRow(comb.GetRow() + iRowsToAdd);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-04-04 23:03:10 -04:00
|
|
|
for( unsigned i = 0; i < m_LabelSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
LabelSegment &labl = m_LabelSegments[i];
|
2011-05-31 11:22:21 -04:00
|
|
|
if( labl.GetRow() < iStartRow )
|
2011-04-04 23:03:10 -04:00
|
|
|
continue;
|
2011-05-31 11:22:21 -04:00
|
|
|
labl.SetRow(labl.GetRow() + iRowsToAdd);
|
2011-04-04 23:03:10 -04:00
|
|
|
}
|
2011-05-15 13:48:10 -04:00
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < m_SpeedSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
SpeedSegment &sped = m_SpeedSegments[i];
|
2011-05-31 15:27:27 -04:00
|
|
|
if( sped.GetRow() < iStartRow )
|
2011-05-15 13:48:10 -04:00
|
|
|
continue;
|
2011-05-31 15:27:27 -04:00
|
|
|
sped.SetRow(sped.GetRow() + iRowsToAdd);
|
2011-05-15 13:48:10 -04:00
|
|
|
}
|
2011-05-16 02:00:17 -04:00
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < m_FakeSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
FakeSegment &fake = m_FakeSegments[i];
|
2011-05-31 00:51:25 -04:00
|
|
|
if( fake.GetRow() < iStartRow )
|
2011-05-16 02:00:17 -04:00
|
|
|
continue;
|
2011-05-31 00:51:25 -04:00
|
|
|
fake.SetRow(fake.GetRow() + iRowsToAdd);
|
2011-05-16 02:00:17 -04:00
|
|
|
}
|
2011-05-26 17:38:31 -04:00
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < m_ScrollSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
ScrollSegment &scrl = m_ScrollSegments[i];
|
2011-06-01 08:44:09 -04:00
|
|
|
if( scrl.GetRow() < iStartRow )
|
2011-05-26 17:38:31 -04:00
|
|
|
continue;
|
2011-06-01 08:44:09 -04:00
|
|
|
scrl.SetRow(scrl.GetRow() + iRowsToAdd);
|
2011-05-26 17:38:31 -04:00
|
|
|
}
|
2011-03-17 01:47:30 -04:00
|
|
|
|
|
|
|
|
if( iStartRow == 0 )
|
|
|
|
|
{
|
|
|
|
|
/* If we're shifting up at the beginning, we just shifted up the first
|
|
|
|
|
* BPMSegment. That segment must always begin at 0. */
|
|
|
|
|
ASSERT( m_BPMSegments.size() > 0 );
|
2011-05-31 23:41:39 +07:00
|
|
|
m_BPMSegments[0].SetRow(0);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete BPMChanges and StopSegments in [iStartRow,iRowsToDelete), and shift down.
|
|
|
|
|
void TimingData::DeleteRows( int iStartRow, int iRowsToDelete )
|
|
|
|
|
{
|
|
|
|
|
/* Remember the BPM at the end of the region being deleted. */
|
|
|
|
|
float fNewBPM = this->GetBPMAtBeat( NoteRowToBeat(iStartRow+iRowsToDelete) );
|
|
|
|
|
|
|
|
|
|
/* We're moving rows up. Delete any BPM changes and stops in the region
|
|
|
|
|
* being deleted. */
|
|
|
|
|
for( unsigned i = 0; i < m_BPMSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
BPMSegment &bpm = m_BPMSegments[i];
|
|
|
|
|
|
|
|
|
|
// Before deleted region:
|
2011-05-31 23:41:39 +07:00
|
|
|
if( bpm.GetRow() < iStartRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// Inside deleted region:
|
2011-05-31 23:41:39 +07:00
|
|
|
if( bpm.GetRow() < iStartRow+iRowsToDelete )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
m_BPMSegments.erase( m_BPMSegments.begin()+i, m_BPMSegments.begin()+i+1 );
|
|
|
|
|
--i;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// After deleted region:
|
2011-05-31 23:41:39 +07:00
|
|
|
bpm.SetRow( bpm.GetRow() - iRowsToDelete );
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < m_StopSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
StopSegment &stop = m_StopSegments[i];
|
2011-06-01 09:50:34 -04:00
|
|
|
int keyRow = stop.GetRow();
|
2011-03-17 01:47:30 -04:00
|
|
|
// Before deleted region:
|
2011-06-01 09:50:34 -04:00
|
|
|
if( keyRow < iStartRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// Inside deleted region:
|
2011-06-01 09:50:34 -04:00
|
|
|
if( keyRow < iStartRow+iRowsToDelete )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
m_StopSegments.erase( m_StopSegments.begin()+i, m_StopSegments.begin()+i+1 );
|
|
|
|
|
--i;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// After deleted region:
|
2011-06-01 09:50:34 -04:00
|
|
|
stop.SetRow(keyRow - iRowsToDelete);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
2011-03-24 20:21:43 -04:00
|
|
|
for( unsigned i = 0; i < m_WarpSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
WarpSegment &warp = m_WarpSegments[i];
|
2011-05-31 10:59:18 -04:00
|
|
|
int keyRow = warp.GetRow();
|
|
|
|
|
if( keyRow < iStartRow )
|
2011-03-24 20:21:43 -04:00
|
|
|
continue;
|
|
|
|
|
|
2011-05-31 10:59:18 -04:00
|
|
|
if( keyRow < iStartRow+iRowsToDelete )
|
2011-03-24 20:21:43 -04:00
|
|
|
{
|
|
|
|
|
m_WarpSegments.erase( m_WarpSegments.begin()+i, m_WarpSegments.begin()+i+1 );
|
|
|
|
|
--i;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-31 10:59:18 -04:00
|
|
|
warp.SetRow(keyRow - iRowsToDelete);
|
2011-03-24 20:21:43 -04:00
|
|
|
}
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
for( unsigned i = 0; i < m_vTimeSignatureSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
TimeSignatureSegment &time = m_vTimeSignatureSegments[i];
|
2011-05-31 14:27:55 -04:00
|
|
|
int keyRow = time.GetRow();
|
2011-03-17 01:47:30 -04:00
|
|
|
// Before deleted region:
|
2011-05-31 14:27:55 -04:00
|
|
|
if( keyRow < iStartRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// Inside deleted region:
|
2011-05-31 14:27:55 -04:00
|
|
|
if( keyRow < iStartRow+iRowsToDelete )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
m_vTimeSignatureSegments.erase(
|
|
|
|
|
m_vTimeSignatureSegments.begin()+i,
|
|
|
|
|
m_vTimeSignatureSegments.begin()+i+1 );
|
|
|
|
|
--i;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// After deleted region:
|
|
|
|
|
|
|
|
|
|
|
2011-05-31 14:27:55 -04:00
|
|
|
time.SetRow(keyRow - iRowsToDelete);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < m_TickcountSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
TickcountSegment &tick = m_TickcountSegments[i];
|
2011-05-31 01:20:22 -04:00
|
|
|
int keyRow = tick.GetRow();
|
2011-03-17 01:47:30 -04:00
|
|
|
// Before deleted region:
|
2011-05-31 01:20:22 -04:00
|
|
|
if( keyRow < iStartRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// Inside deleted region:
|
2011-05-31 01:20:22 -04:00
|
|
|
if( keyRow < iStartRow+iRowsToDelete )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
m_TickcountSegments.erase( m_TickcountSegments.begin()+i, m_TickcountSegments.begin()+i+1 );
|
|
|
|
|
--i;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// After deleted region:
|
2011-05-31 01:20:22 -04:00
|
|
|
tick.SetRow(keyRow - iRowsToDelete);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < m_ComboSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
ComboSegment &comb = m_ComboSegments[i];
|
2011-05-31 11:45:25 -04:00
|
|
|
int keyRow = comb.GetRow();
|
2011-03-17 01:47:30 -04:00
|
|
|
// Before deleted region:
|
2011-05-31 11:45:25 -04:00
|
|
|
if( keyRow < iStartRow )
|
2011-03-17 01:47:30 -04:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// Inside deleted region:
|
2011-05-31 11:45:25 -04:00
|
|
|
if( keyRow < iStartRow+iRowsToDelete )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
m_ComboSegments.erase( m_ComboSegments.begin()+i, m_ComboSegments.begin()+i+1 );
|
|
|
|
|
--i;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// After deleted region:
|
2011-05-31 11:45:25 -04:00
|
|
|
comb.SetRow(keyRow - iRowsToDelete);
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
2011-04-04 23:03:10 -04:00
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < m_LabelSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
LabelSegment &labl = m_LabelSegments[i];
|
2011-05-31 11:22:21 -04:00
|
|
|
int keyRow = labl.GetRow();
|
|
|
|
|
if( keyRow < iStartRow )
|
2011-04-04 23:03:10 -04:00
|
|
|
continue;
|
|
|
|
|
|
2011-05-31 11:22:21 -04:00
|
|
|
if( keyRow < iStartRow+iRowsToDelete )
|
2011-04-04 23:03:10 -04:00
|
|
|
{
|
|
|
|
|
m_LabelSegments.erase( m_LabelSegments.begin()+i, m_LabelSegments.begin()+i+1 );
|
|
|
|
|
--i;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2011-05-31 11:22:21 -04:00
|
|
|
labl.SetRow(keyRow - iRowsToDelete);
|
2011-04-04 23:03:10 -04:00
|
|
|
}
|
2011-05-15 13:48:10 -04:00
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < m_SpeedSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
SpeedSegment &sped = m_SpeedSegments[i];
|
2011-05-31 15:27:27 -04:00
|
|
|
int keyRow = sped.GetRow();
|
|
|
|
|
if( keyRow < iStartRow )
|
2011-05-15 13:48:10 -04:00
|
|
|
continue;
|
|
|
|
|
|
2011-05-31 15:27:27 -04:00
|
|
|
if( keyRow < iStartRow+iRowsToDelete )
|
2011-05-15 13:48:10 -04:00
|
|
|
{
|
|
|
|
|
m_SpeedSegments.erase( m_SpeedSegments.begin()+i, m_SpeedSegments.begin()+i+1 );
|
|
|
|
|
--i;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2011-05-31 15:27:27 -04:00
|
|
|
sped.SetRow(keyRow - iRowsToDelete);
|
2011-05-15 13:48:10 -04:00
|
|
|
}
|
2011-05-16 02:00:17 -04:00
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < m_FakeSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
FakeSegment &fake = m_FakeSegments[i];
|
2011-05-31 00:51:25 -04:00
|
|
|
int keyRow = fake.GetRow();
|
|
|
|
|
if( keyRow < iStartRow )
|
2011-05-16 02:00:17 -04:00
|
|
|
continue;
|
|
|
|
|
|
2011-05-31 00:51:25 -04:00
|
|
|
if( keyRow < iStartRow+iRowsToDelete )
|
2011-05-16 02:00:17 -04:00
|
|
|
{
|
|
|
|
|
m_FakeSegments.erase( m_FakeSegments.begin()+i, m_FakeSegments.begin()+i+1 );
|
|
|
|
|
--i;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-31 00:51:25 -04:00
|
|
|
fake.SetRow(keyRow - iRowsToDelete);
|
2011-05-16 02:00:17 -04:00
|
|
|
}
|
2011-05-26 17:38:31 -04:00
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < m_ScrollSegments.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
ScrollSegment &scrl = m_ScrollSegments[i];
|
2011-06-01 08:44:09 -04:00
|
|
|
int keyRow = scrl.GetRow();
|
|
|
|
|
if( keyRow < iStartRow )
|
2011-05-26 17:38:31 -04:00
|
|
|
continue;
|
|
|
|
|
|
2011-06-01 08:44:09 -04:00
|
|
|
if( keyRow < iStartRow+iRowsToDelete )
|
2011-05-26 17:38:31 -04:00
|
|
|
{
|
|
|
|
|
m_ScrollSegments.erase( m_ScrollSegments.begin()+i, m_ScrollSegments.begin()+i+1 );
|
|
|
|
|
--i;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2011-06-01 08:44:09 -04:00
|
|
|
scrl.SetRow(keyRow - iRowsToDelete);
|
2011-05-26 17:38:31 -04:00
|
|
|
}
|
2011-03-17 01:47:30 -04:00
|
|
|
|
|
|
|
|
this->SetBPMAtRow( iStartRow, fNewBPM );
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-24 12:29:55 +07:00
|
|
|
float TimingData::GetDisplayedSpeedPercent( float fSongBeat, float fMusicSeconds ) const
|
2011-05-24 11:43:08 +07:00
|
|
|
{
|
2011-06-01 14:32:59 -04:00
|
|
|
/* HACK: Somehow we get called into this function when there is no
|
|
|
|
|
* TimingData to work with. This seems to happen the most upon
|
|
|
|
|
* leaving the editor. Still, cover our butts in case this instance
|
|
|
|
|
* isn't existing. */
|
|
|
|
|
if (!this) return 1.0f;
|
2011-05-24 11:43:08 +07:00
|
|
|
if( m_SpeedSegments.size() == 0 )
|
2011-06-01 14:32:59 -04:00
|
|
|
return 1.0f;
|
2011-05-24 11:43:08 +07:00
|
|
|
|
|
|
|
|
const int index = GetSpeedSegmentIndexAtBeat( fSongBeat );
|
|
|
|
|
|
|
|
|
|
const SpeedSegment &seg = m_SpeedSegments[index];
|
2011-05-31 15:27:27 -04:00
|
|
|
float fStartBeat = seg.GetBeat();
|
2011-05-24 11:43:08 +07:00
|
|
|
float fStartTime = GetElapsedTimeFromBeat( fStartBeat ) - GetDelayAtBeat( fStartBeat );
|
|
|
|
|
float fEndTime;
|
|
|
|
|
float fCurTime = fMusicSeconds;
|
|
|
|
|
|
2011-05-31 15:27:27 -04:00
|
|
|
if( seg.GetUnit() == 1 ) // seconds
|
2011-05-24 11:43:08 +07:00
|
|
|
{
|
2011-05-31 15:27:27 -04:00
|
|
|
fEndTime = fStartTime + seg.GetLength();
|
2011-05-24 11:43:08 +07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-05-31 15:27:27 -04:00
|
|
|
fEndTime = GetElapsedTimeFromBeat( fStartBeat + seg.GetLength() )
|
|
|
|
|
- GetDelayAtBeat( fStartBeat + seg.GetLength() );
|
2011-05-24 11:43:08 +07:00
|
|
|
}
|
|
|
|
|
|
2011-05-31 15:27:27 -04:00
|
|
|
if( ( index == 0 && m_SpeedSegments[0].GetLength() > 0.0 ) && fCurTime < fStartTime )
|
2011-05-24 11:43:08 +07:00
|
|
|
{
|
2011-06-12 03:37:10 -04:00
|
|
|
return 1.0f;
|
2011-05-24 11:43:08 +07:00
|
|
|
}
|
2011-05-31 15:27:27 -04:00
|
|
|
else if( fEndTime >= fCurTime && ( index > 0 || m_SpeedSegments[0].GetLength() > 0.0 ) )
|
2011-05-24 11:43:08 +07:00
|
|
|
{
|
2011-05-31 15:27:27 -04:00
|
|
|
const float fPriorSpeed = ( index == 0 ? 1 : m_SpeedSegments[index - 1].GetRatio() );
|
2011-05-24 11:43:08 +07:00
|
|
|
float fTimeUsed = fCurTime - fStartTime;
|
|
|
|
|
float fDuration = fEndTime - fStartTime;
|
|
|
|
|
float fRatioUsed = fDuration == 0.0 ? 1 : fTimeUsed / fDuration;
|
|
|
|
|
|
2011-05-31 15:27:27 -04:00
|
|
|
float fDistance = fPriorSpeed - seg.GetRatio();
|
2011-05-24 11:43:08 +07:00
|
|
|
float fRatioNeed = fRatioUsed * -fDistance;
|
|
|
|
|
return (fPriorSpeed + fRatioNeed);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-05-31 15:27:27 -04:00
|
|
|
return seg.GetRatio();
|
2011-05-24 11:43:08 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-10 16:00:47 +07:00
|
|
|
void TimingData::TidyUpData()
|
|
|
|
|
{
|
|
|
|
|
// If there are no BPM segments, provide a default.
|
|
|
|
|
if( m_BPMSegments.empty() )
|
|
|
|
|
{
|
|
|
|
|
LOG->UserLog( "Song file", m_sFile, "has no BPM segments, default provided." );
|
|
|
|
|
|
|
|
|
|
AddBPMSegment( BPMSegment(0, 60) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make sure the first BPM segment starts at beat 0.
|
2011-05-31 23:41:39 +07:00
|
|
|
if( m_BPMSegments[0].GetRow() != 0 )
|
|
|
|
|
m_BPMSegments[0].SetRow(0);
|
2011-05-10 16:00:47 +07:00
|
|
|
|
|
|
|
|
// If no time signature specified, assume 4/4 time for the whole song.
|
|
|
|
|
if( m_vTimeSignatureSegments.empty() )
|
|
|
|
|
{
|
|
|
|
|
TimeSignatureSegment seg(0, 4, 4);
|
|
|
|
|
m_vTimeSignatureSegments.push_back( seg );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Likewise, if no tickcount signature is specified, assume 2 ticks
|
|
|
|
|
//per beat for the entire song. The default of 2 is chosen more
|
|
|
|
|
//for compatibility with the Pump Pro series than anything else.
|
|
|
|
|
if( m_TickcountSegments.empty() )
|
|
|
|
|
{
|
|
|
|
|
TickcountSegment seg(0, 2);
|
|
|
|
|
m_TickcountSegments.push_back( seg );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Have a default combo segment of one just in case.
|
|
|
|
|
if( m_ComboSegments.empty() )
|
|
|
|
|
{
|
|
|
|
|
ComboSegment seg(0, 1);
|
|
|
|
|
m_ComboSegments.push_back( seg );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Have a default label segment just in case.
|
|
|
|
|
if( m_LabelSegments.empty() )
|
|
|
|
|
{
|
|
|
|
|
LabelSegment seg(0, "Song Start");
|
|
|
|
|
m_LabelSegments.push_back( seg );
|
|
|
|
|
}
|
2011-05-15 13:48:10 -04:00
|
|
|
|
|
|
|
|
// Always be sure there is a starting speed.
|
|
|
|
|
if( m_SpeedSegments.empty() )
|
|
|
|
|
{
|
|
|
|
|
SpeedSegment seg(0, 1, 0);
|
|
|
|
|
m_SpeedSegments.push_back( seg );
|
|
|
|
|
}
|
2011-05-25 22:44:41 +07:00
|
|
|
|
|
|
|
|
// Always be sure there is a starting scrolling factor.
|
|
|
|
|
if( m_ScrollSegments.empty() )
|
|
|
|
|
{
|
|
|
|
|
ScrollSegment seg(0, 1);
|
|
|
|
|
m_ScrollSegments.push_back( seg );
|
|
|
|
|
}
|
2011-05-10 16:00:47 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
bool TimingData::HasBpmChanges() const
|
|
|
|
|
{
|
|
|
|
|
return m_BPMSegments.size()>1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TimingData::HasStops() const
|
|
|
|
|
{
|
|
|
|
|
return m_StopSegments.size()>0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TimingData::HasWarps() const
|
|
|
|
|
{
|
|
|
|
|
return m_WarpSegments.size()>0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-16 02:00:17 -04:00
|
|
|
bool TimingData::HasFakes() const
|
|
|
|
|
{
|
|
|
|
|
return m_FakeSegments.size()>0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-15 13:48:10 -04:00
|
|
|
bool TimingData::HasSpeedChanges() const
|
|
|
|
|
{
|
2011-06-01 10:08:40 -04:00
|
|
|
return m_SpeedSegments.size()>1 || m_SpeedSegments[0].GetRatio() != 1;
|
2011-05-15 13:48:10 -04:00
|
|
|
}
|
|
|
|
|
|
2011-05-25 22:44:41 +07:00
|
|
|
bool TimingData::HasScrollChanges() const
|
|
|
|
|
{
|
2011-06-01 10:08:40 -04:00
|
|
|
return m_ScrollSegments.size()>1 || m_ScrollSegments[0].GetRatio() != 1;
|
2011-05-25 22:44:41 +07:00
|
|
|
}
|
|
|
|
|
|
2011-03-17 01:47:30 -04:00
|
|
|
void TimingData::NoteRowToMeasureAndBeat( int iNoteRow, int &iMeasureIndexOut, int &iBeatIndexOut, int &iRowsRemainder ) const
|
|
|
|
|
{
|
|
|
|
|
iMeasureIndexOut = 0;
|
|
|
|
|
|
|
|
|
|
FOREACH_CONST( TimeSignatureSegment, m_vTimeSignatureSegments, iter )
|
|
|
|
|
{
|
|
|
|
|
vector<TimeSignatureSegment>::const_iterator next = iter;
|
|
|
|
|
next++;
|
2011-05-31 14:27:55 -04:00
|
|
|
int iSegmentEndRow = (next == m_vTimeSignatureSegments.end()) ? INT_MAX : next->GetRow();
|
2011-03-17 01:47:30 -04:00
|
|
|
|
|
|
|
|
int iRowsPerMeasureThisSegment = iter->GetNoteRowsPerMeasure();
|
|
|
|
|
|
2011-05-31 14:27:55 -04:00
|
|
|
if( iNoteRow >= iter->GetRow() )
|
2011-03-17 01:47:30 -04:00
|
|
|
{
|
|
|
|
|
// iNoteRow lands in this segment
|
2011-05-31 14:27:55 -04:00
|
|
|
int iNumRowsThisSegment = iNoteRow - iter->GetRow();
|
2011-03-17 01:47:30 -04:00
|
|
|
int iNumMeasuresThisSegment = (iNumRowsThisSegment) / iRowsPerMeasureThisSegment; // don't round up
|
|
|
|
|
iMeasureIndexOut += iNumMeasuresThisSegment;
|
|
|
|
|
iBeatIndexOut = iNumRowsThisSegment / iRowsPerMeasureThisSegment;
|
|
|
|
|
iRowsRemainder = iNumRowsThisSegment % iRowsPerMeasureThisSegment;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// iNoteRow lands after this segment
|
2011-05-31 14:27:55 -04:00
|
|
|
int iNumRowsThisSegment = iSegmentEndRow - iter->GetRow();
|
2011-03-17 01:47:30 -04:00
|
|
|
int iNumMeasuresThisSegment = (iNumRowsThisSegment + iRowsPerMeasureThisSegment - 1) / iRowsPerMeasureThisSegment; // round up
|
|
|
|
|
iMeasureIndexOut += iNumMeasuresThisSegment;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ASSERT(0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// lua start
|
|
|
|
|
#include "LuaBinding.h"
|
|
|
|
|
|
|
|
|
|
/** @brief Allow Lua to have access to the TimingData. */
|
|
|
|
|
class LunaTimingData: public Luna<TimingData>
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
static int HasStops( T* p, lua_State *L ) { lua_pushboolean(L, p->HasStops()); return 1; }
|
|
|
|
|
static int HasBPMChanges( T* p, lua_State *L ) { lua_pushboolean(L, p->HasBpmChanges()); return 1; }
|
2011-03-24 20:21:43 -04:00
|
|
|
static int HasWarps( T* p, lua_State *L ) { lua_pushboolean(L, p->HasWarps()); return 1; }
|
2011-05-16 02:00:17 -04:00
|
|
|
static int HasFakes( T* p, lua_State *L ) { lua_pushboolean(L, p->HasFakes()); return 1; }
|
2011-05-15 13:48:10 -04:00
|
|
|
static int HasSpeedChanges( T* p, lua_State *L ) { lua_pushboolean(L, p->HasSpeedChanges()); return 1; }
|
2011-06-01 10:12:10 -04:00
|
|
|
static int HasScrollChanges( T* p, lua_State *L ) { lua_pushboolean(L, p->HasScrollChanges()); return 1; }
|
2011-06-15 16:56:01 -04:00
|
|
|
static int GetWarps( T* p, lua_State *L )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> vWarps;
|
|
|
|
|
FOREACH_CONST( WarpSegment, p->m_WarpSegments, seg )
|
|
|
|
|
{
|
|
|
|
|
const float length = seg->GetLength();
|
|
|
|
|
const float beat = seg->GetBeat();
|
|
|
|
|
vWarps.push_back( ssprintf("%f=%f", beat, length) );
|
|
|
|
|
}
|
|
|
|
|
LuaHelpers::CreateTableFromArray(vWarps, L);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
static int GetFakes( T* p, lua_State *L )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> vFakes;
|
|
|
|
|
FOREACH_CONST( FakeSegment, p->m_FakeSegments, seg )
|
|
|
|
|
{
|
|
|
|
|
const float length = seg->GetLength();
|
|
|
|
|
const float beat = seg->GetBeat();
|
|
|
|
|
vFakes.push_back( ssprintf("%f=%f", beat, length) );
|
|
|
|
|
}
|
|
|
|
|
LuaHelpers::CreateTableFromArray(vFakes, L);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
static int GetScrolls( T* p, lua_State *L )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> vScrolls;
|
|
|
|
|
FOREACH_CONST( ScrollSegment, p->m_ScrollSegments, seg )
|
|
|
|
|
{
|
|
|
|
|
const float ratio = seg->GetRatio();
|
|
|
|
|
const float beat = seg->GetBeat();
|
|
|
|
|
vScrolls.push_back( ssprintf("%f=%f", beat, ratio) );
|
|
|
|
|
}
|
|
|
|
|
LuaHelpers::CreateTableFromArray(vScrolls, L);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
static int GetSpeeds( T* p, lua_State *L )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> vSpeeds;
|
|
|
|
|
FOREACH_CONST( SpeedSegment, p->m_SpeedSegments, seg )
|
|
|
|
|
{
|
|
|
|
|
const float length = seg->GetLength();
|
|
|
|
|
const float ratio = seg->GetRatio();
|
|
|
|
|
const unsigned short unit = seg->GetUnit();
|
|
|
|
|
const float beat = seg->GetBeat();
|
|
|
|
|
vSpeeds.push_back( ssprintf("%f=%f=%f=%uh", beat, ratio, length, unit) );
|
|
|
|
|
}
|
|
|
|
|
LuaHelpers::CreateTableFromArray(vSpeeds, L);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
static int GetTimeSignatures( T* p, lua_State *L )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> vTimes;
|
|
|
|
|
FOREACH_CONST( TimeSignatureSegment, p->m_vTimeSignatureSegments, seg )
|
|
|
|
|
{
|
|
|
|
|
const int numerator = seg->GetNum();
|
|
|
|
|
const int denominator = seg->GetDen();
|
|
|
|
|
const float beat = seg->GetBeat();
|
|
|
|
|
vTimes.push_back( ssprintf("%f=%d=%d", beat, numerator, denominator) );
|
|
|
|
|
}
|
|
|
|
|
LuaHelpers::CreateTableFromArray(vTimes, L);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
static int GetCombos( T* p, lua_State *L )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> vCombos;
|
|
|
|
|
FOREACH_CONST( ComboSegment, p->m_ComboSegments, seg )
|
|
|
|
|
{
|
|
|
|
|
const int combo = seg->GetCombo();
|
|
|
|
|
const float beat = seg->GetBeat();
|
|
|
|
|
vCombos.push_back( ssprintf("%f=%d", beat, combo) );
|
|
|
|
|
}
|
|
|
|
|
LuaHelpers::CreateTableFromArray(vCombos, L);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
static int GetTickcounts( T* p, lua_State *L )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> vTicks;
|
|
|
|
|
FOREACH_CONST( TickcountSegment, p->m_TickcountSegments, seg )
|
|
|
|
|
{
|
|
|
|
|
const int ticks = seg->GetTicks();
|
|
|
|
|
const float beat = seg->GetBeat();
|
|
|
|
|
vTicks.push_back( ssprintf("%f=%d", beat, ticks) );
|
|
|
|
|
}
|
|
|
|
|
LuaHelpers::CreateTableFromArray(vTicks, L);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2011-03-17 01:47:30 -04:00
|
|
|
static int GetStops( T* p, lua_State *L )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> vStops;
|
|
|
|
|
FOREACH_CONST( StopSegment, p->m_StopSegments, seg )
|
|
|
|
|
{
|
2011-06-01 09:50:34 -04:00
|
|
|
const float fStartBeat = seg->GetBeat();
|
|
|
|
|
const float fStopLength = seg->GetPause();
|
|
|
|
|
if(!seg->GetDelay())
|
|
|
|
|
vStops.push_back( ssprintf("%f=%f", fStartBeat, fStopLength) );
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LuaHelpers::CreateTableFromArray(vStops, L);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
static int GetDelays( T* p, lua_State *L )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> vDelays;
|
|
|
|
|
FOREACH_CONST( StopSegment, p->m_StopSegments, seg )
|
|
|
|
|
{
|
2011-06-01 09:50:34 -04:00
|
|
|
const float fStartBeat = seg->GetBeat();
|
|
|
|
|
const float fStopLength = seg->GetPause();
|
|
|
|
|
if(seg->GetDelay())
|
|
|
|
|
vDelays.push_back( ssprintf("%f=%f", fStartBeat, fStopLength) );
|
2011-03-17 01:47:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LuaHelpers::CreateTableFromArray(vDelays, L);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
static int GetBPMs( T* p, lua_State *L )
|
|
|
|
|
{
|
|
|
|
|
vector<float> vBPMs;
|
|
|
|
|
FOREACH_CONST( BPMSegment, p->m_BPMSegments, seg )
|
|
|
|
|
{
|
|
|
|
|
const float fBPM = seg->GetBPM();
|
|
|
|
|
vBPMs.push_back( fBPM );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LuaHelpers::CreateTableFromArray(vBPMs, L);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2011-04-04 23:03:10 -04:00
|
|
|
static int GetLabels( T* p, lua_State *L )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> vLabels;
|
|
|
|
|
FOREACH_CONST( LabelSegment, p->m_LabelSegments, seg )
|
|
|
|
|
{
|
2011-05-31 11:22:21 -04:00
|
|
|
const float fStartRow = seg->GetBeat();
|
|
|
|
|
const RString sLabel = seg->GetLabel();
|
2011-04-04 23:03:10 -04:00
|
|
|
vLabels.push_back( ssprintf("%f=%s", fStartRow, sLabel.c_str()) );
|
|
|
|
|
}
|
|
|
|
|
LuaHelpers::CreateTableFromArray(vLabels, L);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2011-03-17 01:47:30 -04:00
|
|
|
static int GetBPMsAndTimes( T* p, lua_State *L )
|
|
|
|
|
{
|
|
|
|
|
vector<RString> vBPMs;
|
|
|
|
|
FOREACH_CONST( BPMSegment, p->m_BPMSegments, seg )
|
|
|
|
|
{
|
2011-05-31 23:41:39 +07:00
|
|
|
const float fStartRow = seg->GetBeat();
|
2011-03-17 01:47:30 -04:00
|
|
|
const float fBPM = seg->GetBPM();
|
|
|
|
|
vBPMs.push_back( ssprintf("%f=%f", fStartRow, fBPM) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LuaHelpers::CreateTableFromArray(vBPMs, L);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
static int GetActualBPM( T* p, lua_State *L )
|
|
|
|
|
{
|
|
|
|
|
// certainly there's a better way to do it than this? -aj
|
|
|
|
|
float fMinBPM, fMaxBPM;
|
|
|
|
|
p->GetActualBPM( fMinBPM, fMaxBPM );
|
|
|
|
|
vector<float> fBPMs;
|
|
|
|
|
fBPMs.push_back( fMinBPM );
|
|
|
|
|
fBPMs.push_back( fMaxBPM );
|
|
|
|
|
LuaHelpers::CreateTableFromArray(fBPMs, L);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2011-06-09 18:16:23 -04:00
|
|
|
static int HasNegativeBPMs( T* p, lua_State *L ) { lua_pushboolean(L, p->HasWarps()); return 1; }
|
2011-03-17 01:47:30 -04:00
|
|
|
// formerly in Song.cpp in sm-ssc private beta 1.x:
|
|
|
|
|
static int GetBPMAtBeat( T* p, lua_State *L ) { lua_pushnumber(L, p->GetBPMAtBeat(FArg(1))); return 1; }
|
|
|
|
|
static int GetBeatFromElapsedTime( T* p, lua_State *L ) { lua_pushnumber(L, p->GetBeatFromElapsedTime(FArg(1))); return 1; }
|
|
|
|
|
static int GetElapsedTimeFromBeat( T* p, lua_State *L ) { lua_pushnumber(L, p->GetElapsedTimeFromBeat(FArg(1))); return 1; }
|
|
|
|
|
|
|
|
|
|
LunaTimingData()
|
|
|
|
|
{
|
|
|
|
|
ADD_METHOD( HasStops );
|
|
|
|
|
ADD_METHOD( HasBPMChanges );
|
2011-03-24 20:21:43 -04:00
|
|
|
ADD_METHOD( HasWarps );
|
2011-05-16 02:00:17 -04:00
|
|
|
ADD_METHOD( HasFakes );
|
2011-05-15 13:48:10 -04:00
|
|
|
ADD_METHOD( HasSpeedChanges );
|
2011-06-01 10:12:10 -04:00
|
|
|
ADD_METHOD( HasScrollChanges );
|
2011-03-17 01:47:30 -04:00
|
|
|
ADD_METHOD( GetStops );
|
|
|
|
|
ADD_METHOD( GetDelays );
|
|
|
|
|
ADD_METHOD( GetBPMs );
|
2011-06-15 16:56:01 -04:00
|
|
|
ADD_METHOD( GetWarps );
|
|
|
|
|
ADD_METHOD( GetFakes );
|
|
|
|
|
ADD_METHOD( GetTimeSignatures );
|
|
|
|
|
ADD_METHOD( GetTickcounts );
|
|
|
|
|
ADD_METHOD( GetSpeeds );
|
|
|
|
|
ADD_METHOD( GetScrolls );
|
|
|
|
|
ADD_METHOD( GetCombos );
|
2011-04-04 23:03:10 -04:00
|
|
|
ADD_METHOD( GetLabels );
|
2011-03-17 01:47:30 -04:00
|
|
|
ADD_METHOD( GetBPMsAndTimes );
|
|
|
|
|
ADD_METHOD( GetActualBPM );
|
|
|
|
|
ADD_METHOD( HasNegativeBPMs );
|
|
|
|
|
// formerly in Song.cpp in sm-ssc private beta 1.x:
|
|
|
|
|
ADD_METHOD( GetBPMAtBeat );
|
|
|
|
|
ADD_METHOD( GetBeatFromElapsedTime );
|
|
|
|
|
ADD_METHOD( GetElapsedTimeFromBeat );
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
LUA_REGISTER_CLASS( TimingData )
|
|
|
|
|
// lua end
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (c) 2001-2004 Chris Danford, Glenn Maynard
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|