Skip to content

Instantly share code, notes, and snippets.

@tobetchi
Created September 28, 2016 10:55
Show Gist options
  • Save tobetchi/6f11ad0020564a1e4853cb495713ac14 to your computer and use it in GitHub Desktop.
Save tobetchi/6f11ad0020564a1e4853cb495713ac14 to your computer and use it in GitHub Desktop.
openFrameworks MIDI recieve sample
#include "ofMain.h"
#include "ofApp.h"
int main( ){
ofSetupOpenGL(1024, 768, OF_WINDOW);
ofRunApp(new ofApp());
}
#include "ofApp.h"
void ofApp::setup() {
// MIDI Setup
midiIn.listPorts();
midiIn.openPort("Launchpad");
midiIn.addListener(this);
}
void ofApp::newMidiMessage(ofxMidiMessage& msg) {
std::cout << "status:" << ofxMidiMessage::getStatusString(msg.status);
std::cout << " channel:" << msg.channel;
std::cout << " pitch:" << msg.pitch;
std::cout << " velocity:" << msg.velocity;
std::cout << " control:" << msg.control;
std::cout << " value:" << msg.value;
std::cout << " dt:" << msg.deltatime;
std::cout << std::endl;
}
#pragma once
#include "ofMain.h"
#include "ofxMidi.h"
class ofApp : public ofBaseApp, public ofxMidiListener {
public:
void setup();
private:
ofxMidiIn midiIn;
void newMidiMessage(ofxMidiMessage& msg);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment