use MAX_NOTE_ROW, fixes

This commit is contained in:
Glenn Maynard
2005-01-22 19:18:42 +00:00
parent 4fbcbdf77c
commit cd9b66220a
3 changed files with 18 additions and 39 deletions
+4 -24
View File
@@ -332,7 +332,7 @@ int NoteData::GetLastRow() const
for( int t=0; t < GetNumTracks(); t++ )
{
int iRow = 999999999;
int iRow = MAX_NOTE_ROW;
if( !GetPrevTapNoteRowForTrack( t, iRow ) )
continue;
iOldestRowFoundSoFar = max( iOldestRowFoundSoFar, iRow );
@@ -349,9 +349,6 @@ int NoteData::GetLastRow() const
int NoteData::GetNumTapNotes( int iStartIndex, int iEndIndex ) const
{
if( iEndIndex == -1 )
iEndIndex = 999999;
int iNumNotes = 0;
for( int t=0; t<GetNumTracks(); t++ )
{
@@ -368,9 +365,6 @@ int NoteData::GetNumTapNotes( int iStartIndex, int iEndIndex ) const
int NoteData::GetNumRowsWithTap( int iStartIndex, int iEndIndex ) const
{
if( iEndIndex == -1 )
iEndIndex = 999999;
int iNumNotes = 0;
FOREACH_NONEMPTY_ROW_ALL_TRACKS_RANGE( *this, r, iStartIndex, iEndIndex )
if( IsThereATapAtRow(r) )
@@ -381,9 +375,6 @@ int NoteData::GetNumRowsWithTap( int iStartIndex, int iEndIndex ) const
int NoteData::GetNumMines( int iStartIndex, int iEndIndex ) const
{
if( iEndIndex == -1 )
iEndIndex = 999999;
int iNumMines = 0;
for( int t=0; t<GetNumTracks(); t++ )
@@ -398,9 +389,6 @@ int NoteData::GetNumMines( int iStartIndex, int iEndIndex ) const
int NoteData::GetNumRowsWithTapOrHoldHead( int iStartIndex, int iEndIndex ) const
{
if( iEndIndex == -1 )
iEndIndex = 999999;
int iNumNotes = 0;
FOREACH_NONEMPTY_ROW_ALL_TRACKS_RANGE( *this, r, iStartIndex, iEndIndex )
if( IsThereATapOrHoldHeadAtRow(r) )
@@ -450,9 +438,6 @@ int NoteData::GetNumHands( int iStartIndex, int iEndIndex ) const
* etc. Only count rows that have at least one tap note (hold heads count).
* Otherwise, every row of hold notes counts, so three simultaneous hold
* notes will count as hundreds of "hands". */
if( iEndIndex == -1 )
iEndIndex = 999999;
int iNum = 0;
FOREACH_NONEMPTY_ROW_ALL_TRACKS_RANGE( *this, r, iStartIndex, iEndIndex )
{
@@ -467,9 +452,6 @@ int NoteData::GetNumHands( int iStartIndex, int iEndIndex ) const
int NoteData::GetNumN( int iMinTaps, int iStartIndex, int iEndIndex ) const
{
if( iEndIndex == -1 )
iEndIndex = 999999;
int iNum = 0;
FOREACH_NONEMPTY_ROW_ALL_TRACKS_RANGE( *this, r, iStartIndex, iEndIndex )
{
@@ -489,9 +471,6 @@ int NoteData::GetNumN( int iMinTaps, int iStartIndex, int iEndIndex ) const
int NoteData::GetNumHoldNotes( int iStartIndex, int iEndIndex ) const
{
if( iEndIndex == -1 )
iEndIndex = GetLastRow();
int iNumHolds = 0;
for( int i=0; i<GetNumHoldNotes(); i++ )
{
@@ -517,7 +496,7 @@ void NoteData::Convert2sAnd3sToHoldNotes()
SetTapNote(t, r, TAP_EMPTY); // clear the hold head marker
// search for end of HoldNote
FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE( *this, t, j, r+1, 999999 )
FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE( *this, t, j, r+1, MAX_NOTE_ROW )
{
// End hold on the next note we see. This should be a hold_tail if the
// data is in a consistent state, but doesn't have to be.
@@ -749,7 +728,7 @@ void NoteData::GetTapNoteRange( int iTrack, int iStartRow, int iEndRow, TrackMap
bool NoteData::GetNextTapNoteRowForAllTracks( int &rowInOut ) const
{
int iClosestNextRow = 999999;
int iClosestNextRow = MAX_NOTE_ROW;
bool bAnyHaveNextNote = false;
for( int t=0; t<GetNumTracks(); t++ )
{
@@ -757,6 +736,7 @@ bool NoteData::GetNextTapNoteRowForAllTracks( int &rowInOut ) const
if( GetNextTapNoteRowForTrack( t, iNewRowThisTrack ) )
{
bAnyHaveNextNote = true;
ASSERT( iNewRowThisTrack < MAX_NOTE_ROW );
iClosestNextRow = min( iClosestNextRow, iNewRowThisTrack );
}
}
+8 -8
View File
@@ -115,16 +115,16 @@ public:
float GetFirstBeat() const { return NoteRowToBeat( GetFirstRow() ); }
int GetLastRow() const; // return the beat number of the last note
float GetLastBeat() const { return NoteRowToBeat( GetLastRow() ); }
int GetNumTapNotes( int iStartIndex = 0, int iEndIndex = -1 ) const;
int GetNumMines( int iStartIndex = 0, int iEndIndex = -1 ) const;
int GetNumHands( int iStartIndex = 0, int iEndIndex = -1 ) const;
int GetNumRowsWithTap( int iStartIndex = 0, int iEndIndex = -1 ) const;
int GetNumRowsWithTapOrHoldHead( int iStartIndex = 0, int iEndIndex = -1 ) const;
int GetNumN( int iMinTaps, int iStartIndex = 0, int iEndIndex = -1 ) const;
int GetNumTapNotes( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumMines( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumHands( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumRowsWithTap( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumRowsWithTapOrHoldHead( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumN( int iMinTaps, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const;
// should hands also count as a jump?
int GetNumDoubles( int iStartIndex = 0, int iEndIndex = -1 ) const { return GetNumN( 2, iStartIndex, iEndIndex ); }
int GetNumDoubles( int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) const { return GetNumN( 2, iStartIndex, iEndIndex ); }
/* optimization: for the default of start to end, use the second (faster) */
int GetNumHoldNotes( const int iStartIndex, const int iEndIndex = -1 ) const;
int GetNumHoldNotes( const int iStartIndex, const int iEndIndex = MAX_NOTE_ROW ) const;
int GetNumHoldNotes() const { return m_HoldNotes.size(); }
int RowNeedsHands( int row ) const;
+6 -7
View File
@@ -21,7 +21,8 @@ NoteType NoteDataUtil::GetSmallestNoteTypeForMeasure( const NoteData &n, int iMe
int iRowSpacing = int(roundf( fBeatSpacing * ROWS_PER_BEAT ));
bool bFoundSmallerNote = false;
for( int i=iMeasureStartIndex; i<=iMeasureLastIndex; i++ ) // for each index in this measure
// for each index in this measure
FOREACH_NONEMPTY_ROW_ALL_TRACKS_RANGE( n, i, iMeasureStartIndex, iMeasureLastIndex )
{
if( i % iRowSpacing == 0 )
continue; // skip
@@ -209,7 +210,8 @@ void NoteDataUtil::GetSMNoteDataString( const NoteData &in_, CString &notes_out
iRowSpacing = 1;
else
iRowSpacing = int(roundf( NoteTypeToBeat(nt) * ROWS_PER_BEAT ));
// (verify first)
// iRowSpacing = BeatToNoteRow( NoteTypeToBeat(nt) );
sRet += ssprintf(" // measure %d\n", m+1);
const int iMeasureStartRow = m * ROWS_PER_MEASURE;
@@ -274,10 +276,8 @@ void NoteDataUtil::LoadTransformedSlidingWindow( const NoteData &in, NoteData &o
int iTrackOffsetMax = abs( iNewNumTracks - Original.GetNumTracks() );
int bOffsetIncreasing = true;
int iLastRow = Original.GetLastRow();
int iLastMeasure = 0;
for( int r=0; r<=iLastRow; )
FOREACH_NONEMPTY_ROW_ALL_TRACKS( Original, r )
{
// copy notes in this measure
for( int t=0; t<Original.GetNumTracks(); t++ )
@@ -287,9 +287,8 @@ void NoteDataUtil::LoadTransformedSlidingWindow( const NoteData &in, NoteData &o
const TapNote &tn = Original.GetTapNote( iOldTrack, r );
out.SetTapNote( iNewTrack, r, tn );
}
r++;
const int iMeasure = r / ROWS_PER_MEASURE;
const int iMeasure = (r+1) / ROWS_PER_MEASURE;
if( iMeasure / 4 != iLastMeasure / 4 ) // adjust sliding window every 4 measures
{
// See if there is a hold crossing the beginning of this measure