O'Reilly logo

Leap Motion Development Essentials by Mischa Spiegelmock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Refactoring for multithreading

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();

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required