Skip to content

Instantly share code, notes, and snippets.

@tobetchi

tobetchi/main.cpp

Created Sep 28, 2016
Embed
What would you like to do?
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