Fix up editing hold notes.
This commit is contained in:
+60
-33
@@ -133,39 +133,19 @@ CString NoteData::GetSMNoteDataString()
|
|||||||
return join( "\n,", asMeasureStrings );
|
return join( "\n,", asMeasureStrings );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NoteData::ClearRange( int iNoteIndexBegin, int iNoteIndexEnd )
|
void NoteData::ClearRange( int iNoteIndexBegin, int iNoteIndexEnd )
|
||||||
{
|
{
|
||||||
// delete old TapNotes in the range
|
this->ConvertHoldNotesTo4s();
|
||||||
for( int i=iNoteIndexBegin; i<=iNoteIndexEnd; i++ )
|
|
||||||
{
|
|
||||||
for( int c=0; c<m_iNumTracks; c++ )
|
for( int c=0; c<m_iNumTracks; c++ )
|
||||||
|
{
|
||||||
|
for( int i=iNoteIndexBegin; i<=iNoteIndexEnd; i++ )
|
||||||
m_TapNotes[c][i] = '0';
|
m_TapNotes[c][i] = '0';
|
||||||
}
|
}
|
||||||
|
this->Convert4sToHoldNotes();
|
||||||
// delete old HoldNotes in the range
|
|
||||||
int iIndexRead, iIndexWrite = 0;
|
|
||||||
const int iOrigNumHoldNotes = m_iNumHoldNotes;
|
|
||||||
for( iIndexRead = 0; iIndexRead < iOrigNumHoldNotes; iIndexRead++ )
|
|
||||||
{
|
|
||||||
HoldNote &hn = m_HoldNotes[iIndexRead];
|
|
||||||
int iHoldStartIndex = BeatToNoteRow( hn.m_fStartBeat );
|
|
||||||
int iHoldEndIndex = BeatToNoteRow( hn.m_fEndBeat );
|
|
||||||
if( (iHoldStartIndex >= iNoteIndexBegin && iHoldStartIndex <= iNoteIndexEnd) ||
|
|
||||||
(iHoldEndIndex >= iNoteIndexBegin && iHoldEndIndex <= iNoteIndexEnd) ) // overlap (kinda)
|
|
||||||
{
|
|
||||||
; // do nothing
|
|
||||||
}
|
|
||||||
else // ! overlap
|
|
||||||
{
|
|
||||||
m_HoldNotes[iIndexWrite] = m_HoldNotes[iIndexRead];
|
|
||||||
iIndexWrite++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_iNumHoldNotes = iIndexWrite;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Copy a range from pFrom to this. (Note that this does *not* overlay;
|
||||||
|
* all data in the range is overwritten.) */
|
||||||
void NoteData::CopyRange( NoteData* pFrom, int iFromIndexBegin, int iFromIndexEnd, int iToIndexBegin )
|
void NoteData::CopyRange( NoteData* pFrom, int iFromIndexBegin, int iFromIndexEnd, int iToIndexBegin )
|
||||||
{
|
{
|
||||||
ASSERT( pFrom->m_iNumTracks == m_iNumTracks );
|
ASSERT( pFrom->m_iNumTracks == m_iNumTracks );
|
||||||
@@ -173,13 +153,11 @@ void NoteData::CopyRange( NoteData* pFrom, int iFromIndexBegin, int iFromIndexEn
|
|||||||
if( iToIndexBegin == -1 )
|
if( iToIndexBegin == -1 )
|
||||||
iToIndexBegin = 0;
|
iToIndexBegin = 0;
|
||||||
|
|
||||||
pFrom->ConvertHoldNotesTo2sAnd3s();
|
pFrom->ConvertHoldNotesTo4s();
|
||||||
|
this->ConvertHoldNotesTo4s();
|
||||||
int f, t;
|
|
||||||
|
|
||||||
// copy recorded TapNotes
|
// copy recorded TapNotes
|
||||||
f = iFromIndexBegin;
|
int f = iFromIndexBegin, t = iToIndexBegin;
|
||||||
t = iToIndexBegin;
|
|
||||||
|
|
||||||
while( f<=iFromIndexEnd )
|
while( f<=iFromIndexEnd )
|
||||||
{
|
{
|
||||||
@@ -189,8 +167,8 @@ void NoteData::CopyRange( NoteData* pFrom, int iFromIndexBegin, int iFromIndexEn
|
|||||||
t++;
|
t++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFrom->Convert2sAnd3sToHoldNotes();
|
pFrom->Convert4sToHoldNotes();
|
||||||
this->Convert2sAnd3sToHoldNotes();
|
this->Convert4sToHoldNotes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NoteData::AddHoldNote( HoldNote add )
|
void NoteData::AddHoldNote( HoldNote add )
|
||||||
@@ -596,6 +574,10 @@ void NoteData::MakeLittle()
|
|||||||
// leave HoldNotes unchanged (what should be do with them?)
|
// leave HoldNotes unchanged (what should be do with them?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ConvertHoldNotesTo2sAnd3s also clears m_iNumHoldNotes;
|
||||||
|
* shouldn't this do likewise and set all 2/3's to 0?
|
||||||
|
* -glenn
|
||||||
|
*/
|
||||||
void NoteData::Convert2sAnd3sToHoldNotes()
|
void NoteData::Convert2sAnd3sToHoldNotes()
|
||||||
{
|
{
|
||||||
// Any note will end a hold (not just a '3'). This makes parsing DWIs much easier,
|
// Any note will end a hold (not just a '3'). This makes parsing DWIs much easier,
|
||||||
@@ -621,6 +603,8 @@ void NoteData::Convert2sAnd3sToHoldNotes()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* "102000301" ==
|
||||||
|
* "104444001" */
|
||||||
void NoteData::ConvertHoldNotesTo2sAnd3s()
|
void NoteData::ConvertHoldNotesTo2sAnd3s()
|
||||||
{
|
{
|
||||||
// copy HoldNotes into the new structure, but expand them into 2s and 3s
|
// copy HoldNotes into the new structure, but expand them into 2s and 3s
|
||||||
@@ -635,6 +619,49 @@ void NoteData::ConvertHoldNotesTo2sAnd3s()
|
|||||||
m_iNumHoldNotes = 0;
|
m_iNumHoldNotes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* "104444001" ==
|
||||||
|
* "102000301"
|
||||||
|
*
|
||||||
|
* "4441" basically means "hold for three rows then hold for another tap";
|
||||||
|
* since taps don't really have a length, it's equivalent to "4440".
|
||||||
|
* So, make sure the character after a 4 is always a 0. */
|
||||||
|
void NoteData::Convert4sToHoldNotes()
|
||||||
|
{
|
||||||
|
for( int col=0; col<m_iNumTracks; col++ ) // foreach column
|
||||||
|
{
|
||||||
|
for( int i=0; i<MAX_TAP_NOTE_ROWS; i++ ) // foreach TapNote element
|
||||||
|
{
|
||||||
|
if( m_TapNotes[col][i] != '4' ) // this is a HoldNote begin marker
|
||||||
|
continue;
|
||||||
|
|
||||||
|
HoldNote hn = { col, NoteRowToBeat(i), 0 };
|
||||||
|
// search for end of HoldNote
|
||||||
|
do {
|
||||||
|
m_TapNotes[col][i] = '0';
|
||||||
|
i++;
|
||||||
|
} while( i<MAX_TAP_NOTE_ROWS && m_TapNotes[col][i] == '4');
|
||||||
|
m_TapNotes[col][i] = '0';
|
||||||
|
|
||||||
|
hn.m_fEndBeat = NoteRowToBeat(i);
|
||||||
|
AddHoldNote( hn );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NoteData::ConvertHoldNotesTo4s()
|
||||||
|
{
|
||||||
|
// copy HoldNotes into the new structure, but expand them into 4s
|
||||||
|
for( int i=0; i<m_iNumHoldNotes; i++ )
|
||||||
|
{
|
||||||
|
HoldNote &hn = m_HoldNotes[i];
|
||||||
|
int iHoldStartIndex = BeatToNoteRow(hn.m_fStartBeat);
|
||||||
|
int iHoldEndIndex = BeatToNoteRow(hn.m_fEndBeat);
|
||||||
|
for( int j = iHoldStartIndex; j < iHoldEndIndex; ++j)
|
||||||
|
m_TapNotes[hn.m_iTrack][j] = '4';
|
||||||
|
}
|
||||||
|
m_iNumHoldNotes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void NoteData::SnapToNearestNoteType( NoteType nt1, NoteType nt2, float fBeginBeat, float fEndBeat )
|
void NoteData::SnapToNearestNoteType( NoteType nt1, NoteType nt2, float fBeginBeat, float fEndBeat )
|
||||||
{
|
{
|
||||||
// nt2 is optional and should be -1 if it is not used
|
// nt2 is optional and should be -1 if it is not used
|
||||||
|
|||||||
@@ -104,5 +104,7 @@ public:
|
|||||||
void Convert2sAnd3sToHoldNotes();
|
void Convert2sAnd3sToHoldNotes();
|
||||||
void ConvertHoldNotesTo2sAnd3s();
|
void ConvertHoldNotesTo2sAnd3s();
|
||||||
|
|
||||||
|
void Convert4sToHoldNotes();
|
||||||
|
void ConvertHoldNotesTo4s();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -525,7 +525,8 @@ bool Notes::LoadFromDWITokens(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pNoteData->Convert2sAnd3sToHoldNotes(); // this will expand the HoldNote begin markers we wrote into actual HoldNotes
|
// this will expand the HoldNote begin markers we wrote into actual HoldNotes
|
||||||
|
pNoteData->Convert2sAnd3sToHoldNotes();
|
||||||
|
|
||||||
ASSERT( pNoteData->m_iNumTracks > 0 );
|
ASSERT( pNoteData->m_iNumTracks > 0 );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user