fix "can't lay holds longer than 1 snap value in record"

This commit is contained in:
Chris Danford
2005-04-07 19:30:40 +00:00
parent 3d8c3c8dd5
commit 2a9bd36813
+8 -17
View File
@@ -298,32 +298,23 @@ void NoteData::AddHoldNote( int iTrack, int iStartRow, int iEndRow, TapNote tn )
ASSERT( iStartRow>=0 && iEndRow>=0 ); ASSERT( iStartRow>=0 && iEndRow>=0 );
ASSERT( iEndRow >= iStartRow ); ASSERT( iEndRow >= iStartRow );
tn.iDuration = iEndRow - iStartRow;
/* Include adjacent (non-overlapping) hold notes, since we need to merge with them. */ /* Include adjacent (non-overlapping) hold notes, since we need to merge with them. */
iterator begin, end; iterator begin, end;
GetTapNoteRangeInclusive( iTrack, iStartRow, iStartRow+tn.iDuration, begin, end, true ); GetTapNoteRangeInclusive( iTrack, iStartRow, iEndRow, begin, end, true );
/* Look for other hold notes that overlap and merge them into add. */ /* Look for other hold notes that overlap and merge them into add. */
for( iterator it = begin; it != end; ++it ) for( iterator it = begin; it != end; ++it )
{ {
int iRow = it->first; int iOtherRow = it->first;
if( it->second.type == TapNote::hold_head ) const TapNote &tnOther = it->second;
if( tnOther.type == TapNote::hold_head )
{ {
if( iRow < iStartRow ) iStartRow = min( iStartRow, iOtherRow );
{ iEndRow = max( iEndRow, iOtherRow + tnOther.iDuration );
/* extend tn up */
int iExtendBy = iStartRow - iRow;
tn.iDuration += iExtendBy;
iStartRow -= iExtendBy;
} }
else }
{
/* extend tn down */
int iEndRow = iRow + it->second.iDuration;
tn.iDuration = iEndRow - iStartRow; tn.iDuration = iEndRow - iStartRow;
}
}
}
/* Remove everything in the range. */ /* Remove everything in the range. */
while( begin != end ) while( begin != end )