Before continuing further on, perhaps it would be a good time to refactor our virtual MIDI device output functionality into its own class, as the MIDI output routines with the attendant threading code should be encapsulated for maintaining some semblance of clean program structure.
namespace leapmidi { class Device { public: Device(); ~Device(); void init(); void queueControlMessage(midi_control_index controlIndex, midi_control_value controlValue);
We'll go ahead and create a leapmidi::Device
class. Users of our class construct a new Device
class and call init()
to set up the MIDI virtual device, and then send MIDI control messages using queueControlMessage()
.
protected: void initPacketList(); void createDevice();
Our earlier MIDI virtual device setup code can go in here.
pthread_t messageQueueThread; void *messageSendingThreadEntry();
This function will be called when our MIDI output thread (kept track of by messageQueueThread
) begins...