1#ifndef TIMING_SEGMENTS_H
2#define TIMING_SEGMENTS_H
21 NUM_TimingSegmentType,
22 TimingSegmentType_Invalid,
28 SegmentEffectType_Row,
29 SegmentEffectType_Range,
30 SegmentEffectType_Indefinite,
32 NUM_SegmentEffectType,
33 SegmentEffectType_Invalid,
36#define FOREACH_TimingSegmentType(tst) FOREACH_ENUM(TimingSegmentType, tst)
39TimingSegmentTypeToString(TimingSegmentType tst) ->
const std::string&;
41const int ROW_INVALID = -1;
44 if (this->x != other.x) \
46#define COMPARE_FLOAT(x) \
47 if (fabsf(this->x - other.x) > EPSILON) \
56 [[nodiscard]]
virtual auto GetType()
const -> TimingSegmentType
58 return TimingSegmentType_Invalid;
61 [[nodiscard]]
virtual auto GetEffectType()
const -> SegmentEffectType
63 return SegmentEffectType_Invalid;
66 [[nodiscard]]
virtual auto Copy()
const ->
TimingSegment* = 0;
68 [[nodiscard]]
virtual auto IsNotable()
const ->
bool = 0;
69 virtual void DebugPrint()
const;
77 : m_iStartRow(ToNoteRow(fBeat))
82 : m_iStartRow(other.GetRow())
87 static const double EPSILON;
97 virtual void Scale(
int start,
int length,
int newLength);
99 [[nodiscard]]
auto GetRow()
const ->
int {
return m_iStartRow; }
100 void SetRow(
int iRow) { m_iStartRow = iRow; }
102 [[nodiscard]]
auto GetBeat()
const ->
float
104 return NoteRowToBeat(m_iStartRow);
106 void SetBeat(
float fBeat) { SetRow(BeatToNoteRow(fBeat)); }
108 [[nodiscard]]
virtual auto ToString(
int )
const -> std::string
110 return FloatToString(GetBeat());
113 [[nodiscard]]
virtual auto GetValues()
const -> std::vector<float>
115 return std::vector<float>(0);
120 return GetRow() < other.GetRow();
125 virtual auto operator==(
const TimingSegment& other)
const ->
bool
127 return GetRow() == other.GetRow();
130 virtual auto operator!=(
const TimingSegment& other)
const ->
bool
132 return !this->operator==(other);
153 [[nodiscard]]
auto GetType()
const -> TimingSegmentType
override
158 [[nodiscard]]
auto GetEffectType()
const -> SegmentEffectType
override
160 return SegmentEffectType_Range;
168 [[nodiscard]]
auto IsNotable()
const ->
bool override
170 return m_iLengthRows > 0;
172 void DebugPrint()
const override;
176 , m_iLengthRows(iLengthRows)
182 , m_iLengthRows(ToNoteRow(fBeats))
188 , m_iLengthRows(other.GetLengthRows())
194 [[nodiscard]]
auto GetLengthRows()
const ->
int {
return m_iLengthRows; }
195 [[nodiscard]]
auto GetLengthBeats()
const ->
float
197 return ToBeat(m_iLengthRows);
199 [[nodiscard]]
auto GetLength()
const ->
float
201 return GetLengthBeats();
204 void SetLength(
int iRows) { m_iLengthRows = ToNoteRow(iRows); }
205 void SetLength(
float fBeats) { m_iLengthRows = ToNoteRow(fBeats); }
207 void Scale(
int start,
int length,
int newLength)
override;
209 [[nodiscard]]
auto ToString(
int dec)
const -> std::string
override;
211 [[nodiscard]]
auto GetValues()
const -> std::vector<float>
override
213 return std::vector<float>(1, GetLength());
216 auto operator==(
const FakeSegment& other)
const ->
bool
218 return m_iLengthRows == other.m_iLengthRows;
221 auto operator==(
const TimingSegment& other)
const ->
bool override
223 if (GetType() != other.GetType()) {
227 return operator==(
static_cast<const FakeSegment&
>(other));
232 int m_iLengthRows{ -1 };
244 [[nodiscard]]
auto GetType()
const -> TimingSegmentType
override
249 [[nodiscard]]
auto GetEffectType()
const -> SegmentEffectType
override
251 return SegmentEffectType_Range;
259 [[nodiscard]]
auto IsNotable()
const ->
bool override
261 return m_iLengthRows > 0;
263 void DebugPrint()
const override;
267 , m_iLengthRows(other.GetLengthRows())
273 , m_iLengthRows(iLengthRows)
279 , m_iLengthRows(ToNoteRow(fBeats))
285 [[nodiscard]]
auto GetLengthRows()
const ->
int {
return m_iLengthRows; }
286 [[nodiscard]]
auto GetLengthBeats()
const ->
float
288 return ToBeat(m_iLengthRows);
290 [[nodiscard]]
auto GetLength()
const ->
float
292 return GetLengthBeats();
295 void SetLength(
int iRows) { m_iLengthRows = ToNoteRow(iRows); }
296 void SetLength(
float fBeats) { m_iLengthRows = ToNoteRow(fBeats); }
298 void Scale(
int start,
int length,
int newLength)
override;
299 [[nodiscard]]
auto ToString(
int dec)
const -> std::string
override;
301 [[nodiscard]]
auto GetValues()
const -> std::vector<float>
override
303 return std::vector<float>(1, GetLength());
306 auto operator==(
const WarpSegment& other)
const ->
bool
308 return m_iLengthRows == other.m_iLengthRows;
311 auto operator==(
const TimingSegment& other)
const ->
bool override
313 if (GetType() != other.GetType()) {
317 return operator==(
static_cast<const WarpSegment&
>(other));
322 int m_iLengthRows{ 0 };
339 [[nodiscard]]
auto GetType() const -> TimingSegmentType
override
341 return SEGMENT_TICKCOUNT;
344 [[nodiscard]]
auto GetEffectType() const -> SegmentEffectType
override
346 return SegmentEffectType_Indefinite;
349 [[nodiscard]]
auto IsNotable() const ->
bool override
353 void DebugPrint()
const override;
363 , m_iTicksPerBeat(iTicks)
369 , m_iTicksPerBeat(other.GetTicks())
373 [[nodiscard]]
auto GetTicks() const ->
int {
return m_iTicksPerBeat; }
374 void SetTicks(
int iTicks) { m_iTicksPerBeat = iTicks; }
376 [[nodiscard]]
auto ToString(
int dec)
const -> std::string
override;
378 [[nodiscard]]
auto GetValues() const -> std::vector<
float>
override
380 return std::vector<float>(1, GetTicks() * 1.F);
385 return m_iTicksPerBeat == other.m_iTicksPerBeat;
388 auto operator==(
const TimingSegment& other)
const ->
bool override
390 if (GetType() != other.GetType()) {
410 [[nodiscard]]
auto GetType()
const -> TimingSegmentType
override
412 return SEGMENT_COMBO;
415 [[nodiscard]]
auto GetEffectType()
const -> SegmentEffectType
override
417 return SegmentEffectType_Indefinite;
420 [[nodiscard]]
auto IsNotable()
const ->
bool override
424 void DebugPrint()
const override;
436 , m_iMissCombo(iMissCombo)
442 , m_iCombo(other.GetCombo())
443 , m_iMissCombo(other.GetMissCombo())
447 [[nodiscard]]
auto GetCombo()
const ->
int {
return m_iCombo; }
448 [[nodiscard]]
auto GetMissCombo()
const ->
int {
return m_iMissCombo; }
450 void SetCombo(
int iCombo) { m_iCombo = iCombo; }
451 void SetMissCombo(
int iCombo) { m_iMissCombo = iCombo; }
453 [[nodiscard]]
auto ToString(
int dec)
const -> std::string
override;
454 [[nodiscard]]
auto GetValues()
const -> std::vector<float>
override;
456 auto operator==(
const ComboSegment& other)
const ->
bool
459 COMPARE(m_iMissCombo);
463 auto operator==(
const TimingSegment& other)
const ->
bool override
465 if (GetType() != other.GetType()) {
469 return operator==(
static_cast<const ComboSegment&
>(other));
488 [[nodiscard]]
auto GetType()
const -> TimingSegmentType
override
490 return SEGMENT_LABEL;
493 [[nodiscard]]
auto GetEffectType()
const -> SegmentEffectType
override
495 return SegmentEffectType_Indefinite;
498 [[nodiscard]]
auto IsNotable()
const ->
bool override
502 void DebugPrint()
const override;
510 std::string sLabel = std::string())
512 , m_sLabel(std::move(sLabel))
518 , m_sLabel(other.GetLabel())
522 [[nodiscard]]
auto GetLabel()
const ->
const std::string&
526 void SetLabel(
const std::string& sLabel) { m_sLabel.assign(sLabel); }
528 [[nodiscard]]
auto ToString(
int dec)
const -> std::string
override;
533 auto operator==(
const LabelSegment& other)
const ->
bool
535 return m_sLabel == other.m_sLabel;
538 auto operator==(
const TimingSegment& other)
const ->
bool override
540 if (GetType() != other.GetType()) {
544 return operator==(
static_cast<const LabelSegment&
>(other));
549 std::string m_sLabel;
557 [[nodiscard]]
auto GetType()
const -> TimingSegmentType
override
562 [[nodiscard]]
auto GetEffectType()
const -> SegmentEffectType
override
564 return SegmentEffectType_Indefinite;
567 [[nodiscard]]
auto IsNotable()
const ->
bool override
571 void DebugPrint()
const override;
579 BPMSegment(
int iStartRow = ROW_INVALID,
float fBPM = 0.0F)
587 , m_fBPS(other.GetBPS())
591 [[nodiscard]]
auto GetBPS()
const ->
float {
return m_fBPS; }
592 [[nodiscard]]
auto GetBPM()
const ->
float {
return m_fBPS * 60.0F; }
594 void SetBPS(
float fBPS) { m_fBPS = fBPS; }
595 void SetBPM(
float fBPM) { m_fBPS = fBPM / 60.0F; }
597 [[nodiscard]]
auto ToString(
int dec)
const -> std::string
override;
599 [[nodiscard]]
auto GetValues()
const -> std::vector<float>
override
601 return std::vector<float>(1, GetBPM());
604 auto operator==(
const BPMSegment& other)
const ->
bool
606 COMPARE_FLOAT(m_fBPS);
610 auto operator==(
const TimingSegment& other)
const ->
bool override
612 if (GetType() != other.GetType()) {
616 return operator==(
static_cast<const BPMSegment&
>(other));
633 [[nodiscard]]
auto GetType()
const -> TimingSegmentType
override
635 return SEGMENT_TIME_SIG;
638 [[nodiscard]]
auto GetEffectType()
const -> SegmentEffectType
override
640 return SegmentEffectType_Indefinite;
643 [[nodiscard]]
auto IsNotable()
const ->
bool override
647 void DebugPrint()
const override;
659 , m_iDenominator(iDenom)
665 , m_iNumerator(other.GetNum())
666 , m_iDenominator(other.GetDen())
670 [[nodiscard]]
auto GetNum()
const ->
int {
return m_iNumerator; }
671 void SetNum(
int num) { m_iNumerator = num; }
673 [[nodiscard]]
auto GetDen()
const ->
int {
return m_iDenominator; }
674 void SetDen(
int den) { m_iDenominator = den; }
676 void Set(
int num,
int den)
679 m_iDenominator = den;
682 [[nodiscard]]
auto ToString(
int dec)
const -> std::string
override;
683 [[nodiscard]]
auto GetValues()
const -> std::vector<float>
override;
699 return BeatToNoteRow(1) * 4 * m_iNumerator / m_iDenominator;
704 COMPARE(m_iNumerator);
705 COMPARE(m_iDenominator);
709 auto operator==(
const TimingSegment& other)
const ->
bool override
711 if (GetType() != other.GetType()) {
719 int m_iNumerator, m_iDenominator;
734 [[nodiscard]]
auto GetType()
const -> TimingSegmentType
override
736 return SEGMENT_SPEED;
739 [[nodiscard]]
auto GetEffectType()
const -> SegmentEffectType
override
741 return SegmentEffectType_Indefinite;
744 [[nodiscard]]
auto IsNotable()
const ->
bool override
748 void DebugPrint()
const override;
775 , m_fRatio(other.GetRatio())
776 , m_fDelay(other.GetDelay())
777 , m_Unit(other.GetUnit())
781 [[nodiscard]]
auto GetRatio() const ->
float {
return m_fRatio; }
782 void SetRatio(
float fRatio) { m_fRatio = fRatio; }
784 [[nodiscard]]
auto GetDelay() const ->
float {
return m_fDelay; }
785 void SetDelay(
float fDelay) { m_fDelay = fDelay; }
787 [[nodiscard]]
auto GetUnit() const ->
BaseUnit {
return m_Unit; }
788 void SetUnit(
BaseUnit unit) { m_Unit = unit; }
790 void Scale(
int start,
int length,
int newLength)
override;
792 [[nodiscard]]
auto ToString(
int dec)
const -> std::string
override;
793 [[nodiscard]]
auto GetValues() const -> std::vector<
float> override;
795 auto operator==(const
SpeedSegment& other) const ->
bool
797 COMPARE_FLOAT(m_fRatio);
798 COMPARE_FLOAT(m_fDelay);
803 auto operator==(
const TimingSegment& other)
const ->
bool override
805 if (GetType() != other.GetType()) {
809 return operator==(
static_cast<const SpeedSegment&
>(other));
835 [[nodiscard]]
auto GetType()
const -> TimingSegmentType
override
837 return SEGMENT_SCROLL;
840 [[nodiscard]]
auto GetEffectType()
const -> SegmentEffectType
override
842 return SegmentEffectType_Indefinite;
845 [[nodiscard]]
auto IsNotable()
const ->
bool override
849 void DebugPrint()
const override;
856 ScrollSegment(
int iStartRow = ROW_INVALID,
float fRatio = 1.0F)
864 , m_fRatio(other.GetRatio())
868 [[nodiscard]]
auto GetRatio()
const ->
float {
return m_fRatio; }
869 void SetRatio(
float fRatio) { m_fRatio = fRatio; }
871 [[nodiscard]]
auto ToString(
int dec)
const -> std::string
override;
873 [[nodiscard]]
auto GetValues()
const -> std::vector<float>
override
875 return std::vector<float>(1, GetRatio());
880 COMPARE_FLOAT(m_fRatio);
884 auto operator==(
const TimingSegment& other)
const ->
bool override
886 if (GetType() != other.GetType()) {
903 [[nodiscard]]
auto GetType()
const -> TimingSegmentType
override
908 [[nodiscard]]
auto GetEffectType()
const -> SegmentEffectType
override
910 return SegmentEffectType_Row;
913 [[nodiscard]]
auto IsNotable()
const ->
bool override
915 return m_fSeconds > 0;
917 void DebugPrint()
const override;
924 StopSegment(
int iStartRow = ROW_INVALID,
float fSeconds = 0.0F)
926 , m_fSeconds(fSeconds)
932 , m_fSeconds(other.GetPause())
936 [[nodiscard]]
auto GetPause()
const ->
float {
return m_fSeconds; }
937 void SetPause(
float fSeconds) { m_fSeconds = fSeconds; }
939 [[nodiscard]]
auto ToString(
int dec)
const -> std::string
override;
941 [[nodiscard]]
auto GetValues()
const -> std::vector<float>
override
943 return std::vector<float>(1, GetPause());
946 auto operator==(
const StopSegment& other)
const ->
bool
948 COMPARE_FLOAT(m_fSeconds);
952 auto operator==(
const TimingSegment& other)
const ->
bool override
954 if (GetType() != other.GetType()) {
958 return operator==(
static_cast<const StopSegment&
>(other));
971 [[nodiscard]]
auto GetType()
const -> TimingSegmentType
override
973 return SEGMENT_DELAY;
976 [[nodiscard]]
auto GetEffectType()
const -> SegmentEffectType
override
978 return SegmentEffectType_Row;
981 [[nodiscard]]
auto IsNotable()
const ->
bool override
983 return m_fSeconds > 0;
985 void DebugPrint()
const override;
992 DelaySegment(
int iStartRow = ROW_INVALID,
float fSeconds = 0)
994 , m_fSeconds(fSeconds)
1000 , m_fSeconds(other.GetPause())
1004 [[nodiscard]]
auto GetPause()
const ->
float {
return m_fSeconds; }
1005 void SetPause(
float fSeconds) { m_fSeconds = fSeconds; }
1007 [[nodiscard]]
auto ToString(
int dec)
const -> std::string
override;
1009 [[nodiscard]]
auto GetValues()
const -> std::vector<float>
override
1011 return std::vector<float>(1, GetPause());
1014 auto operator==(
const DelaySegment& other)
const ->
bool
1016 COMPARE_FLOAT(m_fSeconds);
1020 auto operator==(
const TimingSegment& other)
const ->
bool override
1022 if (GetType() != other.GetType()) {
1026 return operator==(
static_cast<const DelaySegment&
>(other));
Identifies when a song changes its BPM.
Definition TimingSegments.h:556
Identifies when a chart is to have a different combo multiplier value.
Definition TimingSegments.h:409
Identifies when a song has a delay, or pump style stop.
Definition TimingSegments.h:970
Identifies when a whole region of arrows is to be ignored.
Definition TimingSegments.h:152
void Scale(int start, int length, int newLength) override
Scales itself.
Definition TimingSegments.cpp:157
Identifies when a chart is entering a different section.
Definition TimingSegments.h:487
Identifies when the arrow scroll changes.
Definition TimingSegments.h:733
BaseUnit
The type of unit used for segment scaling.
Definition TimingSegments.h:757
void Scale(int start, int length, int newLength) override
Scales itself.
Definition TimingSegments.cpp:279
Identifies when a song has a stop, DDR/ITG style.
Definition TimingSegments.h:902
Identifies when a chart is to have a different tickcount value for hold notes.
Definition TimingSegments.h:335
static const unsigned DEFAULT_TICK_COUNT
The default amount of ticks per beat.
Definition TimingSegments.h:337
Identifies when a song changes its time signature.
Definition TimingSegments.h:632
auto GetNoteRowsPerMeasure() const -> int
Retrieve the number of note rows per measure within the TimeSignatureSegment.
Definition TimingSegments.h:697
The base timing segment for make glorious benefit wolfman XXX: this should be an abstract class.
Definition TimingSegments.h:55
virtual void Scale(int start, int length, int newLength)
Scales itself.
Definition TimingSegments.cpp:21
Identifies when a song needs to warp to a new beat.
Definition TimingSegments.h:243
void Scale(int start, int length, int newLength) override
Scales itself.
Definition TimingSegments.cpp:182