Files
itgmania212121/src/TimingData.h
T

633 lines
26 KiB
C++
Raw Normal View History

2011-02-12 15:43:24 -05:00
/** @brief TimingData - Holds data for translating beats<->seconds. */
2010-01-26 21:00:30 -06:00
#ifndef TIMING_DATA_H
#define TIMING_DATA_H
#include "NoteTypes.h"
2010-05-13 12:58:20 -05:00
#include "PrefsManager.h"
2010-01-26 21:00:30 -06:00
struct lua_State;
2011-02-12 15:43:24 -05:00
/** @brief Compare a TimingData segment's properties with one another. */
2010-01-26 21:00:30 -06:00
#define COMPARE(x) if(x!=other.x) return false;
2011-02-12 15:43:24 -05:00
/**
* @brief Identifies when a song changes its BPM.
*/
2010-01-26 21:00:30 -06:00
struct BPMSegment
{
2011-02-12 15:43:24 -05:00
/**
* @brief Creates a simple BPM Segment with default values.
*
* It is best to override the values as soon as possible.
*/
2010-01-26 21:00:30 -06:00
BPMSegment() : m_iStartRow(-1), m_fBPS(-1.0f) { }
2011-02-12 15:43:24 -05:00
/**
* @brief Creates a BPM Segment with the specified starting row and beats per second.
* @param s the starting row of this segment.
* @param b the beats per second to be turned into beats per minute.
*/
2010-01-26 21:00:30 -06:00
BPMSegment( int s, float b ) { m_iStartRow = max( 0, s ); SetBPM( b ); }
2011-02-12 15:43:24 -05:00
/**
* @brief The row in which the BPMSegment activates.
*/
2010-01-26 21:00:30 -06:00
int m_iStartRow;
2011-02-12 15:43:24 -05:00
/**
* @brief The BPS to use when this row is reached.
*/
2010-01-26 21:00:30 -06:00
float m_fBPS;
2011-02-12 15:43:24 -05:00
/**
* @brief Converts the BPS to a BPM.
* @param f The BPM.
*/
2010-01-26 21:00:30 -06:00
void SetBPM( float f ) { m_fBPS = f / 60.0f; }
2011-02-12 15:43:24 -05:00
/**
* @brief Retrieves the BPM from the BPS.
* @return the BPM.
*/
2010-01-26 21:00:30 -06:00
float GetBPM() const { return m_fBPS * 60.0f; }
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two BPMSegments to see if they are equal to each other.
* @param other the other BPMSegment to compare to.
* @return the equality of the two segments.
*/
2010-01-26 21:00:30 -06:00
bool operator==( const BPMSegment &other ) const
{
COMPARE( m_iStartRow );
COMPARE( m_fBPS );
return true;
}
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two BPMSegments to see if they are not equal to each other.
* @param other the other BPMSegment to compare to.
* @return the inequality of the two segments.
*/
2010-01-26 21:00:30 -06:00
bool operator!=( const BPMSegment &other ) const { return !operator==(other); }
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two BPMSegments to see if one is less than the other.
* @param other the other BPMSegment to compare to.
* @return the truth/falsehood of if the first is less than the second.
*/
bool operator<( const BPMSegment &other ) const
{
return m_iStartRow < other.m_iStartRow ||
( m_iStartRow == other.m_iStartRow && m_fBPS < other.m_fBPS );
}
/**
* @brief Compares two BPMSegments to see if one is less than or equal to the other.
* @param other the other BPMSegment to compare to.
* @return the truth/falsehood of if the first is less or equal to than the second.
*/
2011-01-14 10:33:12 -05:00
bool operator<=( const BPMSegment &other ) const
{
return ( operator<(other) || operator==(other) );
}
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two BPMSegments to see if one is greater than the other.
* @param other the other BPMSegment to compare to.
* @return the truth/falsehood of if the first is greater than the second.
*/
bool operator>( const BPMSegment &other ) const { return !operator<=(other); }
/**
* @brief Compares two BPMSegments to see if one is greater than or equal to the other.
* @param other the other BPMSegment to compare to.
* @return the truth/falsehood of if the first is greater than or equal to the second.
*/
bool operator>=( const BPMSegment &other ) const { return !operator<(other); }
2010-01-26 21:00:30 -06:00
};
2011-02-12 15:43:24 -05:00
/**
* @brief Identifies when a song has a stop or a delay.
*
* It is hopeful that stops and delays can be made into their own segments at some point.
*/
2010-01-26 21:00:30 -06:00
struct StopSegment
{
2011-02-12 15:43:24 -05:00
/**
* @brief Creates a simple Stop Segment with default values.
*
* It is best to override the values as soon as possible.
*/
2010-01-26 21:00:30 -06:00
StopSegment() : m_iStartRow(-1), m_fStopSeconds(-1.0f), m_bDelay(false) { }
2011-02-12 15:43:24 -05:00
/**
* @brief Creates a Stop Segment at the specified row for the specified length of time.
*
* This will not create a dedicated delay segment. Use the third constructor for
* making delays.
* @param s the starting row of this segment.
* @param f the length of time to pause the note scrolling.
*/
2010-05-13 12:58:20 -05:00
StopSegment( int s, float f ) {
m_iStartRow = max( 0, s );
m_fStopSeconds = PREFSMAN->m_bQuirksMode ? f : max( 0.0f, f );
2011-02-12 15:43:24 -05:00
m_bDelay = false;
2010-05-13 12:58:20 -05:00
}
2011-02-12 15:43:24 -05:00
/**
* @brief Creates a Stop (or Delay) Segment at the specified row for the specified length of time.
* @param s the starting row of this segment.
* @param f the length of time to pause the note scrolling.
* @param d the flag that makes this Stop Segment a Delay Segment.
*/
2010-05-13 12:58:20 -05:00
StopSegment( int s, float f, bool d ) {
m_iStartRow = max( 0, s );
m_fStopSeconds = PREFSMAN->m_bQuirksMode ? f : max( 0.0f, f );
m_bDelay = d;
}
2011-02-12 15:43:24 -05:00
/**
* @brief The row in which the StopSegment activates.
*/
2010-01-26 21:00:30 -06:00
int m_iStartRow;
2011-02-12 15:43:24 -05:00
/**
* @brief The amount of time to complete the pause at the given row.
*/
2010-01-26 21:00:30 -06:00
float m_fStopSeconds;
2011-02-12 15:43:24 -05:00
/**
* @brief If true, the Stop Segment is treated as a Delay Segment, similar to the Pump It Up series.
*/
bool m_bDelay;
/**
* @brief Compares two StopSegments to see if they are equal to each other.
* @param other the other StopSegment to compare to.
* @return the equality of the two segments.
*/
2010-01-26 21:00:30 -06:00
bool operator==( const StopSegment &other ) const
{
COMPARE( m_iStartRow );
COMPARE( m_fStopSeconds );
COMPARE( m_bDelay );
return true;
}
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two StopSegments to see if they are not equal to each other.
* @param other the other StopSegment to compare to.
* @return the inequality of the two segments.
*/
2010-01-26 21:00:30 -06:00
bool operator!=( const StopSegment &other ) const { return !operator==(other); }
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two StopSegments to see if one is less than the other.
*
* It should be observed that Delay Segments have to come before Stop Segments.
* Otherwise, it will act like a Stop Segment with extra time from the Delay at
* the same row.
* @param other the other StopSegment to compare to.
* @return the truth/falsehood of if the first is less than the second.
*/
2011-01-10 23:58:53 -06:00
bool operator<( const StopSegment &other ) const
{
return ( m_iStartRow < other.m_iStartRow ) ||
2011-02-12 15:43:24 -05:00
( m_iStartRow == other.m_iStartRow &&
( m_bDelay && !other.m_bDelay || m_fStopSeconds < other.m_fStopSeconds ));
}
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two StopSegments to see if one is less than or equal to the other.
* @param other the other StopSegment to compare to.
* @return the truth/falsehood of if the first is less or equal to than the second.
*/
bool operator<=( const StopSegment &other ) const
{
return ( operator<(other) || operator==(other) );
}
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two StopSegments to see if one is greater than the other.
*
* Similar to the less than operator function, stops must come after delays
* to avoid rendering the point of delays pointless.
* @param other the other StopSegment to compare to.
* @return the truth/falsehood of if the first is greater than the second.
*/
bool operator>( const StopSegment &other ) const { return !operator<=(other); }
/**
* @brief Compares two StopSegments to see if one is greater than or equal to the other.
* @param other the other StopSegment to compare to.
* @return the truth/falsehood of if the first is greater than or equal to the second.
*/
bool operator>=( const StopSegment &other ) const { return !operator<(other); }
2010-01-26 21:00:30 -06:00
};
2011-02-12 15:43:24 -05:00
/**
* @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
2010-01-26 21:00:30 -06:00
* properly a fraction) is the number of beats per measure. The lower number (denominator here)
* is the note value representing one beat. */
struct TimeSignatureSegment
{
2011-02-12 15:43:24 -05:00
/**
* @brief Creates a simple Time Signature Segment with default values.
*/
2010-01-26 21:00:30 -06:00
TimeSignatureSegment() : m_iStartRow(-1), m_iNumerator(4), m_iDenominator(4) { }
2011-02-12 15:43:24 -05:00
/**
* @brief Creates a Time Signature Segment at the given row with a supplied numerator.
* @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 = n;
2011-02-12 15:43:24 -05:00
m_iDenominator = 4;
}
2011-02-12 15:43:24 -05:00
/**
* @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 = n;
m_iDenominator = d;
}
2011-02-12 15:43:24 -05:00
/**
* @brief The row in which the TimeSignatureSegment activates.
*/
2010-01-26 21:00:30 -06:00
int m_iStartRow;
2011-02-12 15:43:24 -05:00
/**
* @brief The numerator of the TimeSignatureSegment.
*/
2010-01-26 21:00:30 -06:00
int m_iNumerator;
2011-02-12 15:43:24 -05:00
/**
* @brief The denominator of the TimeSignatureSegment.
*/
2010-01-26 21:00:30 -06:00
int m_iDenominator;
2011-02-12 15:43:24 -05:00
/**
* @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
2010-01-26 21:00:30 -06:00
* 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
2011-02-12 15:43:24 -05:00
* rows per beat. Multiplying by m_iNumerator gives rows per measure.
* @returns the number of note rows per measure.
*/
2010-01-26 21:00:30 -06:00
int GetNoteRowsPerMeasure() const { return BeatToNoteRow(1) * 4 * m_iNumerator / m_iDenominator; }
2011-02-12 15:43:24 -05:00
/**
* @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.
*/
2010-01-26 21:00:30 -06:00
bool operator==( const TimeSignatureSegment &other ) const
{
COMPARE( m_iStartRow );
COMPARE( m_iNumerator );
COMPARE( m_iDenominator );
return true;
}
2011-02-12 15:43:24 -05:00
/**
* @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.
*/
2010-01-26 21:00:30 -06:00
bool operator!=( const TimeSignatureSegment &other ) const { return !operator==(other); }
2011-02-12 15:43:24 -05:00
/**
* @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
2011-01-14 10:33:12 -05:00
{
return ( operator<(other) || operator==(other) );
}
2011-02-12 15:43:24 -05:00
/**
* @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); }
2010-01-26 21:00:30 -06:00
};
2011-02-12 15:43:24 -05:00
/**
* @brief Identifies when a song needs to warp to a new beat.
*
* A warp segment is used to replicate the effects of Negative BPMs without
* abusing negative BPMs. Negative BPMs should be converted to warp segments.
* WarpAt=WarpTo is the format, where both are in beats. (Technically they're
* both rows though.) */
2010-01-26 21:00:30 -06:00
struct WarpSegment
{
2011-02-12 15:43:24 -05:00
/**
* @brief Creates a simple Warp Segment with default values.
*
* It is best to override the values as soon as possible.
*/
2010-08-15 16:12:30 -05:00
WarpSegment() : m_iStartRow(-1), m_fWarpBeats(-1) { }
2011-02-12 15:43:24 -05:00
/**
* @brief Creates a Warp Segment with the specified starting row and row to warp to.
* @param s the starting row of this segment.
* @param r the row to warp to.
*/
WarpSegment( int s, int r )
{
m_iStartRow = max( 0, s );
m_fWarpBeats = max( 0, NoteRowToBeat( r ) );
}
/**
* @brief Creates a Warp Segment with the specified starting row and beat to warp to.
* @param s the starting row of this segment.
* @param b the beat to warp to.
*/
2010-08-15 16:12:30 -05:00
WarpSegment( int s, float b ){ m_iStartRow = max( 0, s ); m_fWarpBeats = max( 0, b ); }
2011-02-12 15:43:24 -05:00
/**
* @brief The row in which the WarpSegment activates.
*/
2010-01-26 21:00:30 -06:00
int m_iStartRow;
2011-02-12 15:43:24 -05:00
/**
* @brief The beat to warp to.
*/
2010-08-15 16:12:30 -05:00
float m_fWarpBeats;
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two WarpSegments to see if they are equal to each other.
* @param other the other WarpSegment to compare to.
* @return the equality of the two segments.
*/
2010-01-26 21:00:30 -06:00
bool operator==( const WarpSegment &other ) const
{
COMPARE( m_iStartRow );
2010-08-15 16:12:30 -05:00
COMPARE( m_fWarpBeats );
2010-01-26 21:00:30 -06:00
return true;
}
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two WarpSegments to see if they are not equal to each other.
* @param other the other WarpSegment to compare to.
* @return the inequality of the two segments.
*/
2010-01-26 21:00:30 -06:00
bool operator!=( const WarpSegment &other ) const { return !operator==(other); }
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two WarpSegments to see if one is less than the other.
* @param other the other WarpSegment to compare to.
* @return the truth/falsehood of if the first is less than the second.
*/
bool operator<( const WarpSegment &other ) const
{
return m_iStartRow < other.m_iStartRow ||
( m_iStartRow == other.m_iStartRow && m_fWarpBeats < other.m_fWarpBeats );
}
/**
* @brief Compares two WarpSegments to see if one is less than or equal to the other.
* @param other the other WarpSegment to compare to.
* @return the truth/falsehood of if the first is less or equal to than the second.
*/
2011-01-14 10:33:12 -05:00
bool operator<=( const WarpSegment &other ) const
{
return ( operator<(other) || operator==(other) );
}
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two WarpSegments to see if one is greater than the other.
* @param other the other WarpSegment to compare to.
* @return the truth/falsehood of if the first is greater than the second.
*/
bool operator>( const WarpSegment &other ) const { return !operator<=(other); }
/**
* @brief Compares two WarpSegments to see if one is greater than or equal to the other.
* @param other the other WarpSegment to compare to.
* @return the truth/falsehood of if the first is greater than or equal to the second.
*/
bool operator>=( const WarpSegment &other ) const { return !operator<(other); }
};
2010-01-26 21:00:30 -06:00
2011-02-12 15:43:24 -05:00
/**
* @brief Identifies when a chart is to have a different tickcount value for hold notes.
*
2011-01-17 23:10:53 -05:00
* A tickcount segment is used to better replicate the checkpoint hold
* system used by various based video games. The number is used to
* represent how many ticks can be counted in one beat.
*/
struct TickcountSegment
{
2011-02-12 15:43:24 -05:00
/**
* @brief Creates a simple Tickcount Segment with default values.
*
* It is best to override the values as soon as possible.
*/
2011-01-17 23:10:53 -05:00
TickcountSegment() : m_iStartRow(-1), m_iTicks(2) { }
2011-02-12 15:43:24 -05:00
/**
* @brief Creates a Tickcount Segment with the specified starting row and beats per second.
* @param s the starting row of this segment.
* @param t the amount of ticks counted per beat.
*/
2011-01-17 23:10:53 -05:00
TickcountSegment( int s, int t ){ m_iStartRow = max( 0, s ); m_iTicks = max( 1, t ); }
2011-02-12 15:43:24 -05:00
/**
* @brief The row in which the TickcountSegment activates.
*/
2011-01-17 23:10:53 -05:00
int m_iStartRow;
2011-02-12 15:43:24 -05:00
/**
* @brief The amount of ticks counted per beat.
*/
2011-01-17 23:10:53 -05:00
int m_iTicks;
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two TickcountSegments to see if they are equal to each other.
* @param other the other TickcountSegment to compare to.
* @return the equality of the two segments.
*/
2011-01-17 23:10:53 -05:00
bool operator==( const TickcountSegment &other ) const
{
COMPARE( m_iStartRow );
COMPARE( m_iTicks );
return true;
}
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two TickcountSegments to see if they are not equal to each other.
* @param other the other TickcountSegment to compare to.
* @return the inequality of the two segments.
*/
2011-01-17 23:10:53 -05:00
bool operator!=( const TickcountSegment &other ) const { return !operator==(other); }
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two TickcountSegments to see if one is less than the other.
* @param other the other TickcountSegment to compare to.
* @return the truth/falsehood of if the first is less than the second.
*/
2011-01-17 23:10:53 -05:00
bool operator<( const TickcountSegment &other ) const { return m_iStartRow < other.m_iStartRow; }
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two TickcountSegments to see if one is less than or equal to the other.
* @param other the other TickcountSegment to compare to.
* @return the truth/falsehood of if the first is less or equal to than the second.
*/
2011-01-17 23:10:53 -05:00
bool operator<=( const TickcountSegment &other ) const
{
return ( operator<(other) || operator==(other) );
}
2011-02-12 15:43:24 -05:00
/**
* @brief Compares two TickcountSegments to see if one is greater than the other.
* @param other the other TickcountSegment to compare to.
* @return the truth/falsehood of if the first is greater than the second.
*/
bool operator>( const TickcountSegment &other ) const { return !operator<=(other); }
/**
* @brief Compares two TickcountSegments to see if one is greater than or equal to the other.
* @param other the other TickcountSegment to compare to.
* @return the truth/falsehood of if the first is greater than or equal to the second.
*/
bool operator>=( const TickcountSegment &other ) const { return !operator<(other); }
2011-01-17 23:10:53 -05:00
};
2011-02-12 15:43:24 -05:00
/**
* @brief Houses all of the TimingData functions.
*/
2010-01-26 21:00:30 -06:00
class TimingData
{
public:
TimingData();
void GetActualBPM( float &fMinBPMOut, float &fMaxBPMOut ) const;
float GetBPMAtBeat( float fBeat ) const;
void SetBPMAtRow( int iNoteRow, float fBPM );
void SetBPMAtBeat( float fBeat, float fBPM ) { SetBPMAtRow( BeatToNoteRow(fBeat), fBPM ); }
void SetStopAtRow( int iNoteRow, float fSeconds );
void SetStopAtRow( int iNoteRow, float fSeconds, bool bDelay ); // (sm-ssc)
void SetStopAtBeat( float fBeat, float fSeconds ) { SetStopAtRow( BeatToNoteRow(fBeat), fSeconds ); }
void SetStopAtBeat( float fBeat, float fSeconds, bool bDelay ) { SetStopAtRow( BeatToNoteRow(fBeat), fSeconds, bDelay ); } // (sm-ssc)
float GetStopAtRow( int iNoteRow, bool &bDelayOut ) const;
2011-01-18 09:17:48 -05:00
float GetStopAtRow( int iRow ) const;
float GetStopAtBeat( float fBeat ) const { return GetStopAtRow( BeatToNoteRow(fBeat) ); }
float GetDelayAtRow( int iRow ) const;
float GetDelayAtBeat( float fBeat ) const { return GetDelayAtRow( BeatToNoteRow(fBeat) ); }
void SetTimeSignatureAtRow( int iRow, int iNumerator, int iDenominator );
2011-01-16 13:27:32 -05:00
void SetTimeSignatureAtBeat( float fBeat, int iNumerator, int iDenominator ) { SetTimeSignatureAtRow( BeatToNoteRow(fBeat), iNumerator, iDenominator ); }
2011-01-16 13:50:11 -05:00
void SetTimeSignatureNumeratorAtRow( int iRow, int iNumerator );
void SetTimeSignatureNumeratorAtBeat( float fBeat, int iNumerator ) { SetTimeSignatureNumeratorAtRow( BeatToNoteRow(fBeat), iNumerator); }
void SetTimeSignatureDenominatorAtRow( int iRow, int iDenominator );
void SetTimeSignatureDenominatorAtBeat( float fBeat, int iDenominator ) { SetTimeSignatureDenominatorAtRow( BeatToNoteRow(fBeat), iDenominator); }
int GetWarpToRow( int iWarpBeginRow ) const;
void SetDelayAtRow( int iNoteRow, float fSeconds ); // sm-ssc
2011-01-17 23:10:53 -05:00
void SetTickcountAtRow( int iRow, int iTicks );
void SetTickcountAtBeat( float fBeat, int iTicks ) { SetTickcountAtRow( BeatToNoteRow( fBeat ), iTicks ); }
2011-01-18 09:17:48 -05:00
int GetTickcountAtRow( int iRow ) const;
int GetTickcountAtBeat( float fBeat ) const { return GetTickcountAtRow( BeatToNoteRow(fBeat) ); }
2010-01-26 21:00:30 -06:00
void MultiplyBPMInBeatRange( int iStartIndex, int iEndIndex, float fFactor );
void AddBPMSegment( const BPMSegment &seg );
void AddStopSegment( const StopSegment &seg );
void AddTimeSignatureSegment( const TimeSignatureSegment &seg );
void AddWarpSegment( const WarpSegment &seg );
2011-01-17 23:10:53 -05:00
void AddTickcountSegment( const TickcountSegment &seg );
2011-01-18 09:17:48 -05:00
int GetBPMSegmentIndexAtBeat( float fBeat ) const;
int GetTimeSignatureSegmentIndexAtRow( int iRow ) const;
int GetTimeSignatureSegmentIndexAtBeat( float fBeat ) const { return GetTimeSignatureSegmentIndexAtRow( BeatToNoteRow(fBeat) ); }
TimeSignatureSegment& GetTimeSignatureSegmentAtRow( int iRow );
TimeSignatureSegment& GetTimeSignatureSegmentAtBeat( float fBeat ) { return GetTimeSignatureSegmentAtRow( BeatToNoteRow(fBeat) ); }
int GetTimeSignatureNumeratorAtRow( int iRow );
int GetTimeSignatureNumeratorAtBeat( float fBeat ) { return GetTimeSignatureNumeratorAtRow( BeatToNoteRow(fBeat) ); }
int GetTimeSignatureDenominatorAtRow( int iRow );
2011-01-18 09:17:48 -05:00
int GetTimeSignatureDenominatorAtBeat( float fBeat ) { return GetTimeSignatureDenominatorAtRow( BeatToNoteRow(fBeat) ); }
2010-01-26 21:00:30 -06:00
BPMSegment& GetBPMSegmentAtBeat( float fBeat );
2011-01-18 09:17:48 -05:00
int GetTickcountSegmentIndexAtRow( int iRow ) const;
int GetTickcountSegmentIndexAtBeat( float fBeat ) const { return GetTickcountSegmentIndexAtRow( BeatToNoteRow(fBeat) ); }
2011-01-17 23:10:53 -05:00
TickcountSegment& GetTickcountSegmentAtRow( int iRow );
TickcountSegment& GetTickcountSegmentAtBeat( float fBeat ) { return GetTickcountSegmentAtRow( BeatToNoteRow(fBeat) ); }
2010-01-26 21:00:30 -06:00
void NoteRowToMeasureAndBeat( int iNoteRow, int &iMeasureIndexOut, int &iBeatIndexOut, int &iRowsRemainder ) const;
2010-08-15 16:12:30 -05:00
void GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, float &fBPSOut, bool &bFreezeOut, bool &bDelayOut, int &iWarpBeginOut, float &fWarpLengthOut ) const;
2010-01-26 21:00:30 -06:00
float GetBeatFromElapsedTime( float fElapsedTime ) const // shortcut for places that care only about the beat
{
2010-08-15 16:12:30 -05:00
float fBeat, fThrowAway, fThrowAway2;
2010-01-26 21:00:30 -06:00
bool bThrowAway, bThrowAway2;
2010-08-15 16:12:30 -05:00
int iThrowAway;
GetBeatAndBPSFromElapsedTime( fElapsedTime, fBeat, fThrowAway, bThrowAway, bThrowAway2, iThrowAway, fThrowAway2 );
2010-01-26 21:00:30 -06:00
return fBeat;
}
float GetElapsedTimeFromBeat( float fBeat ) const;
2010-08-15 16:12:30 -05:00
void GetBeatAndBPSFromElapsedTimeNoOffset( float fElapsedTime, float &fBeatOut, float &fBPSOut, bool &bFreezeOut, bool &bDelayOut, int &iWarpBeginOut, float &iWarpLengthOut ) const;
2010-01-26 21:00:30 -06:00
float GetBeatFromElapsedTimeNoOffset( float fElapsedTime ) const // shortcut for places that care only about the beat
{
2010-08-15 16:12:30 -05:00
float fBeat, fThrowAway, fThrowAway2;
2010-01-26 21:00:30 -06:00
bool bThrowAway, bThrowAway2;
2010-08-15 16:12:30 -05:00
int iThrowAway;
GetBeatAndBPSFromElapsedTimeNoOffset( fElapsedTime, fBeat, fThrowAway, bThrowAway, bThrowAway2, iThrowAway, fThrowAway2 );
2010-01-26 21:00:30 -06:00
return fBeat;
}
float GetElapsedTimeFromBeatNoOffset( float fBeat ) const;
bool HasBpmChanges() const;
bool HasStops() const;
bool HasWarps() const;
2010-01-26 21:00:30 -06:00
bool operator==( const TimingData &other )
{
COMPARE( m_BPMSegments.size() );
for( unsigned i=0; i<m_BPMSegments.size(); i++ )
COMPARE( m_BPMSegments[i] );
COMPARE( m_StopSegments.size() );
for( unsigned i=0; i<m_StopSegments.size(); i++ )
COMPARE( m_StopSegments[i] );
COMPARE( m_WarpSegments.size() );
for( unsigned i=0; i<m_WarpSegments.size(); i++ )
COMPARE( m_WarpSegments[i] );
2011-01-17 23:10:53 -05:00
COMPARE( m_vTimeSignatureSegments.size() );
for( unsigned i=0; i<m_vTimeSignatureSegments.size(); i++)
COMPARE( m_vTimeSignatureSegments[i] );
COMPARE( m_TickcountSegments.size() );
for( unsigned i=0; i<m_TickcountSegments.size(); i++ )
COMPARE( m_TickcountSegments[i] );
2010-01-26 21:00:30 -06:00
COMPARE( m_fBeat0OffsetInSeconds );
return true;
}
bool operator!=( const TimingData &other ) { return !operator==(other); }
void ScaleRegion( float fScale = 1, int iStartRow = 0, int iEndRow = MAX_NOTE_ROW );
void InsertRows( int iStartRow, int iRowsToAdd );
void DeleteRows( int iStartRow, int iRowsToDelete );
// Lua
void PushSelf( lua_State *L );
RString m_sFile; // informational only
2011-01-17 23:10:53 -05:00
// All of the following vectors must be sorted before gameplay.
vector<BPMSegment> m_BPMSegments;
vector<StopSegment> m_StopSegments;
vector<TimeSignatureSegment> m_vTimeSignatureSegments;
vector<WarpSegment> m_WarpSegments;
vector<TickcountSegment> m_TickcountSegments;
2010-01-26 21:00:30 -06:00
float m_fBeat0OffsetInSeconds;
bool m_bHasNegativeBpms; // only used for Lua bindings in Song (to be moved to TimingData later)
2010-01-26 21:00:30 -06:00
};
#undef COMPARE
#endif
2011-02-12 15:43:24 -05:00
/**
* @file
* @author Chris Danford, Glenn Maynard (c) 2001-2004
*
* @section LICENSE
2010-01-26 21:00:30 -06:00
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/