NoteField::m_fBeginMarker, m_fEndMarker -> m_iBeginMarker, m_iEndMarker

go back to storing BPM as a float, until I'm sure it won't cause precision
problems
This commit is contained in:
Glenn Maynard
2005-01-23 23:17:12 +00:00
parent ae427e7cb5
commit 52731adc29
10 changed files with 124 additions and 138 deletions
+17 -14
View File
@@ -31,7 +31,7 @@ NoteField::NoteField()
m_sprBars.Load( THEME->GetPathToG("NoteField bars") ); m_sprBars.Load( THEME->GetPathToG("NoteField bars") );
m_sprBars.StopAnimating(); m_sprBars.StopAnimating();
m_fBeginMarker = m_fEndMarker = -1; m_iBeginMarker = m_iEndMarker = -1;
m_fPercentFadeToFail = -1; m_fPercentFadeToFail = -1;
LastDisplay = NULL; LastDisplay = NULL;
@@ -267,8 +267,9 @@ void NoteField::DrawBeatBar( const float fBeat )
} }
} }
void NoteField::DrawMarkerBar( const float fBeat ) void NoteField::DrawMarkerBar( int iBeat )
{ {
float fBeat = NoteRowToBeat( iBeat );
const float fYOffset = ArrowEffects::GetYOffset( m_pPlayerState, 0, fBeat ); const float fYOffset = ArrowEffects::GetYOffset( m_pPlayerState, 0, fBeat );
const float fYPos = ArrowEffects::GetYPos( m_pPlayerState, 0, fYOffset, m_fYReverseOffsetPixels ); const float fYPos = ArrowEffects::GetYPos( m_pPlayerState, 0, fYOffset, m_fYReverseOffsetPixels );
@@ -277,8 +278,10 @@ void NoteField::DrawMarkerBar( const float fBeat )
m_rectMarkerBar.Draw(); m_rectMarkerBar.Draw();
} }
void NoteField::DrawAreaHighlight( const float fStartBeat, const float fEndBeat ) void NoteField::DrawAreaHighlight( int iStartBeat, int iEndBeat )
{ {
float fStartBeat = NoteRowToBeat( iStartBeat );
float fEndBeat = NoteRowToBeat( iEndBeat );
float fYStartOffset = ArrowEffects::GetYOffset( m_pPlayerState, 0, fStartBeat ); float fYStartOffset = ArrowEffects::GetYOffset( m_pPlayerState, 0, fStartBeat );
float fYStartPos = ArrowEffects::GetYPos( m_pPlayerState, 0, fYStartOffset, m_fYReverseOffsetPixels ); float fYStartPos = ArrowEffects::GetYPos( m_pPlayerState, 0, fYStartOffset, m_fYReverseOffsetPixels );
float fYEndOffset = ArrowEffects::GetYOffset( m_pPlayerState, 0, fEndBeat ); float fYEndOffset = ArrowEffects::GetYOffset( m_pPlayerState, 0, fEndBeat );
@@ -524,12 +527,12 @@ void NoteField::DrawPrimitives()
// //
// Draw marker bars // Draw marker bars
// //
if( m_fBeginMarker != -1 && m_fEndMarker != -1 ) if( m_iBeginMarker != -1 && m_iEndMarker != -1 )
DrawAreaHighlight( m_fBeginMarker, m_fEndMarker ); DrawAreaHighlight( m_iBeginMarker, m_iEndMarker );
else if( m_fBeginMarker != -1 ) else if( m_iBeginMarker != -1 )
DrawMarkerBar( m_fBeginMarker ); DrawMarkerBar( m_iBeginMarker );
else if( m_fEndMarker != -1 ) else if( m_iEndMarker != -1 )
DrawMarkerBar( m_fEndMarker ); DrawMarkerBar( m_iEndMarker );
} }
@@ -590,8 +593,8 @@ void NoteField::DrawPrimitives()
SearchForBeat( CurDisplay, NextDisplay, NoteRowToBeat(hn.iStartRow) ); SearchForBeat( CurDisplay, NextDisplay, NoteRowToBeat(hn.iStartRow) );
bool bIsInSelectionRange = false; bool bIsInSelectionRange = false;
if( m_fBeginMarker!=-1 && m_fEndMarker!=-1 ) if( m_iBeginMarker!=-1 && m_iEndMarker!=-1 )
bIsInSelectionRange = hn.ContainedByRange( BeatToNoteRow( m_fBeginMarker ), BeatToNoteRow( m_fEndMarker ) ); bIsInSelectionRange = hn.ContainedByRange( m_iBeginMarker, m_iEndMarker );
NoteDisplayCols *nd = CurDisplay->second; NoteDisplayCols *nd = CurDisplay->second;
nd->display[c].DrawHold( hn, bIsHoldingNote, bIsActive, Result, bIsInSelectionRange ? fSelectedRangeGlow : m_fPercentFadeToFail, false, m_fYReverseOffsetPixels ); nd->display[c].DrawHold( hn, bIsHoldingNote, bIsActive, Result, bIsInSelectionRange ? fSelectedRangeGlow : m_fPercentFadeToFail, false, m_fYReverseOffsetPixels );
@@ -652,10 +655,10 @@ void NoteField::DrawPrimitives()
} }
bool bIsInSelectionRange = false; bool bIsInSelectionRange = false;
if( m_fBeginMarker!=-1 && m_fEndMarker!=-1 ) if( m_iBeginMarker!=-1 && m_iEndMarker!=-1 )
{ {
float fBeat = NoteRowToBeat(i); int iBeat = i;
bIsInSelectionRange = m_fBeginMarker<=fBeat && fBeat<=m_fEndMarker; bIsInSelectionRange = m_iBeginMarker<=iBeat && iBeat<=m_iEndMarker;
} }
bool bIsAddition = (tn.source == TapNote::addition); bool bIsAddition = (tn.source == TapNote::addition);
+3 -3
View File
@@ -30,7 +30,7 @@ public:
float fYReverseOffsetPixels ); float fYReverseOffsetPixels );
virtual void Unload(); virtual void Unload();
float m_fBeginMarker, m_fEndMarker; // only used with MODE_EDIT int m_iBeginMarker, m_iEndMarker; // only used with MODE_EDIT
void FadeToFail(); void FadeToFail();
void CacheAllUsedNoteSkins( bool bDeleteUnused ); void CacheAllUsedNoteSkins( bool bDeleteUnused );
@@ -44,8 +44,8 @@ public:
protected: protected:
void DrawBeatBar( const float fBeat ); void DrawBeatBar( const float fBeat );
void DrawMarkerBar( const float fBeat ); void DrawMarkerBar( int fBeat );
void DrawAreaHighlight( const float fStartBeat, const float fEndBeat ); void DrawAreaHighlight( int iStartBeat, int iEndBeat );
void DrawBPMText( const float fBeat, const float fBPM ); void DrawBPMText( const float fBeat, const float fBPM );
void DrawFreezeText( const float fBeat, const float fBPM ); void DrawFreezeText( const float fBeat, const float fBPM );
void DrawBGChangeText( const float fBeat, const CString sNewBGName ); void DrawBGChangeText( const float fBeat, const CString sNewBGName );
+1 -1
View File
@@ -603,7 +603,7 @@ void BMSLoader::ReadGlobalTags( const NameToData_t &mapNameToData, Song &out )
if( GetTagFromMap( mapNameToData, "#bpm", sData ) ) if( GetTagFromMap( mapNameToData, "#bpm", sData ) )
{ {
BPMSegment newSeg( 0, BeatToNoteRow(strtof(sData, NULL)) ); BPMSegment newSeg( 0, strtof(sData, NULL) );
out.AddBPMSegment( newSeg ); out.AddBPMSegment( newSeg );
LOG->Trace( "Inserting new BPM change at beat %f, BPM %f", NoteRowToBeat(newSeg.m_iStartIndex), newSeg.GetBPM() ); LOG->Trace( "Inserting new BPM change at beat %f, BPM %f", NoteRowToBeat(newSeg.m_iStartIndex), newSeg.GetBPM() );
+1 -1
View File
@@ -375,7 +375,7 @@ bool DWILoader::LoadFromDWIFile( CString sPath, Song &out )
out.m_sCDTitleFile = sParams[1]; out.m_sCDTitleFile = sParams[1];
else if( 0==stricmp(sValueName,"BPM") ) else if( 0==stricmp(sValueName,"BPM") )
out.AddBPMSegment( BPMSegment(0, BeatToNoteRow(strtof(sParams[1], NULL))) ); out.AddBPMSegment( BPMSegment(0, strtof(sParams[1], NULL)) );
else if( 0==stricmp(sValueName,"DISPLAYBPM") ) else if( 0==stricmp(sValueName,"DISPLAYBPM") )
{ {
+8 -6
View File
@@ -146,8 +146,7 @@ bool KSFLoader::LoadFromKSFFile( const CString &sPath, Steps &out, const Song &s
} }
int iHoldStartRow[13]; int iHoldStartRow[13];
int t; for( int t=0; t<13; t++ )
for( t=0; t<13; t++ )
iHoldStartRow[t] = -1; iHoldStartRow[t] = -1;
for( unsigned r=0; r<asRows.size(); r++ ) for( unsigned r=0; r<asRows.size(); r++ )
@@ -203,7 +202,10 @@ bool KSFLoader::LoadFromKSFFile( const CString &sPath, Steps &out, const Song &s
{ {
case '0': tap = TAP_EMPTY; break; case '0': tap = TAP_EMPTY; break;
case '1': tap = TAP_ORIGINAL_TAP; break; case '1': tap = TAP_ORIGINAL_TAP; break;
default: ASSERT(0); tap = TAP_EMPTY; break; default:
LOG->Warn( "File %s had an invalid row (\"%s\"); corrupt notes ignored",
sPath.c_str(), sRowString.c_str() );
return false;
} }
notedata.SetTapNote(t, row, tap); notedata.SetTapNote(t, row, tap);
@@ -283,7 +285,7 @@ bool KSFLoader::LoadGlobalData( const CString &sPath, Song &out )
if( 0==stricmp(sValueName,"TITLE") ) if( 0==stricmp(sValueName,"TITLE") )
LoadTags(sParams[1], out); LoadTags(sParams[1], out);
else if( 0==stricmp(sValueName,"BPM") ) else if( 0==stricmp(sValueName,"BPM") )
out.AddBPMSegment( BPMSegment(0, BeatToNoteRow(strtof(sParams[1], NULL))) ); out.AddBPMSegment( BPMSegment(0, strtof(sParams[1], NULL)) );
else if( 0==stricmp(sValueName,"BPM2") ) else if( 0==stricmp(sValueName,"BPM2") )
BPM2 = strtof( sParams[1], NULL ); BPM2 = strtof( sParams[1], NULL );
else if( 0==stricmp(sValueName,"BPM3") ) else if( 0==stricmp(sValueName,"BPM3") )
@@ -310,7 +312,7 @@ bool KSFLoader::LoadGlobalData( const CString &sPath, Song &out )
const float beat = BPMPos2 * BeatsPerSecond; const float beat = BPMPos2 * BeatsPerSecond;
LOG->Trace("BPM %f, BPS %f, BPMPos2 %f, beat %f", LOG->Trace("BPM %f, BPS %f, BPMPos2 %f, beat %f",
out.GetBPMAtBeat(0), BeatsPerSecond, BPMPos2, beat); out.GetBPMAtBeat(0), BeatsPerSecond, BPMPos2, beat);
out.AddBPMSegment( BPMSegment(BeatToNoteRow(beat), BeatToNoteRow(BPM2)) ); out.AddBPMSegment( BPMSegment(BeatToNoteRow(beat), BPM2) );
} }
if( BPM3 > 0 && BPMPos3 > 0 ) if( BPM3 > 0 && BPMPos3 > 0 )
@@ -319,7 +321,7 @@ bool KSFLoader::LoadGlobalData( const CString &sPath, Song &out )
const float beat = BPMPos3 * BeatsPerSecond; const float beat = BPMPos3 * BeatsPerSecond;
LOG->Trace("BPM %f, BPS %f, BPMPos3 %f, beat %f", LOG->Trace("BPM %f, BPS %f, BPMPos3 %f, beat %f",
out.GetBPMAtBeat(0), BeatsPerSecond, BPMPos3, beat); out.GetBPMAtBeat(0), BeatsPerSecond, BPMPos3, beat);
out.AddBPMSegment( BPMSegment(BeatToNoteRow(beat), BeatToNoteRow(BPM3)) ); out.AddBPMSegment( BPMSegment(BeatToNoteRow(beat), BPM3) );
} }
/* Try to fill in missing bits of information from the pathname. */ /* Try to fill in missing bits of information from the pathname. */
+69 -83
View File
@@ -489,7 +489,7 @@ ScreenEdit::ScreenEdit( CString sName ) : Screen( sName )
GAMESTATE->ResetNoteSkins(); GAMESTATE->ResetNoteSkins();
GAMESTATE->StoreSelectedOptions(); GAMESTATE->StoreSelectedOptions();
g_fShiftAnchor = -1; g_iShiftAnchor = -1;
m_SnapDisplay.SetXY( EDIT_X, PLAYER_Y_STANDARD ); m_SnapDisplay.SetXY( EDIT_X, PLAYER_Y_STANDARD );
@@ -664,7 +664,7 @@ void ScreenEdit::Update( float fDeltaTime )
// check for end of playback/record // check for end of playback/record
if( GAMESTATE->m_fSongBeat > m_NoteFieldEdit.m_fEndMarker + 4 ) // give a one measure lead out if( GAMESTATE->m_fSongBeat > NoteRowToBeat(m_NoteFieldEdit.m_iEndMarker) + 4 ) // give a one measure lead out
{ {
if( m_EditMode == MODE_RECORDING ) if( m_EditMode == MODE_RECORDING )
{ {
@@ -674,7 +674,7 @@ void ScreenEdit::Update( float fDeltaTime )
{ {
TransitionToEdit(); TransitionToEdit();
} }
GAMESTATE->m_fSongBeat = m_NoteFieldEdit.m_fEndMarker; GAMESTATE->m_fSongBeat = NoteRowToBeat( m_NoteFieldEdit.m_iEndMarker );
} }
} }
@@ -742,8 +742,8 @@ void ScreenEdit::UpdateTextInfo()
sText += ssprintf( "Current Beat:\n %.2f\n", GAMESTATE->m_fSongBeat ); sText += ssprintf( "Current Beat:\n %.2f\n", GAMESTATE->m_fSongBeat );
sText += ssprintf( "Current Second:\n %.2f\n", m_pSong->GetElapsedTimeFromBeat(GAMESTATE->m_fSongBeat) ); sText += ssprintf( "Current Second:\n %.2f\n", m_pSong->GetElapsedTimeFromBeat(GAMESTATE->m_fSongBeat) );
sText += ssprintf( "Snap to:\n %s\n", sNoteType.c_str() ); sText += ssprintf( "Snap to:\n %s\n", sNoteType.c_str() );
sText += ssprintf( "Selection begin:\n %s\n", m_NoteFieldEdit.m_fBeginMarker==-1 ? "not set" : ssprintf("%.2f",m_NoteFieldEdit.m_fBeginMarker).c_str() ); sText += ssprintf( "Selection begin:\n %s\n", m_NoteFieldEdit.m_iBeginMarker==-1 ? "not set" : ssprintf("%.2f",NoteRowToBeat(m_NoteFieldEdit.m_iBeginMarker)).c_str() );
sText += ssprintf( "Selection end:\n %s\n", m_NoteFieldEdit.m_fEndMarker==-1 ? "not set" : ssprintf("%.2f",m_NoteFieldEdit.m_fEndMarker).c_str() ); sText += ssprintf( "Selection end:\n %s\n", m_NoteFieldEdit.m_iEndMarker==-1 ? "not set" : ssprintf("%.2f",NoteRowToBeat(m_NoteFieldEdit.m_iEndMarker)).c_str() );
sText += ssprintf( "Difficulty:\n %s\n", DifficultyToString( m_pSteps->GetDifficulty() ).c_str() ); sText += ssprintf( "Difficulty:\n %s\n", DifficultyToString( m_pSteps->GetDifficulty() ).c_str() );
sText += ssprintf( "Description:\n %s\n", GAMESTATE->m_pCurSteps[PLAYER_1] ? GAMESTATE->m_pCurSteps[PLAYER_1]->GetDescription().c_str() : "no description" ); sText += ssprintf( "Description:\n %s\n", GAMESTATE->m_pCurSteps[PLAYER_1] ? GAMESTATE->m_pCurSteps[PLAYER_1]->GetDescription().c_str() : "no description" );
sText += ssprintf( "Main title:\n %s\n", m_pSong->m_sMainTitle.c_str() ); sText += ssprintf( "Main title:\n %s\n", m_pSong->m_sMainTitle.c_str() );
@@ -834,9 +834,6 @@ void ScreenEdit::Input( const DeviceInput& DeviceI, const InputEventType type, c
void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI, EditButton EditB ) void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI, EditButton EditB )
{ {
if( DeviceI.device != DEVICE_KEYBOARD )
return;
if( type == IET_LEVEL_CHANGED ) if( type == IET_LEVEL_CHANGED )
return; // don't care return; // don't care
@@ -845,12 +842,13 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
switch( EditB ) switch( EditB )
{ {
case EDIT_BUTTON_SCROLL_SELECT: case EDIT_BUTTON_SCROLL_SELECT:
g_fShiftAnchor = -1; g_iShiftAnchor = -1;
break; break;
} }
return; return;
} }
const int iSongBeat = BeatToNoteRow(GAMESTATE->m_fSongBeat);
switch( EditB ) switch( EditB )
{ {
case EDIT_BUTTON_COLUMN_0: case EDIT_BUTTON_COLUMN_0:
@@ -1008,21 +1006,21 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
* *
* If this is the first time we've moved since shift was depressed, * If this is the first time we've moved since shift was depressed,
* the old position (before this move) becomes the start pos: */ * the old position (before this move) becomes the start pos: */
int iEndBeat = BeatToNoteRow( fEndBeat );
if( g_iShiftAnchor == -1 )
g_iShiftAnchor = BeatToNoteRow(fStartBeat);
if( g_fShiftAnchor == -1 ) if( iEndBeat == g_iShiftAnchor )
g_fShiftAnchor = fStartBeat;
if(fEndBeat == g_fShiftAnchor)
{ {
/* We're back at the anchor, so we have nothing selected. */ /* We're back at the anchor, so we have nothing selected. */
m_NoteFieldEdit.m_fBeginMarker = m_NoteFieldEdit.m_fEndMarker = -1; m_NoteFieldEdit.m_iBeginMarker = m_NoteFieldEdit.m_iEndMarker = -1;
} }
else else
{ {
m_NoteFieldEdit.m_fBeginMarker = g_fShiftAnchor; m_NoteFieldEdit.m_iBeginMarker = g_iShiftAnchor;
m_NoteFieldEdit.m_fEndMarker = fEndBeat; m_NoteFieldEdit.m_iEndMarker = iEndBeat;
if(m_NoteFieldEdit.m_fBeginMarker > m_NoteFieldEdit.m_fEndMarker) if( m_NoteFieldEdit.m_iBeginMarker > m_NoteFieldEdit.m_iEndMarker )
swap(m_NoteFieldEdit.m_fBeginMarker, m_NoteFieldEdit.m_fEndMarker); swap( m_NoteFieldEdit.m_iBeginMarker, m_NoteFieldEdit.m_iEndMarker );
} }
} }
@@ -1041,38 +1039,38 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
OnSnapModeChange(); OnSnapModeChange();
break; break;
case EDIT_BUTTON_LAY_SELECT: case EDIT_BUTTON_LAY_SELECT:
if( m_NoteFieldEdit.m_fBeginMarker==-1 && m_NoteFieldEdit.m_fEndMarker==-1 ) if( m_NoteFieldEdit.m_iBeginMarker==-1 && m_NoteFieldEdit.m_iEndMarker==-1 )
{ {
// lay begin marker // lay begin marker
m_NoteFieldEdit.m_fBeginMarker = GAMESTATE->m_fSongBeat; m_NoteFieldEdit.m_iBeginMarker = BeatToNoteRow(GAMESTATE->m_fSongBeat);
} }
else if( m_NoteFieldEdit.m_fEndMarker==-1 ) // only begin marker is laid else if( m_NoteFieldEdit.m_iEndMarker==-1 ) // only begin marker is laid
{ {
if( GAMESTATE->m_fSongBeat == m_NoteFieldEdit.m_fBeginMarker ) if( iSongBeat == m_NoteFieldEdit.m_iBeginMarker )
{ {
m_NoteFieldEdit.m_fBeginMarker = -1; m_NoteFieldEdit.m_iBeginMarker = -1;
} }
else else
{ {
m_NoteFieldEdit.m_fEndMarker = max( m_NoteFieldEdit.m_fBeginMarker, GAMESTATE->m_fSongBeat ); m_NoteFieldEdit.m_iEndMarker = max( m_NoteFieldEdit.m_iBeginMarker, iSongBeat );
m_NoteFieldEdit.m_fBeginMarker = min( m_NoteFieldEdit.m_fBeginMarker, GAMESTATE->m_fSongBeat ); m_NoteFieldEdit.m_iBeginMarker = min( m_NoteFieldEdit.m_iBeginMarker, iSongBeat );
} }
} }
else // both markers are laid else // both markers are laid
{ {
m_NoteFieldEdit.m_fBeginMarker = GAMESTATE->m_fSongBeat; m_NoteFieldEdit.m_iBeginMarker = iSongBeat;
m_NoteFieldEdit.m_fEndMarker = -1; m_NoteFieldEdit.m_iEndMarker = -1;
} }
m_soundMarker.Play(); m_soundMarker.Play();
break; break;
case EDIT_BUTTON_OPEN_AREA_MENU: case EDIT_BUTTON_OPEN_AREA_MENU:
{ {
// update enabled/disabled in g_AreaMenu // update enabled/disabled in g_AreaMenu
bool bAreaSelected = m_NoteFieldEdit.m_fBeginMarker!=-1 && m_NoteFieldEdit.m_fEndMarker!=-1; bool bAreaSelected = m_NoteFieldEdit.m_iBeginMarker!=-1 && m_NoteFieldEdit.m_iEndMarker!=-1;
g_AreaMenu.rows[cut].enabled = bAreaSelected; g_AreaMenu.rows[cut].enabled = bAreaSelected;
g_AreaMenu.rows[copy].enabled = bAreaSelected; g_AreaMenu.rows[copy].enabled = bAreaSelected;
g_AreaMenu.rows[paste_at_current_beat].enabled = this->m_Clipboard.GetLastBeat() != 0; g_AreaMenu.rows[paste_at_current_beat].enabled = this->m_Clipboard.GetLastBeat() != 0;
g_AreaMenu.rows[paste_at_begin_marker].enabled = this->m_Clipboard.GetLastBeat() != 0 && m_NoteFieldEdit.m_fBeginMarker!=-1; g_AreaMenu.rows[paste_at_begin_marker].enabled = this->m_Clipboard.GetLastBeat() != 0 && m_NoteFieldEdit.m_iBeginMarker!=-1;
g_AreaMenu.rows[clear].enabled = bAreaSelected; g_AreaMenu.rows[clear].enabled = bAreaSelected;
g_AreaMenu.rows[quantize].enabled = bAreaSelected; g_AreaMenu.rows[quantize].enabled = bAreaSelected;
g_AreaMenu.rows[turn].enabled = bAreaSelected; g_AreaMenu.rows[turn].enabled = bAreaSelected;
@@ -1306,13 +1304,13 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
break; break;
case EDIT_BUTTON_PLAY_SELECTION: case EDIT_BUTTON_PLAY_SELECTION:
if( m_NoteFieldEdit.m_fBeginMarker!=-1 && m_NoteFieldEdit.m_fEndMarker!=-1 ) if( m_NoteFieldEdit.m_iBeginMarker!=-1 && m_NoteFieldEdit.m_iEndMarker!=-1 )
HandleAreaMenuChoice( play, NULL ); HandleAreaMenuChoice( play, NULL );
else else
HandleMainMenuChoice( play_current_beat_to_end, NULL ); HandleMainMenuChoice( play_current_beat_to_end, NULL );
break; break;
case EDIT_BUTTON_RECORD: case EDIT_BUTTON_RECORD:
if( m_NoteFieldEdit.m_fBeginMarker!=-1 && m_NoteFieldEdit.m_fEndMarker!=-1 ) if( m_NoteFieldEdit.m_iBeginMarker!=-1 && m_NoteFieldEdit.m_iEndMarker!=-1 )
HandleAreaMenuChoice( record, NULL ); HandleAreaMenuChoice( record, NULL );
break; break;
case EDIT_BUTTON_INSERT: case EDIT_BUTTON_INSERT:
@@ -1464,13 +1462,10 @@ void ScreenEdit::TransitionFromRecordToEdit()
{ {
TransitionToEdit(); TransitionToEdit();
int rowBegin = BeatToNoteRow( m_NoteFieldEdit.m_fBeginMarker );
int rowEnd = BeatToNoteRow( m_NoteFieldEdit.m_fEndMarker );
// delete old TapNotes in the range // delete old TapNotes in the range
m_NoteDataEdit.ClearRange( rowBegin, rowEnd ); m_NoteDataEdit.ClearRange( m_NoteFieldEdit.m_iBeginMarker, m_NoteFieldEdit.m_iEndMarker );
m_NoteDataEdit.CopyRange( m_NoteDataRecord, rowBegin, rowEnd, rowBegin ); m_NoteDataEdit.CopyRange( m_NoteDataRecord, m_NoteFieldEdit.m_iBeginMarker, m_NoteFieldEdit.m_iEndMarker, m_NoteFieldEdit.m_iBeginMarker );
m_NoteDataRecord.ClearAll(); m_NoteDataRecord.ClearAll();
} }
@@ -1736,15 +1731,15 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, int* iAnswers )
break; break;
case play_whole_song: case play_whole_song:
{ {
m_NoteFieldEdit.m_fBeginMarker = 0; m_NoteFieldEdit.m_iBeginMarker = 0;
m_NoteFieldEdit.m_fEndMarker = m_NoteDataEdit.GetLastBeat(); m_NoteFieldEdit.m_iEndMarker = m_NoteDataEdit.GetLastRow();
HandleAreaMenuChoice( play, NULL ); HandleAreaMenuChoice( play, NULL );
} }
break; break;
case play_current_beat_to_end: case play_current_beat_to_end:
{ {
m_NoteFieldEdit.m_fBeginMarker = GAMESTATE->m_fSongBeat; m_NoteFieldEdit.m_iBeginMarker = BeatToNoteRow(GAMESTATE->m_fSongBeat);
m_NoteFieldEdit.m_fEndMarker = m_NoteDataEdit.GetLastBeat(); m_NoteFieldEdit.m_iEndMarker = m_NoteDataEdit.GetLastRow();
HandleAreaMenuChoice( play, NULL ); HandleAreaMenuChoice( play, NULL );
} }
break; break;
@@ -1915,11 +1910,9 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers )
break; break;
case copy: case copy:
{ {
ASSERT( m_NoteFieldEdit.m_fBeginMarker!=-1 && m_NoteFieldEdit.m_fEndMarker!=-1 ); ASSERT( m_NoteFieldEdit.m_iBeginMarker!=-1 && m_NoteFieldEdit.m_iEndMarker!=-1 );
int iFirstRow = BeatToNoteRow( m_NoteFieldEdit.m_fBeginMarker );
int iLastRow = BeatToNoteRow( m_NoteFieldEdit.m_fEndMarker );
m_Clipboard.ClearAll(); m_Clipboard.ClearAll();
m_Clipboard.CopyRange( m_NoteDataEdit, iFirstRow, iLastRow ); m_Clipboard.CopyRange( m_NoteDataEdit, m_NoteFieldEdit.m_iBeginMarker, m_NoteFieldEdit.m_iEndMarker );
} }
break; break;
case paste_at_current_beat: case paste_at_current_beat:
@@ -1932,25 +1925,20 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers )
break; break;
case paste_at_begin_marker: case paste_at_begin_marker:
{ {
ASSERT( m_NoteFieldEdit.m_fBeginMarker!=-1 ); ASSERT( m_NoteFieldEdit.m_iBeginMarker!=-1 );
int iSrcFirstRow = 0; m_NoteDataEdit.CopyRange( m_Clipboard, 0, m_Clipboard.GetLastRow(), m_NoteFieldEdit.m_iBeginMarker );
int iSrcLastRow = BeatToNoteRow( m_Clipboard.GetLastBeat() );
int iDestFirstRow = BeatToNoteRow( m_NoteFieldEdit.m_fBeginMarker );
m_NoteDataEdit.CopyRange( m_Clipboard, iSrcFirstRow, iSrcLastRow, iDestFirstRow );
} }
break; break;
case clear: case clear:
{ {
ASSERT( m_NoteFieldEdit.m_fBeginMarker!=-1 && m_NoteFieldEdit.m_fEndMarker!=-1 ); ASSERT( m_NoteFieldEdit.m_iBeginMarker!=-1 && m_NoteFieldEdit.m_iEndMarker!=-1 );
int iFirstRow = BeatToNoteRow( m_NoteFieldEdit.m_fBeginMarker ); m_NoteDataEdit.ClearRange( m_NoteFieldEdit.m_iBeginMarker, m_NoteFieldEdit.m_iEndMarker );
int iLastRow = BeatToNoteRow( m_NoteFieldEdit.m_fEndMarker );
m_NoteDataEdit.ClearRange( iFirstRow, iLastRow );
} }
break; break;
case quantize: case quantize:
{ {
NoteType nt = (NoteType)iAnswers[c]; NoteType nt = (NoteType)iAnswers[c];
NoteDataUtil::SnapToNearestNoteType( m_NoteDataEdit, nt, nt, BeatToNoteRow(m_NoteFieldEdit.m_fBeginMarker), BeatToNoteRow(m_NoteFieldEdit.m_fEndMarker) ); NoteDataUtil::SnapToNearestNoteType( m_NoteDataEdit, nt, nt, m_NoteFieldEdit.m_iBeginMarker, m_NoteFieldEdit.m_iEndMarker );
} }
break; break;
case turn: case turn:
@@ -1976,8 +1964,8 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers )
break; break;
case transform: case transform:
{ {
int iBeginRow = BeatToNoteRow( m_NoteFieldEdit.m_fBeginMarker ); int iBeginRow = m_NoteFieldEdit.m_iBeginMarker;
int iEndRow = BeatToNoteRow( m_NoteFieldEdit.m_fEndMarker ); int iEndRow = m_NoteFieldEdit.m_iEndMarker;
TransformType tt = (TransformType)iAnswers[c]; TransformType tt = (TransformType)iAnswers[c];
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType; StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType;
@@ -2066,13 +2054,12 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers )
m_Clipboard.Convert2sAnd3sToHoldNotes(); m_Clipboard.Convert2sAnd3sToHoldNotes();
// float fOldClipboardEndBeat = m_NoteFieldEdit.m_fEndMarker; int iOldClipboardBeats = m_NoteFieldEdit.m_iEndMarker - m_NoteFieldEdit.m_iBeginMarker;
float fOldClipboardBeats = m_NoteFieldEdit.m_fEndMarker - m_NoteFieldEdit.m_fBeginMarker; int iNewClipboardBeats = lrintf( iOldClipboardBeats * fScale );
float fNewClipboardBeats = fOldClipboardBeats * fScale; int iDeltaBeats = iNewClipboardBeats - iOldClipboardBeats;
float fDeltaBeats = fNewClipboardBeats - fOldClipboardBeats; int iNewClipboardEndBeat = m_NoteFieldEdit.m_iBeginMarker + iNewClipboardBeats;
float fNewClipboardEndBeat = m_NoteFieldEdit.m_fBeginMarker + fNewClipboardBeats; NoteDataUtil::ShiftRows( m_NoteDataEdit, m_NoteFieldEdit.m_iBeginMarker, iDeltaBeats );
NoteDataUtil::ShiftRows( m_NoteDataEdit, BeatToNoteRow(m_NoteFieldEdit.m_fBeginMarker), BeatToNoteRow(fDeltaBeats) ); m_pSong->m_Timing.ScaleRegion( fScale, m_NoteFieldEdit.m_iBeginMarker, m_NoteFieldEdit.m_iEndMarker );
m_pSong->m_Timing.ScaleRegion( fScale, BeatToNoteRow(m_NoteFieldEdit.m_fBeginMarker), BeatToNoteRow(m_NoteFieldEdit.m_fEndMarker) );
HandleAreaMenuChoice( paste_at_begin_marker, NULL ); HandleAreaMenuChoice( paste_at_begin_marker, NULL );
@@ -2091,22 +2078,22 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers )
sIter[i]->GetNoteData( ndTemp ); sIter[i]->GetNoteData( ndTemp );
ndTemp.ConvertHoldNotesTo2sAnd3s(); ndTemp.ConvertHoldNotesTo2sAnd3s();
NoteDataUtil::ScaleRegion( ndTemp, fScale, BeatToNoteRow(m_NoteFieldEdit.m_fBeginMarker), BeatToNoteRow(m_NoteFieldEdit.m_fEndMarker) ); NoteDataUtil::ScaleRegion( ndTemp, fScale, m_NoteFieldEdit.m_iBeginMarker, m_NoteFieldEdit.m_iEndMarker );
ndTemp.Convert2sAnd3sToHoldNotes(); ndTemp.Convert2sAnd3sToHoldNotes();
sIter[i]->SetNoteData( ndTemp ); sIter[i]->SetNoteData( ndTemp );
} }
m_NoteFieldEdit.m_fEndMarker = fNewClipboardEndBeat; m_NoteFieldEdit.m_iEndMarker = iNewClipboardEndBeat;
float fOldBPM = m_pSong->GetBPMAtBeat( m_NoteFieldEdit.m_fBeginMarker ); float fOldBPM = m_pSong->GetBPMAtBeat( NoteRowToBeat(m_NoteFieldEdit.m_iBeginMarker) );
float fNewBPM = fOldBPM * fScale; float fNewBPM = fOldBPM * fScale;
m_pSong->SetBPMAtBeat( m_NoteFieldEdit.m_fBeginMarker, fNewBPM ); m_pSong->SetBPMAtBeat( NoteRowToBeat(m_NoteFieldEdit.m_iBeginMarker), fNewBPM );
m_pSong->SetBPMAtBeat( fNewClipboardEndBeat, fOldBPM ); m_pSong->SetBPMAtBeat( NoteRowToBeat(iNewClipboardEndBeat), fOldBPM );
} }
break; break;
case play: case play:
{ {
ASSERT( m_NoteFieldEdit.m_fBeginMarker!=-1 && m_NoteFieldEdit.m_fEndMarker!=-1 ); ASSERT( m_NoteFieldEdit.m_iBeginMarker!=-1 && m_NoteFieldEdit.m_iEndMarker!=-1 );
SOUND->PlayMusic(""); SOUND->PlayMusic("");
@@ -2120,7 +2107,7 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers )
/* Give a 1 measure lead-in. Set this before loading Player, so it knows /* Give a 1 measure lead-in. Set this before loading Player, so it knows
* where we're starting. */ * where we're starting. */
float fSeconds = m_pSong->m_Timing.GetElapsedTimeFromBeat( m_NoteFieldEdit.m_fBeginMarker - 4 ); float fSeconds = m_pSong->m_Timing.GetElapsedTimeFromBeat( NoteRowToBeat(m_NoteFieldEdit.m_iBeginMarker) - 4 );
GAMESTATE->UpdateSongPosition( fSeconds, m_pSong->m_Timing ); GAMESTATE->UpdateSongPosition( fSeconds, m_pSong->m_Timing );
/* If we're in course display mode, set that up. */ /* If we're in course display mode, set that up. */
@@ -2161,7 +2148,7 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers )
break; break;
case record: case record:
{ {
ASSERT( m_NoteFieldEdit.m_fBeginMarker!=-1 && m_NoteFieldEdit.m_fEndMarker!=-1 ); ASSERT( m_NoteFieldEdit.m_iBeginMarker!=-1 && m_NoteFieldEdit.m_iEndMarker!=-1 );
SOUND->PlayMusic(""); SOUND->PlayMusic("");
@@ -2181,7 +2168,7 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers )
m_rectRecordBack.BeginTweening( 0.5f ); m_rectRecordBack.BeginTweening( 0.5f );
m_rectRecordBack.SetDiffuse( RageColor(0,0,0,0.8f) ); m_rectRecordBack.SetDiffuse( RageColor(0,0,0,0.8f) );
GAMESTATE->m_fSongBeat = m_NoteFieldEdit.m_fBeginMarker - 4; // give a 1 measure lead-in GAMESTATE->m_fSongBeat = NoteRowToBeat(m_NoteFieldEdit.m_iBeginMarker - ROWS_PER_MEASURE ); // give a 1 measure lead-in
float fStartSeconds = m_pSong->GetElapsedTimeFromBeat(GAMESTATE->m_fSongBeat); float fStartSeconds = m_pSong->GetElapsedTimeFromBeat(GAMESTATE->m_fSongBeat);
LOG->Trace( "Starting playback at %f", fStartSeconds ); LOG->Trace( "Starting playback at %f", fStartSeconds );
@@ -2208,19 +2195,18 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers )
// MD 11/02/03 - Converting selected region to a pause of the same length. // MD 11/02/03 - Converting selected region to a pause of the same length.
case convert_beat_to_pause: case convert_beat_to_pause:
{ {
ASSERT( m_NoteFieldEdit.m_fBeginMarker!=-1 && m_NoteFieldEdit.m_fEndMarker!=-1 ); ASSERT( m_NoteFieldEdit.m_iBeginMarker!=-1 && m_NoteFieldEdit.m_iEndMarker!=-1 );
// This was written horribly, using beats and not converting to time at all. float fMarkerStart = m_pSong->m_Timing.GetElapsedTimeFromBeat( NoteRowToBeat(m_NoteFieldEdit.m_iBeginMarker) );
float fMarkerStart = m_pSong->m_Timing.GetElapsedTimeFromBeat(m_NoteFieldEdit.m_fBeginMarker); float fMarkerEnd = m_pSong->m_Timing.GetElapsedTimeFromBeat( NoteRowToBeat(m_NoteFieldEdit.m_iEndMarker) );
float fMarkerEnd = m_pSong->m_Timing.GetElapsedTimeFromBeat(m_NoteFieldEdit.m_fEndMarker);
float fStopLength = fMarkerEnd - fMarkerStart; float fStopLength = fMarkerEnd - fMarkerStart;
// be sure not to clobber the row at the start - a row at the end // be sure not to clobber the row at the start - a row at the end
// can be dropped safely, though // can be dropped safely, though
NoteDataUtil::ShiftRows( m_NoteDataEdit, NoteDataUtil::ShiftRows( m_NoteDataEdit,
BeatToNoteRow(m_NoteFieldEdit.m_fBeginMarker) + 1, m_NoteFieldEdit.m_iBeginMarker + 1,
BeatToNoteRow(-m_NoteFieldEdit.m_fEndMarker+m_NoteFieldEdit.m_fBeginMarker) -m_NoteFieldEdit.m_iEndMarker+m_NoteFieldEdit.m_iBeginMarker
); );
m_pSong->m_Timing.ShiftRows( BeatToNoteRow(m_NoteFieldEdit.m_fBeginMarker) + 1, m_pSong->m_Timing.ShiftRows( m_NoteFieldEdit.m_iBeginMarker + 1,
BeatToNoteRow(-m_NoteFieldEdit.m_fEndMarker+m_NoteFieldEdit.m_fBeginMarker) -m_NoteFieldEdit.m_iEndMarker+m_NoteFieldEdit.m_iBeginMarker
); );
unsigned i; unsigned i;
for( i=0; i<m_pSong->m_Timing.m_StopSegments.size(); i++ ) for( i=0; i<m_pSong->m_Timing.m_StopSegments.size(); i++ )
@@ -2231,15 +2217,15 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers )
continue; continue;
else { else {
if( fStart > fMarkerStart ) if( fStart > fMarkerStart )
m_pSong->m_Timing.m_StopSegments[i].m_iStartRow = BeatToNoteRow(m_NoteFieldEdit.m_fBeginMarker); m_pSong->m_Timing.m_StopSegments[i].m_iStartRow = m_NoteFieldEdit.m_iBeginMarker;
m_pSong->m_Timing.m_StopSegments[i].m_fStopSeconds = fStopLength; m_pSong->m_Timing.m_StopSegments[i].m_fStopSeconds = fStopLength;
break; break;
} }
} }
if( i == m_pSong->m_Timing.m_StopSegments.size() ) // there is no BPMSegment at the current beat if( i == m_pSong->m_Timing.m_StopSegments.size() ) // there is no BPMSegment at the current beat
m_pSong->AddStopSegment( StopSegment(BeatToNoteRow(m_NoteFieldEdit.m_fBeginMarker), fStopLength) ); m_pSong->AddStopSegment( StopSegment(m_NoteFieldEdit.m_iBeginMarker, fStopLength) );
m_NoteFieldEdit.m_fEndMarker = -1; m_NoteFieldEdit.m_iEndMarker = -1;
break; break;
} }
// MD 11/02/03 - Converting a pause at the current beat into beats. // MD 11/02/03 - Converting a pause at the current beat into beats.
+1 -1
View File
@@ -162,7 +162,7 @@ protected:
float m_fTrailingBeat; // this approaches GAMESTATE->m_fSongBeat, which is the actual beat float m_fTrailingBeat; // this approaches GAMESTATE->m_fSongBeat, which is the actual beat
/* The location we were at when shift was pressed, or /* The location we were at when shift was pressed, or
* -1 when shift isn't pressed: */ * -1 when shift isn't pressed: */
float g_fShiftAnchor; int g_iShiftAnchor;
NoteData m_Clipboard; NoteData m_Clipboard;
+1 -1
View File
@@ -1829,7 +1829,7 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ
fOffsetDelta *= 10; fOffsetDelta *= 10;
BPMSegment& seg = GAMESTATE->m_pCurSong->GetBPMSegmentAtBeat( GAMESTATE->m_fSongBeat ); BPMSegment& seg = GAMESTATE->m_pCurSong->GetBPMSegmentAtBeat( GAMESTATE->m_fSongBeat );
seg.m_iBPS += BeatToNoteRow(fOffsetDelta); seg.m_fBPS += fOffsetDelta;
m_textDebug.SetText( ssprintf("Cur BPM = %.2f", seg.GetBPM()) ); m_textDebug.SetText( ssprintf("Cur BPM = %.2f", seg.GetBPM()) );
m_textDebug.StopTweening(); m_textDebug.StopTweening();
+19 -24
View File
@@ -7,12 +7,12 @@
void BPMSegment::SetBPM( float f ) void BPMSegment::SetBPM( float f )
{ {
m_iBPS = BeatToNoteRow( f / 60.0f ); m_fBPS = f / 60.0f;
} }
float BPMSegment::GetBPM() const float BPMSegment::GetBPM() const
{ {
return NoteRowToBeat(m_iBPS * 60); return m_fBPS * 60.0f;
} }
TimingData::TimingData() TimingData::TimingData()
@@ -42,16 +42,14 @@ void SortStopSegmentsArray( vector<StopSegment> &arrayStopSegments )
void TimingData::GetActualBPM( float &fMinBPMOut, float &fMaxBPMOut ) const void TimingData::GetActualBPM( float &fMinBPMOut, float &fMaxBPMOut ) const
{ {
int iMinBPS = MAX_NOTE_ROW; fMinBPMOut = 99999;
int iMaxBPS = 0; fMaxBPMOut = 0;
for( unsigned i=0; i<m_BPMSegments.size(); i++ ) for( unsigned i=0; i<m_BPMSegments.size(); i++ )
{ {
const BPMSegment &seg = m_BPMSegments[i]; const BPMSegment &seg = m_BPMSegments[i];
iMaxBPS = max( seg.m_iBPS, iMaxBPS ); fMaxBPMOut = max( seg.m_fBPS * 60.0f, fMaxBPMOut );
iMinBPS = min( seg.m_iBPS, iMinBPS ); fMinBPMOut = min( seg.m_fBPS * 60.0f, fMinBPMOut );
} }
fMinBPMOut = NoteRowToBeat( iMinBPS );
fMaxBPMOut = NoteRowToBeat( iMaxBPS );
} }
@@ -71,7 +69,7 @@ void TimingData::AddStopSegment( const StopSegment &seg )
void TimingData::SetBPMAtBeat( float fBeat, float fBPM ) void TimingData::SetBPMAtBeat( float fBeat, float fBPM )
{ {
int iNoteRow = BeatToNoteRow( fBeat ); int iNoteRow = BeatToNoteRow( fBeat );
int iBPS = BeatToNoteRow( fBPM ) / 60; float fBPS = fBPM / 60.0f;
unsigned i; unsigned i;
for( i=0; i<m_BPMSegments.size(); i++ ) for( i=0; i<m_BPMSegments.size(); i++ )
if( m_BPMSegments[i].m_iStartIndex >= iNoteRow ) if( m_BPMSegments[i].m_iStartIndex >= iNoteRow )
@@ -81,16 +79,16 @@ void TimingData::SetBPMAtBeat( float fBeat, float fBPM )
{ {
// There is no BPMSegment at the specified beat. If the BPM being set differs // There is no BPMSegment at the specified beat. If the BPM being set differs
// from the last BPMSegment's BPM, create a new BPMSegment. // from the last BPMSegment's BPM, create a new BPMSegment.
if( i == 0 || m_BPMSegments[i-1].m_iBPS != iBPS ) if( i == 0 || fabsf(m_BPMSegments[i-1].m_fBPS - fBPS) > 0.003f )
AddBPMSegment( BPMSegment(iNoteRow, iBPS) ); AddBPMSegment( BPMSegment(iNoteRow, fBPS) );
} }
else // BPMSegment being modified is m_BPMSegments[i] else // BPMSegment being modified is m_BPMSegments[i]
{ {
if( i > 0 && m_BPMSegments[i-1].m_iBPS == iBPS ) if( i > 0 && fabsf(m_BPMSegments[i-1].m_fBPS - fBPS) < 0.003f )
m_BPMSegments.erase( m_BPMSegments.begin()+i, m_BPMSegments.erase( m_BPMSegments.begin()+i,
m_BPMSegments.begin()+i+1); m_BPMSegments.begin()+i+1);
else else
m_BPMSegments[i].m_iBPS = iBPS; m_BPMSegments[i].m_fBPS = fBPS;
} }
} }
@@ -152,7 +150,7 @@ void TimingData::MultiplyBPMInBeatRange( int iStartIndex, int iEndIndex, float f
else if( iStartIndexNextSegment > iEndIndex ) else if( iStartIndexNextSegment > iEndIndex )
continue; continue;
m_BPMSegments[i].m_iBPS = lrintf( m_BPMSegments[i].m_iBPS * fFactor ); m_BPMSegments[i].m_fBPS = m_BPMSegments[i].m_fBPS * fFactor;
} }
} }
@@ -194,8 +192,7 @@ void TimingData::GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatO
const bool bIsLastBPMSegment = i==m_BPMSegments.size()-1; const bool bIsLastBPMSegment = i==m_BPMSegments.size()-1;
const int iStartRowNextSegment = bIsLastBPMSegment ? MAX_NOTE_ROW : m_BPMSegments[i+1].m_iStartIndex; const int iStartRowNextSegment = bIsLastBPMSegment ? MAX_NOTE_ROW : m_BPMSegments[i+1].m_iStartIndex;
const float fStartBeatNextSegment = NoteRowToBeat( iStartRowNextSegment ); const float fStartBeatNextSegment = NoteRowToBeat( iStartRowNextSegment );
const int iBPS = m_BPMSegments[i].m_iBPS; const float fBPS = m_BPMSegments[i].m_fBPS;
const float fBPS = NoteRowToBeat( iBPS );
for( unsigned j=0; j<m_StopSegments.size(); j++ ) // foreach freeze for( unsigned j=0; j<m_StopSegments.size(); j++ ) // foreach freeze
{ {
@@ -260,24 +257,22 @@ float TimingData::GetElapsedTimeFromBeat( float fBeat ) const
for( unsigned i=0; i<m_BPMSegments.size(); i++ ) // foreach BPMSegment for( unsigned i=0; i<m_BPMSegments.size(); i++ ) // foreach BPMSegment
{ {
const bool bIsLastBPMSegment = i==m_BPMSegments.size()-1; const bool bIsLastBPMSegment = i==m_BPMSegments.size()-1;
const float fBPS = NoteRowToBeat( m_BPMSegments[i].m_iBPS ); const float fBPS = m_BPMSegments[i].m_fBPS;
if( bIsLastBPMSegment ) if( bIsLastBPMSegment )
{ {
fElapsedTime += fBeat / fBPS; fElapsedTime += NoteRowToBeat( iRow ) / fBPS;
} }
else else
{ {
const int iStartIndexThisSegment = m_BPMSegments[i].m_iStartIndex; const int iStartIndexThisSegment = m_BPMSegments[i].m_iStartIndex;
const float fStartBeatThisSegment = NoteRowToBeat( iStartIndexThisSegment );
const int iStartIndexNextSegment = m_BPMSegments[i+1].m_iStartIndex; const int iStartIndexNextSegment = m_BPMSegments[i+1].m_iStartIndex;
const float fStartBeatNextSegment = NoteRowToBeat( iStartIndexNextSegment ); const int iRowsInThisSegment = min( iStartIndexNextSegment - iStartIndexThisSegment, iRow );
const float fBeatsInThisSegment = fStartBeatNextSegment - fStartBeatThisSegment; fElapsedTime += NoteRowToBeat( iRowsInThisSegment ) / fBPS;
fElapsedTime += min(fBeat, fBeatsInThisSegment) / fBPS; iRow -= iRowsInThisSegment;
fBeat -= fBeatsInThisSegment;
} }
if( fBeat <= 0 ) if( iRow <= 0 )
return fElapsedTime; return fElapsedTime;
} }
+3 -3
View File
@@ -7,10 +7,10 @@
struct BPMSegment struct BPMSegment
{ {
BPMSegment() { m_iStartIndex = -1; m_iBPS = -1; } BPMSegment() { m_iStartIndex = -1; m_fBPS = -1; }
BPMSegment( int s, int b ) { m_iStartIndex = s; m_iBPS = b; } BPMSegment( int s, float b ) { m_iStartIndex = s; m_fBPS = b/60.0f; }
int m_iStartIndex; int m_iStartIndex;
int m_iBPS; /* rows per second */ float m_fBPS;
void SetBPM( float f ); void SetBPM( float f );
float GetBPM() const; float GetBPM() const;