Time Signatures, the other big one. :D
This commit is contained in:
@@ -119,112 +119,6 @@ struct StopSegment
|
||||
bool operator>=( const StopSegment &other ) const { return !operator<(other); }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Identifies when a song changes its time signature.
|
||||
*
|
||||
* This only supports simple time signatures. The upper number (called the numerator here, though this isn't
|
||||
* properly a fraction) is the number of beats per measure. The lower number (denominator here)
|
||||
* is the note value representing one beat. */
|
||||
struct TimeSignatureSegment
|
||||
{
|
||||
/**
|
||||
* @brief Creates a simple Time Signature Segment with default values.
|
||||
*/
|
||||
TimeSignatureSegment() : m_iStartRow(-1), m_iNumerator(4), m_iDenominator(4) { }
|
||||
/**
|
||||
* @brief Creates a Time Signature Segment at the given row with a supplied numerator.
|
||||
*
|
||||
* The denominator will be 4 if this is called.
|
||||
* @param r the starting row of the segment.
|
||||
* @param n the numerator for the segment.
|
||||
*/
|
||||
TimeSignatureSegment( int r, int n ): m_iStartRow(max(0, r)),
|
||||
m_iNumerator(max(1, n)), m_iDenominator(4) {}
|
||||
/**
|
||||
* @brief Creates a Time Signature Segment at the given row with a supplied numerator & denominator.
|
||||
* @param r the starting row of the segment.
|
||||
* @param n the numerator for the segment.
|
||||
* @param d the denonimator for the segment.
|
||||
*/
|
||||
TimeSignatureSegment( int r, int n, int d ): m_iStartRow(max(0, r)),
|
||||
m_iNumerator(max(1, n)), m_iDenominator(max(1, d)) {}
|
||||
/**
|
||||
* @brief The row in which the TimeSignatureSegment activates.
|
||||
*/
|
||||
int m_iStartRow;
|
||||
/**
|
||||
* @brief The numerator of the TimeSignatureSegment.
|
||||
*/
|
||||
int m_iNumerator;
|
||||
/**
|
||||
* @brief The denominator of the TimeSignatureSegment.
|
||||
*/
|
||||
int m_iDenominator;
|
||||
|
||||
/**
|
||||
* @brief Retrieve the number of note rows per measure within the TimeSignatureSegment.
|
||||
*
|
||||
* With BeatToNoteRow(1) rows per beat, then we should have BeatToNoteRow(1)*m_iNumerator
|
||||
* beats per measure. But if we assume that every BeatToNoteRow(1) rows is a quarter note,
|
||||
* and we want the beats to be 1/m_iDenominator notes, then we should have
|
||||
* BeatToNoteRow(1)*4 is rows per whole note and thus BeatToNoteRow(1)*4/m_iDenominator is
|
||||
* rows per beat. Multiplying by m_iNumerator gives rows per measure.
|
||||
* @returns the number of note rows per measure.
|
||||
*/
|
||||
int GetNoteRowsPerMeasure() const { return BeatToNoteRow(1) * 4 * m_iNumerator / m_iDenominator; }
|
||||
/**
|
||||
* @brief Compares two TimeSignatureSegments to see if they are equal to each other.
|
||||
* @param other the other TimeSignatureSegment to compare to.
|
||||
* @return the equality of the two segments.
|
||||
*/
|
||||
bool operator==( const TimeSignatureSegment &other ) const
|
||||
{
|
||||
COMPARE( m_iStartRow );
|
||||
COMPARE( m_iNumerator );
|
||||
COMPARE( m_iDenominator );
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* @brief Compares two TimeSignatureSegments to see if they are not equal to each other.
|
||||
* @param other the other TimeSignatureSegment to compare to.
|
||||
* @return the inequality of the two segments.
|
||||
*/
|
||||
bool operator!=( const TimeSignatureSegment &other ) const { return !operator==(other); }
|
||||
/**
|
||||
* @brief Compares two TimeSignatureSegments to see if one is less than the other.
|
||||
* @param other the other TimeSignatureSegment to compare to.
|
||||
* @return the truth/falsehood of if the first is less than the second.
|
||||
*/
|
||||
bool operator<( const TimeSignatureSegment &other ) const
|
||||
{
|
||||
return m_iStartRow < other.m_iStartRow ||
|
||||
( m_iStartRow == other.m_iStartRow &&
|
||||
( m_iNumerator < other.m_iNumerator ||
|
||||
( m_iNumerator == other.m_iNumerator && m_iDenominator < other.m_iDenominator )));
|
||||
}
|
||||
/**
|
||||
* @brief Compares two TimeSignatureSegments to see if one is less than or equal to the other.
|
||||
* @param other the other TimeSignatureSegment to compare to.
|
||||
* @return the truth/falsehood of if the first is less or equal to than the second.
|
||||
*/
|
||||
bool operator<=( const TimeSignatureSegment &other ) const
|
||||
{
|
||||
return ( operator<(other) || operator==(other) );
|
||||
}
|
||||
/**
|
||||
* @brief Compares two TimeSignatureSegments to see if one is greater than the other.
|
||||
* @param other the other TimeSignatureSegment to compare to.
|
||||
* @return the truth/falsehood of if the first is greater than the second.
|
||||
*/
|
||||
bool operator>( const TimeSignatureSegment &other ) const { return !operator<=(other); }
|
||||
/**
|
||||
* @brief Compares two TimeSignatureSegments to see if one is greater than or equal to the other.
|
||||
* @param other the other TimeSignatureSegment to compare to.
|
||||
* @return the truth/falsehood of if the first is greater than or equal to the second.
|
||||
*/
|
||||
bool operator>= (const TimeSignatureSegment &other ) const { return !operator<(other); }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Identifies when the arrow scroll changes.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user