experimental time signature support. Background changes and beat bars are currently the only things that are aware of time signature. Note coloring isn't aware of time signature yet.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "Foreach.h"
|
||||
#include <float.h>
|
||||
|
||||
|
||||
TimingData::TimingData()
|
||||
{
|
||||
m_fBeat0OffsetInSeconds = 0;
|
||||
@@ -35,6 +36,11 @@ void TimingData::AddStopSegment( const StopSegment &seg )
|
||||
m_StopSegments.insert( upper_bound(m_StopSegments.begin(), m_StopSegments.end(), seg), seg );
|
||||
}
|
||||
|
||||
void TimingData::AddTimeSignatureSegment( const TimeSignatureSegment &seg )
|
||||
{
|
||||
m_vTimeSignatureSegments.insert( upper_bound(m_vTimeSignatureSegments.begin(), m_vTimeSignatureSegments.end(), seg), seg );
|
||||
}
|
||||
|
||||
/* Change an existing BPM segment, merge identical segments together or insert a new one. */
|
||||
void TimingData::SetBPMAtRow( int iNoteRow, float fBPM )
|
||||
{
|
||||
@@ -392,6 +398,41 @@ bool TimingData::HasStops() const
|
||||
return m_StopSegments.size()>0;
|
||||
}
|
||||
|
||||
void TimingData::NoteRowToMeasureAndBeat( int iNoteRow, int &iMeasureIndexOut, int &iBeatIndexOut, int &iRowsRemainder ) const
|
||||
{
|
||||
iMeasureIndexOut = 0;
|
||||
|
||||
FOREACH_CONST( TimeSignatureSegment, m_vTimeSignatureSegments, iter )
|
||||
{
|
||||
vector<TimeSignatureSegment>::const_iterator next = iter;
|
||||
next++;
|
||||
int iSegmentEndRow = (next == m_vTimeSignatureSegments.end()) ? INT_MAX : next->m_iStartRow;
|
||||
|
||||
int iRowsPerMeasureThisSegment = iter->GetNoteRowsPerMeasure();
|
||||
|
||||
if( iNoteRow >= iter->m_iStartRow )
|
||||
{
|
||||
// iNoteRow lands in this segment
|
||||
int iNumRowsThisSegment = iNoteRow - iter->m_iStartRow;
|
||||
int iNumMeasuresThisSegment = (iNumRowsThisSegment) / iRowsPerMeasureThisSegment; // don't round up
|
||||
iMeasureIndexOut += iNumMeasuresThisSegment;
|
||||
iBeatIndexOut = iNumRowsThisSegment / iRowsPerMeasureThisSegment;
|
||||
iRowsRemainder = iNumRowsThisSegment % iRowsPerMeasureThisSegment;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// iNoteRow lands after this segment
|
||||
int iNumRowsThisSegment = iSegmentEndRow - iter->m_iStartRow;
|
||||
int iNumMeasuresThisSegment = (iNumRowsThisSegment + iRowsPerMeasureThisSegment - 1) / iRowsPerMeasureThisSegment; // round up
|
||||
iMeasureIndexOut += iNumMeasuresThisSegment;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT(0);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Chris Danford, Glenn Maynard
|
||||
* All rights reserved.
|
||||
|
||||
Reference in New Issue
Block a user