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 +-- 3 files changed, 66 insertions(+), 7 deletions(-) (limited to 'gui') 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; }; -- cgit v1.2.3