summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2018-12-17 22:16:49 +0000
committerTim Redfern <tim@getdrop.com>2018-12-17 22:16:49 +0000
commit3a937c1566ab04b5e9ebf4712d47e19a704539e3 (patch)
tree7a6adca7ea01b9e5272976c238c275b69346ca4d /gui
parent1369877fa5dfa46f54cc3ffc3d231e661505105c (diff)
POC
Diffstat (limited to 'gui')
-rw-r--r--gui/bin/data/settings.xml6
-rw-r--r--gui/src/ofApp.cpp63
-rw-r--r--gui/src/ofApp.h4
3 files changed, 66 insertions, 7 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 @@
</p3>
</WARP>
<POSITION>
- <X>-17.628570557</X>
- <Y>-187.371429443</Y>
+ <X>151.228576660</X>
+ <Y>-457.628570557</Y>
</POSITION>
-<SCALE>2.863990068</SCALE>
+<SCALE>1.503718138</SCALE>
<laser>
<power>0</power>
<intensity>30</intensity>
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<numpoints;i++){
+ uint8_t* pixel=(uint8_t*)(&ints[i*4+3]);
+ uint32_t alpha=(uint32_t)pixel[3];
+ ofColor col=alpha?ofColor((pixel[2]*alpha)>>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.size()<<" polygons"<<std::endl;
+
+ stats_message=ofToString(received_frames)+": "+ofToString(oscpoly.size()); //+" dumped: "+ofToString(dumped_frames);
+ }
+ polyOutput=oscpoly;
+ break;
+ }
default: {
break;
}
@@ -959,10 +1016,12 @@ void ofApp::keyPressed(ofKeyEventArgs &args){
if (source<0){
source=Source_end-1;
}
+ std::cout << sourcenames[source] << std::endl;
break;
}
case 'p':{
source=(source+1)%Source_end;
+ std::cout << sourcenames[source] << std::endl;
break;
}
case 'w':{
diff --git a/gui/src/ofApp.h b/gui/src/ofApp.h
index b426cb2..6d6932c 100644
--- a/gui/src/ofApp.h
+++ b/gui/src/ofApp.h
@@ -58,7 +58,7 @@ enum Source{
Source_end
};
-
+#define PORT 7070
@@ -277,6 +277,6 @@ class ofApp: public ofBaseApp, public ofxMidiListener {
ofxOscReceiver receiver;
-
+ vector<colourPolyline> oscpoly;
};