Optimize LoadTransformedSlidingWindow a bit.

Const fixes.
This commit is contained in:
Glenn Maynard
2002-12-14 20:27:52 +00:00
parent d8fde44063
commit 2b16fbc4a3
2 changed files with 12 additions and 25 deletions
+10 -23
View File
@@ -165,12 +165,12 @@ bool NoteData::IsThereANoteAtRow( int iRow ) const
} }
int NoteData::GetFirstRow() int NoteData::GetFirstRow() const
{ {
return BeatToNoteRow( GetFirstBeat() ); return BeatToNoteRow( GetFirstBeat() );
} }
float NoteData::GetFirstBeat() float NoteData::GetFirstBeat() const
{ {
float fEarliestBeatFoundSoFar = MAX_BEATS; float fEarliestBeatFoundSoFar = MAX_BEATS;
@@ -443,37 +443,25 @@ void NoteData::LoadTransformedSlidingWindow( NoteData* pOriginal, int iNewNumTra
int bOffsetIncreasing = true; int bOffsetIncreasing = true;
int iLastRow = pOriginal->GetLastRow(); int iLastRow = pOriginal->GetLastRow();
for( int r=0; r<=iLastRow; r++ ) for( int r=0; r<=iLastRow; )
{ {
// copy notes in this measure // copy notes in this measure
for( int t=0; t<pOriginal->m_iNumTracks; t++ ) for( int t=0; t<pOriginal->m_iNumTracks; t++ )
{ {
int iOldTrack = t; /* Copy a measure's worth of rows. This is an optimization; it's
int iNewTrack = (iOldTrack + iCurTrackOffset) % iNewNumTracks; * faster to copy row-wise than track-wise. */
if( pOriginal->GetTapNote(iOldTrack, r) != TAP_EMPTY ) do {
int iOldTrack = t;
int iNewTrack = (iOldTrack + iCurTrackOffset) % iNewNumTracks;
this->SetTapNote(iNewTrack, r, pOriginal->GetTapNote(iOldTrack, r)); this->SetTapNote(iNewTrack, r, pOriginal->GetTapNote(iOldTrack, r));
r++;
} while (r<=iLastRow && r % (ROWS_PER_MEASURE*4) == 0 );
} }
if( r % (ROWS_PER_MEASURE*4) == 0 ) // adjust sliding window every 4 measures if( r % (ROWS_PER_MEASURE*4) == 0 ) // adjust sliding window every 4 measures
{ {
// See if there is a hold crossing the beginning of this measure // See if there is a hold crossing the beginning of this measure
bool bHoldCrossesThisMeasure = false; bool bHoldCrossesThisMeasure = false;
#if 0
pOriginal->Convert4sToHoldNotes();
for( int i=0; i<pOriginal->GetNumHoldNotes(); i++ )
{
const HoldNote& hn = pOriginal->GEtHoldNote(i);
/* Bug here: NoteRowToBeat() may have floating point error,
* so we need to do an epsilon here. But we can do this in
* 4s easier anyway ... XXX -glenn */
if( hn.m_fStartBeat < NoteRowToBeat(r) && hn.m_fEndBeat > NoteRowToBeat(r) )
{
bHoldCrossesThisMeasure = true;
break;
}
}
pOriginal->ConvertHoldNotesTo4s();
#endif
if( r ) if( r )
for( int t=0; t<=pOriginal->m_iNumTracks; t++ ) for( int t=0; t<=pOriginal->m_iNumTracks; t++ )
@@ -501,7 +489,6 @@ void NoteData::LoadTransformedSlidingWindow( NoteData* pOriginal, int iNewNumTra
Convert4sToHoldNotes(); Convert4sToHoldNotes();
} }
void NoteData::PadTapNotes(int rows) void NoteData::PadTapNotes(int rows)
{ {
int needed = rows - m_TapNotes[0].size() + 1; int needed = rows - m_TapNotes[0].size() + 1;
+2 -2
View File
@@ -84,8 +84,8 @@ public:
// statistics // statistics
bool IsThereANoteAtRow( int iRow ) const; bool IsThereANoteAtRow( int iRow ) const;
float GetFirstBeat(); // return the beat number of the first note float GetFirstBeat() const; // return the beat number of the first note
int GetFirstRow(); int GetFirstRow() const;
float GetLastBeat() const; // return the beat number of the last note float GetLastBeat() const; // return the beat number of the last note
int GetLastRow() const; int GetLastRow() const;
int GetNumTapNotes( const float fStartBeat = 0, const float fEndBeat = MAX_BEATS ) const; int GetNumTapNotes( const float fStartBeat = 0, const float fEndBeat = MAX_BEATS ) const;