Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

TimingData.h

Go to the documentation of this file.
00001 /* TimingData - Holds data for translating beats<->seconds. */ 00002 00003 #ifndef TIMING_DATA_H 00004 #define TIMING_DATA_H 00005 00006 #include "NoteTypes.h" 00007 00008 struct BPMSegment 00009 { 00010 BPMSegment() { m_iStartIndex = -1; m_fBPS = -1; } 00011 BPMSegment( int s, float b ) { m_iStartIndex = s; m_fBPS = b/60.0f; } 00012 int m_iStartIndex; 00013 float m_fBPS; 00014 00015 void SetBPM( float f ); 00016 float GetBPM() const; 00017 }; 00018 00019 struct StopSegment 00020 { 00021 StopSegment() { m_fStopSeconds = -1; m_iStartRow = -1; } 00022 StopSegment( int s, float f ) { m_iStartRow = s; m_fStopSeconds = f; } 00023 int m_iStartRow; 00024 float m_fStopSeconds; 00025 }; 00026 00027 class TimingData 00028 { 00029 public: 00030 TimingData(); 00031 00032 void GetActualBPM( float &fMinBPMOut, float &fMaxBPMOut ) const; 00033 float GetBPMAtBeat( float fBeat ) const; 00034 void SetBPMAtBeat( float fBeat, float fBPM ); 00035 void SetStopAtBeat( float fBeat, float fSeconds ); 00036 void MultiplyBPMInBeatRange( int iStartIndex, int iEndIndex, float fFactor ); 00037 void AddBPMSegment( const BPMSegment &seg ); 00038 void AddStopSegment( const StopSegment &seg ); 00039 BPMSegment& GetBPMSegmentAtBeat( float fBeat ); 00040 00041 void GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, float &fBPSOut, bool &bFreezeOut ) const; 00042 float GetBeatFromElapsedTime( float fElapsedTime ) const // shortcut for places that care only about the beat 00043 { 00044 float fBeat, fThrowAway; 00045 bool bThrowAway; 00046 GetBeatAndBPSFromElapsedTime( fElapsedTime, fBeat, fThrowAway, bThrowAway ); 00047 return fBeat; 00048 } 00049 float GetElapsedTimeFromBeat( float fBeat ) const; 00050 bool HasBpmChangesOrStops() const; 00051 00052 // used for editor fix - expand/contract needs to move BPMSegments 00053 // and StopSegments that land during/after the edited range. 00054 // in addition, we need to be able to shift them otherwise as well 00055 // (for example, adding/removing rows should move all following 00056 // segments as necessary) 00057 // NOTE: How do we want to handle deleting rows that have a BPM change 00058 // or a stop? I'd like to think we should move them to the first row 00059 // of the range that was deleted (say if rows 1680-1728 are deleted, and 00060 // a BPM change or a stop occurs at row 1704, we'll move it to row 00061 // 1680). 00062 void ScaleRegion( float fScale = 1, int iStartRow = 0, int iEndRow = MAX_NOTE_ROW ); 00063 void ShiftRows( int iStartRow, int iRowsToShift ); 00064 00065 CString m_sFile; // informational only 00066 vector<BPMSegment> m_BPMSegments; // this must be sorted before gameplay 00067 vector<StopSegment> m_StopSegments; // this must be sorted before gameplay 00068 float m_fBeat0OffsetInSeconds; 00069 }; 00070 00071 #endif 00072 00073 /* 00074 * (c) 2001-2004 Chris Danford, Glenn Maynard 00075 * All rights reserved. 00076 * 00077 * Permission is hereby granted, free of charge, to any person obtaining a 00078 * copy of this software and associated documentation files (the 00079 * "Software"), to deal in the Software without restriction, including 00080 * without limitation the rights to use, copy, modify, merge, publish, 00081 * distribute, and/or sell copies of the Software, and to permit persons to 00082 * whom the Software is furnished to do so, provided that the above 00083 * copyright notice(s) and this permission notice appear in all copies of 00084 * the Software and that both the above copyright notice(s) and this 00085 * permission notice appear in supporting documentation. 00086 * 00087 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00088 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00089 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00090 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00091 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00092 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00093 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00094 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00095 * PERFORMANCE OF THIS SOFTWARE. 00096 */

Generated on Thu Jan 27 20:57:34 2005 for StepMania by doxygen 1.3.7