A pure virtual class implementing an object which has a callback procedure to be called at every tick of a MIDITimer.
More...
#include <tick.h>
|
virtual void | TickProc (tMsecs sys_time)=0 |
| This is the pure virtual function you must implement in your subclass. More...
|
|
A pure virtual class implementing an object which has a callback procedure to be called at every tick of a MIDITimer.
You can use this feature to send, receive or manipulate MIDI messages with accurate timing: the MIDISequencer, MIDIThru and MIDIRecorder classes inherit by this. To use a MIDITickComponent object it must be placed in the MIDIManager queue with the MIDIManager::AddMIDITick() method: this is done by the base class constructor so the user doesn't need to do this; you can hence call the Start() and Stop() methods of the object to start and stop the callback. A priority parameter is supplied to determine the position of the MIDITickComponent in the MIDIManager queue.
- Examples
- test_component.cpp.
◆ MIDITickComponent()
The constructor.
It adds the component to the MIDIManager queue calling MIDIManager::AddMIDITick(), so the user doesn't need to do it manually.
- Parameters
-
pr | the priority (see tPriority) |
func | a pointer to the static callback: this should be the address of the StaticTickProc() you have implemented in your subclass |
◆ ~MIDITickComponent()
virtual MIDITickComponent::~MIDITickComponent |
( |
| ) |
|
|
virtual |
The destructor.
Before deleting the object it tries to remove its pointer from the MIDIManager queue to prevent the manager from using an invalid pointer. If a derived class destructor needs to delete something it should call Stop() as first statement, then do its work.
◆ Reset()
virtual void MIDITickComponent::Reset |
( |
| ) |
|
|
pure virtual |
◆ GetFunc()
MIDITick * MIDITickComponent::GetFunc |
( |
| ) |
const |
|
inline |
◆ GetPriority()
tPriority MIDITickComponent::GetPriority |
( |
| ) |
const |
|
inline |
◆ GetDevOffset()
tMsecs MIDITickComponent::GetDevOffset |
( |
| ) |
const |
|
inline |
◆ IsPlaying()
bool MIDITickComponent::IsPlaying |
( |
| ) |
const |
|
inline |
◆ SetDevOffset()
void MIDITickComponent::SetDevOffset |
( |
tMsecs |
dev_offs | ) |
|
Sets an user defined time offset, which will be added to every time calculation.
For example, the MIDISequencer uses this as the start time of the sequencer.
◆ Start()
virtual void MIDITickComponent::Start |
( |
| ) |
|
|
virtual |
Sets the running status as true and starts to call the callback.
Moreover it set the sys_time_offset parameter to the now time so, at every subsequent call of the callback, you can calculate the elapsed time. In your derived class you probably will want to redefine this for doing other things before starting the callback (for example opening MIDI ports): however in your derived method you must call this base class method.
Reimplemented in AdvancedSequencer, Metronome, MIDIRecorder, MIDISequencer, and MIDIThru.
- Examples
- test_component.cpp.
◆ Stop()
virtual void MIDITickComponent::Stop |
( |
| ) |
|
|
virtual |
◆ StaticTickProc()
static void MIDITickComponent::StaticTickProc |
( |
tMsecs |
sys_time, |
|
|
void * |
pt |
|
) |
| |
|
inlinestaticprotected |
This is the static callback procedure which the MIDIManager will call at every MIDITimer tick.
The parameters are automatically set by the MIDIManager at every function call.
- Parameters
-
sys_time | the now system time |
pt | the this pointer of the object instance. |
You must implement it in your subclass and give this function address in the constructor. Typically this should only cast the void pointer pt to a pointer to your object and then call the pt->TickProc(sys_time), i.e. your non static procedure.
- Examples
- test_component.cpp.
◆ TickProc()
virtual void MIDITickComponent::TickProc |
( |
tMsecs |
sys_time | ) |
|
|
protectedpure virtual |
◆ tick_proc
const MIDITick* MIDITickComponent::tick_proc |
|
protected |
The pointer to the static callback (set by the constructor to StaticTickProc()).
◆ dev_time_offset
tMsecs MIDITickComponent::dev_time_offset |
|
protected |
A time offset set by the user and which you can use for your calculations.
◆ sys_time_offset
tMsecs MIDITickComponent::sys_time_offset |
|
protected |
The system time of the last call of Start().
You can use this for calculating the time elapsed between the start of the callback and the actual call of TickProc().
◆ proc_lock
std::recursive_mutex MIDITickComponent::proc_lock |
|
protected |
A mutex you can use for implementing thread safe methods.
The documentation for this class was generated from the following file: