#include "../include/tick.h"
#include "../include/manager.h"
using namespace std;
public:
TestComp();
protected:
static const tMsecs NOTE_INTERVAL = 1000;
static const tMsecs NOTE_LENGTH = 400;
};
void TestComp::Start() {
cout << "Starting the component ... " << endl;
next_note_on = 0;
next_note_off = NOTE_LENGTH;
}
void TestComp::Stop() {
cout << "Stopping the component ... " << endl;
}
void TestComp::StaticTickProc(
tMsecs sys_time,
void* pt) {
TestComp* class_pt = static_cast<TestComp*>(pt);
class_pt->TickProc(sys_time);
}
void TestComp::TickProc(
tMsecs sys_time) {
tMsecs deltat = sys_time - sys_time_offset;
if (deltat >= next_note_off) {
cout << "and off" << endl;
next_note_off += NOTE_INTERVAL;
}
if (deltat >= next_note_on) {
cout << "Note on . . . ";
next_note_on += NOTE_INTERVAL;
}
}
int main() {
TestComp comp;
comp.Start();
cout << "Waiting 10 secs ... " << endl;
comp.Stop();
cout << "Waiting 5 secs without playing ... " << endl;
cout << "Exiting" << endl;
return EXIT_SUCCESS;
}
static MIDIOutDriver * GetOutDriver(unsigned int n)
Returns a pointer to the MIDIOutDriver with given port id.
void SetNoteOff(unsigned char chan, unsigned char note, unsigned char vel)
Makes the message a note off message with given channel, note and velocity.
void SetNoteOn(unsigned char chan, unsigned char note, unsigned char vel)
Makes the message a note on message with given channel, note and velocity.
virtual void OpenPort()
Opens the hardware out port.
virtual void OutputMessage(const MIDITimedMessage &msg)
Makes a copy of the message, processes it with the out processor and then sends it to the hardware po...
virtual void ClosePort()
Closes the hardware out port.
A pure virtual class implementing an object which has a callback procedure to be called at every tick...
Definition: tick.h:65
virtual void Reset()=0
A pure virtual method which should reinitialize the class parameters.
static void StaticTickProc(tMsecs sys_time, void *pt)
This is the static callback procedure which the MIDIManager will call at every MIDITimer tick.
Definition: tick.h:116
virtual void Start()
Sets the running status as true and starts to call the callback.
virtual void TickProc(tMsecs sys_time)=0
This is the pure virtual function you must implement in your subclass.
virtual void Stop()
Sets the running status as false and stops the callback.
The MIDITimedMessage class inherits from the MIDIMessage and represents a message associated with a s...
Definition: msg.h:382
static void Wait(unsigned int msecs)
Stops the calling thread for the given number of milliseconds.
Definition: timer.h:105
unsigned long long tMsecs
The type of a variable which can hold the elapsed time in milliseconds.
Definition: timer.h:44
@ PR_PRE_SEQ
The component is inserted before the sequencer.
Definition: tick.h:46