danomatika / ofxMidi

(maintained) Midi addon for openFrameworks
Other
262 stars 73 forks source link

Adding Listener to a Class #47

Closed gsautr closed 7 years ago

gsautr commented 7 years ago

Basic issue but struggling to find a way to bind the listener to a class as opposed to ofApp? ie.

class MyClass {
public: 
    ofxMidiIn midiIn;
    ofxMidiMessage midiMessage;
    void setup() {
         midiIn.listPorts();
         midiIn.openPort(1);
         midiIn.addListener(this);

    }
    void newMidiMessage(ofxMidiMessage & msg) {

    }
}
danomatika commented 7 years ago

You need to inherit from ofxMidiListener:

class MyClass : public ofxMidiListener {
danomatika commented 7 years ago

Get it to work?