C++ API Reference RNBO: src/RNBO_TempoEvent.h Source File

RNBO: src/RNBO_TempoEvent.h Source File

1 //
2 // RNBO_TempoEvent.h
3 //
4 //
5 
6 #ifndef _RNBO_TempoEvent_H_
7 #define _RNBO_TempoEvent_H_
8 
9 #include "RNBO_Types.h"
10 
11 namespace RNBO {
12 
13  class PatcherEventTarget;
14 
18  class TempoEvent {
19 
20  public:
21 
22  TempoEvent()
23  : _eventTime(0)
24  , _tempo(-1)
25  {
26  }
27 
28  ~TempoEvent()
29  {
30  }
31 
32  TempoEvent(
33  MillisecondTime eventTime,
34  Tempo tempo
35  )
36  : _eventTime(eventTime)
37  , _tempo(tempo)
38  {
39  }
40 
41  TempoEvent(const TempoEvent& other)
42  : _eventTime(other._eventTime)
43  {
44  _tempo = other._tempo;
45  }
46 
47  TempoEvent(TempoEvent&& other)
48  : _eventTime(other._eventTime)
49  {
50  _tempo = other._tempo;
51  }
52 
53  TempoEvent& operator = (const TempoEvent& other)
54  {
55  _eventTime = other._eventTime;
56  _tempo = other._tempo;
57 
58  return *this;
59  }
60 
61  bool operator==(const TempoEvent& rhs) const
62  {
63  return rhs.getTime() == getTime() && rhs.getTempo() == getTempo();
64  }
65 
66  MillisecondTime getTime() const { return _eventTime; }
67  Tempo getTempo() const { return _tempo; }
68 
69  // we will always use the default event target (the top level patcher)
70  PatcherEventTarget* getEventTarget() const { return nullptr; }
71 
72  // debugging
73  void dumpEvent() const {
74  // disabling for now to avoid requiring fprintf support in generated code
75 // fprintf(stdout, "TempoEvent: time=%.3f tempo=%d", _eventTime, _tempo);
76  }
77 
78  protected:
79 
80  MillisecondTime _eventTime;
81  Tempo _tempo;
82 
83  friend class EventVariant;
84 
85  void setTime(MillisecondTime eventTime) { _eventTime = eventTime; }
86  };
87 
88 } // namespace RNBO
89 
90 #endif // #ifndef _RNBO_TempoEvent_H_