diff --git a/stepmania/src/NoteData.cpp b/stepmania/src/NoteData.cpp index e3e79d143a..a87ce7a420 100644 --- a/stepmania/src/NoteData.cpp +++ b/stepmania/src/NoteData.cpp @@ -197,12 +197,12 @@ float NoteData::GetFirstBeat() return fEarliestBeatFoundSoFar; } -int NoteData::GetLastRow() +int NoteData::GetLastRow() const { return BeatToNoteRow( GetLastBeat() ); } -float NoteData::GetLastBeat() +float NoteData::GetLastBeat() const { float fOldestBeatFoundSoFar = 0; @@ -226,7 +226,7 @@ float NoteData::GetLastBeat() return fOldestBeatFoundSoFar; } -int NoteData::GetNumTapNotes( const float fStartBeat, const float fEndBeat ) +int NoteData::GetNumTapNotes( const float fStartBeat, const float fEndBeat ) const { int iNumNotes = 0; @@ -243,7 +243,7 @@ int NoteData::GetNumTapNotes( const float fStartBeat, const float fEndBeat ) return iNumNotes; } -int NoteData::GetNumDoubles( const float fStartBeat, const float fEndBeat ) +int NoteData::GetNumDoubles( const float fStartBeat, const float fEndBeat ) const { int iNumDoubles = 0; @@ -265,7 +265,7 @@ int NoteData::GetNumDoubles( const float fStartBeat, const float fEndBeat ) return iNumDoubles; } -int NoteData::GetNumHoldNotes( const float fStartBeat, const float fEndBeat ) +int NoteData::GetNumHoldNotes( const float fStartBeat, const float fEndBeat ) const { int iNumHolds = 0; @@ -296,70 +296,6 @@ int NoteData::GetPossibleDancePoints() GetNumHoldNotes()*HoldNoteScoreToDancePoints(HNS_OK); } -void NoteData::CropToLeftSide() -{ - int iFirstRightSideColumn = 4; - int iLastRightSideColumn = 7; - - // clear out the right half - int c; - for( c=iFirstRightSideColumn; c<=iLastRightSideColumn; c++ ) - { - for( int i=0; i=0; i-- ) // foreach HoldNote - { - if( c >= iFirstRightSideColumn ) - { - // delete this HoldNote - m_HoldNotes.erase(m_HoldNotes.begin()+i, m_HoldNotes.begin()+i+1); - } - } -} - - -void NoteData::CropToRightSide() -{ - int iFirstRightSideColumn = 4; - int iLastRightSideColumn = 7; - - int c; - - // clear out the left half - for( c=0; c=0; i-- ) // foreach HoldNote - { - HoldNote &hn = GetHoldNote(i); - - if( hn.m_iTrack < iFirstRightSideColumn ) - { - // delete this HoldNote by shifting everything down - RemoveHoldNote( i ); - } - else - { - hn.m_iTrack -= 4; - } - } -} - void NoteData::RemoveHoldNotes() { // turn all the HoldNotes into TapNotes @@ -727,66 +663,6 @@ void NoteData::SnapToNearestNoteType( NoteType nt1, NoteType nt2, float fBeginBe } -float NoteData::GetStreamRadarValue( float fSongSeconds ) -{ - // density of steps - int iNumNotes = GetNumTapNotes() + GetNumHoldNotes(); - float fNotesPerSecond = iNumNotes/fSongSeconds; - float fReturn = fNotesPerSecond / 7; - return min( fReturn, 1.0f ); -} - -float NoteData::GetVoltageRadarValue( float fSongSeconds ) -{ - float fAvgBPS = GetLastBeat() / fSongSeconds; - - // peak density of steps - float fMaxDensitySoFar = 0; - - const int BEAT_WINDOW = 8; - - for( int i=0; i= NOTE_TYPE_12TH ) - iNumChaosNotes++; - } - - float fReturn = iNumChaosNotes / fSongSeconds * 0.5f; - return min( fReturn, 1.0f ); -} - -float NoteData::GetFreezeRadarValue( float fSongSeconds ) -{ - // number of hold steps - float fReturn = GetNumHoldNotes() / fSongSeconds; - return min( fReturn, 1.0f ); -} - - // -1 for iOriginalTracksToTakeFrom means no track void NoteData::LoadTransformed( NoteData* pOriginal, int iNewNumTracks, const int iOriginalTrackToTakeFrom[] ) { @@ -1144,3 +1020,75 @@ CString NoteDataUtil::GetSMNoteDataString(NoteData &in) return join( "\n,", asMeasureStrings ); } + +float NoteDataUtil::GetRadarValue( const NoteData &in, RadarCategory rv, float fSongSeconds ) +{ + switch( rv ) + { + case RADAR_STREAM: return GetStreamRadarValue( in, fSongSeconds ); + case RADAR_VOLTAGE: return GetVoltageRadarValue( in, fSongSeconds ); + case RADAR_AIR: return GetAirRadarValue( in, fSongSeconds ); + case RADAR_FREEZE: return GetFreezeRadarValue( in, fSongSeconds ); + case RADAR_CHAOS: return GetChaosRadarValue( in, fSongSeconds ); + default: ASSERT(0); return 0; + } +} + +float NoteDataUtil::GetStreamRadarValue( const NoteData &in, float fSongSeconds ) +{ + // density of steps + int iNumNotes = in.GetNumTapNotes() + in.GetNumHoldNotes(); + float fNotesPerSecond = iNumNotes/fSongSeconds; + float fReturn = fNotesPerSecond / 7; + return min( fReturn, 1.0f ); +} + +float NoteDataUtil::GetVoltageRadarValue( const NoteData &in, float fSongSeconds ) +{ + float fAvgBPS = in.GetLastBeat() / fSongSeconds; + + // peak density of steps + float fMaxDensitySoFar = 0; + + const int BEAT_WINDOW = 8; + + for( int i=0; i= NOTE_TYPE_12TH ) + iNumChaosNotes++; + } + + float fReturn = iNumChaosNotes / fSongSeconds * 0.5f; + return min( fReturn, 1.0f ); +} diff --git a/stepmania/src/NoteData.h b/stepmania/src/NoteData.h index dbe0691bd1..92101edd34 100644 --- a/stepmania/src/NoteData.h +++ b/stepmania/src/NoteData.h @@ -85,42 +85,20 @@ public: float GetFirstBeat(); // return the beat number of the first note int GetFirstRow(); - float GetLastBeat(); // return the beat number of the last note - int GetLastRow(); - int GetNumTapNotes( const float fStartBeat = 0, const float fEndBeat = MAX_BEATS ); - int GetNumDoubles( const float fStartBeat = 0, const float fEndBeat = MAX_BEATS ); + float GetLastBeat() const; // return the beat number of the last note + int GetLastRow() const; + int GetNumTapNotes( const float fStartBeat = 0, const float fEndBeat = MAX_BEATS ) const; + int GetNumDoubles( const float fStartBeat = 0, const float fEndBeat = MAX_BEATS ) const; /* optimization: for the default of start to end, use the second (faster) */ - int GetNumHoldNotes( const float fStartBeat, const float fEndBeat = MAX_BEATS ); + int GetNumHoldNotes( const float fStartBeat, const float fEndBeat = MAX_BEATS ) const; int GetNumHoldNotes() const { return m_HoldNotes.size(); } int GetPossibleDancePoints(); - // radar values - return between 0.0 and 1.2 - float GetRadarValue( RadarCategory rv, float fSongSeconds ) - { - switch( rv ) - { - case RADAR_STREAM: return GetStreamRadarValue( fSongSeconds ); break; - case RADAR_VOLTAGE: return GetVoltageRadarValue( fSongSeconds ); break; - case RADAR_AIR: return GetAirRadarValue( fSongSeconds ); break; - case RADAR_FREEZE: return GetFreezeRadarValue( fSongSeconds ); break; - case RADAR_CHAOS: return GetChaosRadarValue( fSongSeconds ); break; - default: ASSERT(0); return 0; - } - }; - float GetStreamRadarValue( float fSongSeconds ); - float GetVoltageRadarValue( float fSongSeconds ); - float GetAirRadarValue( float fSongSeconds ); - float GetFreezeRadarValue( float fSongSeconds ); - float GetChaosRadarValue( float fSongSeconds ); - // Transformations void LoadTransformed( NoteData* pOriginal, int iNewNumTracks, const int iOriginalTrackToTakeFrom[] ); // -1 for iOriginalTracksToTakeFrom means no track void LoadTransformedSlidingWindow( NoteData* pOriginal, int iNewNumTracks ); // used by autogen - - void CropToLeftSide(); - void CropToRightSide(); void RemoveHoldNotes(); void Turn( PlayerOptions::TurnType tt ); void MakeLittle(); @@ -145,6 +123,15 @@ namespace NoteDataUtil NoteType GetSmallestNoteTypeForMeasure( const NoteData &n, int iMeasureIndex ); void LoadFromSMNoteDataString( NoteData &out, CString sSMNoteData ); CString GetSMNoteDataString(NoteData &in); + + float GetStreamRadarValue( const NoteData &in, float fSongSeconds ); + float GetVoltageRadarValue( const NoteData &in, float fSongSeconds ); + float GetAirRadarValue( const NoteData &in, float fSongSeconds ); + float GetFreezeRadarValue( const NoteData &in, float fSongSeconds ); + float GetChaosRadarValue( const NoteData &in, float fSongSeconds ); + + // radar values - return between 0.0 and 1.2 + float GetRadarValue( const NoteData &in, RadarCategory rv, float fSongSeconds ); }; #endif diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 7336b2cf02..55342e4c0c 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -1153,7 +1153,7 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) for( int r=0; rm_fRadarPossible[p][r] = m_Player[p].GetRadarValue( rc, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds ); + GAMESTATE->m_fRadarPossible[p][r] = NoteDataUtil::GetRadarValue( m_Player[p], rc, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds ); GAMESTATE->m_fRadarActual[p][r] = m_Player[p].GetActualRadarValue( rc, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds ); } } diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index dba4810fa9..3d3dfaf52a 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -563,7 +563,7 @@ void Song::ReCalulateRadarValuesAndLastBeat() pNotes->GetNoteData( &tempNoteData ); for( int r=0; rm_fRadarValues[r] = tempNoteData.GetRadarValue( (RadarCategory)r, m_fMusicLengthSeconds ); + pNotes->m_fRadarValues[r] = NoteDataUtil::GetRadarValue( tempNoteData, (RadarCategory)r, m_fMusicLengthSeconds ); float fFirstBeat = tempNoteData.GetFirstBeat(); float fLastBeat = tempNoteData.GetLastBeat();