Created
September 28, 2016 08:19
-
-
Save tobetchi/fa0638c287c6c0ebee688ede356b9959 to your computer and use it in GitHub Desktop.
openFrameworks OSC recieve sample Raw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofMain.h" | |
#include "ofApp.h" | |
int main() { | |
ofSetupOpenGL(1024, 768, OF_WINDOW); | |
ofRunApp(new ofApp()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofApp.h" | |
void ofApp::setup() { | |
// OSC Setup | |
receiver.setup(PORT); | |
} | |
void ofApp::update() { | |
// OSC Message Recieve | |
while (receiver.hasWaitingMessages()) { | |
ofxOscMessage m; | |
receiver.getNextMessage(m); | |
string address = m.getAddress(); | |
string arg = ""; | |
for (int i = 0; i < m.getNumArgs(); i++) { | |
// 引数の型名を取得 | |
arg += m.getArgTypeName(i); | |
arg += ":"; | |
// 引数の値を取得 (IntとFloatとStringのみ) | |
if (m.getArgType(i) == OFXOSC_TYPE_INT32) { | |
arg += ofToString(m.getArgAsInt32(i)); | |
} else if (m.getArgType(i) == OFXOSC_TYPE_FLOAT) { | |
arg += ofToString(m.getArgAsFloat(i)); | |
} else if (m.getArgType(i) == OFXOSC_TYPE_STRING) { | |
arg += m.getArgAsString(i); | |
} else { | |
arg += "unknown"; | |
} | |
} | |
std::cout << address << " " << arg << std::endl; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "ofMain.h" | |
#include "ofxOsc.h" | |
#define PORT 7001 | |
class ofApp : public ofBaseApp { | |
public: | |
void setup(); | |
void update(); | |
private: | |
ofxOscReceiver receiver; | |
ofxOscMessage m; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment