From 3a937c1566ab04b5e9ebf4712d47e19a704539e3 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 17 Dec 2018 22:16:49 +0000 Subject: POC --- gui/bin/data/settings.xml | 6 ++-- gui/src/ofApp.cpp | 63 +++++++++++++++++++++++++++++++++++++++-- gui/src/ofApp.h | 4 +-- oscReceiveExample/src/ofApp.cpp | 6 ++-- 4 files changed, 69 insertions(+), 10 deletions(-) diff --git a/gui/bin/data/settings.xml b/gui/bin/data/settings.xml index 4e3523f..1634e84 100644 --- a/gui/bin/data/settings.xml +++ b/gui/bin/data/settings.xml @@ -18,10 +18,10 @@ - -17.628570557 - -187.371429443 + 151.228576660 + -457.628570557 -2.863990068 +1.503718138 0 30 diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp index 7641664..2b7a9e1 100644 --- a/gui/src/ofApp.cpp +++ b/gui/src/ofApp.cpp @@ -5,13 +5,14 @@ const ofPoint outputWindowSize=ofPoint(1200,900); const float guiScale=560.0f/4096.0f; -string sourcenames[5]={ +string sourcenames[6 ]={ "TEST", // "NDI", "Player", "SVG outlines", "SVG segmenters", - "Audio" + "Audio", + "OSC" }; //-------------------------------------------------------------- @@ -176,6 +177,10 @@ void ofApp::setup(){ outputScale=XML.getValue("SCALE", 1.0f); + cout << "listening for osc messages on port " << PORT << "\n"; + receiver.setup(PORT); + + ofSetFrameRate(60); } //====================== audio functions @@ -667,6 +672,22 @@ void ofApp::drawOutput(ofEventArgs & args){ scale_amt=(((sin(scale_phase)*0.5)+0.5)*(xf_scale_max-xf_scale_min))+xf_scale_min; + int received_frames=0; + int numpoints=0; + ofBuffer buf; + + while(receiver.hasWaitingMessages()){ + ofxOscMessage m; + receiver.getNextMessage(m); + if(m.getAddress() == "/points"){ + numpoints=m.getArgAsInt(0); + buf=m.getArgAsBlob(1); + received_frames++; + } + } + + string stats_message; + switch (source){ case TEST:{ ofMatrix4x4 m = ofMatrix4x4::newIdentityMatrix(); @@ -814,6 +835,42 @@ void ofApp::drawOutput(ofEventArgs & args){ polyOutput=plotter.output(scalePlot,decayPlot); break; } + case OSC:{ + + if (numpoints){ + + char* data=buf.getData(); + float* floats=(float*) data; + uint32_t* ints=(uint32_t*)(floats); + oscpoly.clear(); + colourPolyline poly; + ofColor lastcol; + for (int i=0;i>8,(pixel[1]*alpha)>>8,(pixel[0]*alpha)>>8):lastcol; + lastcol=col; + + poly.addVertex( + floats[i*4]*ofGetWidth(), + floats[i*4+1]*ofGetHeight(), + col); + if (!alpha&&poly.size()){ + poly.addVertex( + floats[i*4]*ofGetWidth(), + floats[i*4+1]*ofGetHeight(), + ofColor(0,0,0)); + oscpoly.push_back(poly); + poly.clear(); + } + } + std::cout<<"created "< oscpoly; }; diff --git a/oscReceiveExample/src/ofApp.cpp b/oscReceiveExample/src/ofApp.cpp index cd76ce5..3a83147 100644 --- a/oscReceiveExample/src/ofApp.cpp +++ b/oscReceiveExample/src/ofApp.cpp @@ -204,7 +204,7 @@ void ofApp::draw(){ ofSetColor(255,255,255); - if(poly.size()) poly.drawDebug(SHOWBLACK); + if(poly.size()) poly.drawDebug(debug_level); ofSetColor(255,255,255); @@ -231,10 +231,10 @@ void ofApp::keyPressed(int key){ create_polys+=10; break; case '[': - debug_level=max(NODEBUG,debug_level-1); + debug_level=max(NODEBUG,(line_debug_level)(debug_level-1)); break; case ']': - debug_level=min(SHOWALL,debug_level+1); + debug_level=min(CONSOLE,(line_debug_level)(debug_level+1)); break; } -- cgit v1.2.3