From aca6161b1c8ee632e388731084b6158a1483e71a Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 30 Sep 2022 23:24:23 +0100 Subject: head wreck --- passadesgui/src/lineSegmenter.cpp | 2 +- passadesgui/src/lineSegmenter.h | 8 ++- passadesgui/src/ofApp.cpp | 139 +++++++++++++++++++++++++++++++++++--- passadesgui/src/ofApp.h | 6 +- 4 files changed, 139 insertions(+), 16 deletions(-) (limited to 'passadesgui/src') diff --git a/passadesgui/src/lineSegmenter.cpp b/passadesgui/src/lineSegmenter.cpp index 3f434b1..495190d 100644 --- a/passadesgui/src/lineSegmenter.cpp +++ b/passadesgui/src/lineSegmenter.cpp @@ -84,7 +84,7 @@ const vector & colourLineSegmenter::getSegments(int num,float c segment.addVertex(line.getPointAtIndexInterpolated(endIndex),line.getColourAtIndexInterpolated(endIndex)); } else { - segment.addVertex(line.getPointAtIndexInterpolated(endIndex),line.getColourAtIndexInterpolated(endIndex) ); + segment.addVertex(line.getPointAtIndexInterpolated(endIndex),line.getColourAtIndexInterpolated(endIndex)); } segments.push_back(segment); } diff --git a/passadesgui/src/lineSegmenter.h b/passadesgui/src/lineSegmenter.h index 2467c6a..6aa7bc7 100644 --- a/passadesgui/src/lineSegmenter.h +++ b/passadesgui/src/lineSegmenter.h @@ -26,15 +26,17 @@ class colourLineSegmenter{ public: colourLineSegmenter(colourPolyline &_line){ line=_line; + //this was commented out //if (line.isClosed()){ // line.addVertex(line[0]); //} } colourLineSegmenter(ofPolyline &_line,const ofColor color=ofColor(255,255,255)){ line=colourPolyline(_line,color); - if (_line.isClosed()){ - line.addVertex(line[0],line.getColourAt(0)); - } + //if (_line.isClosed()){ + // line.addVertex(line[0],line.getColourAt(0)); + //} + //commenting this out does not help weird issie when segmenting } const vector &getSegments(int num,float coverage, float phase); colourPolyline getPoly(){ diff --git a/passadesgui/src/ofApp.cpp b/passadesgui/src/ofApp.cpp index 36e0785..e8b8a91 100644 --- a/passadesgui/src/ofApp.cpp +++ b/passadesgui/src/ofApp.cpp @@ -91,7 +91,7 @@ void ofApp::setup(){ drawgui.add(video_speed.setup("playback speed", 1.0, 0.0, 3.0)); drawgui.add(shapes_randomise.setup("randomise shapes", true)); drawgui.add(shapes_amount.setup("shapes amount", 0.2, 0.0, 0.8)); - drawgui.add(shapes_duration.setup("shape duration", 5, 0, 25)); + drawgui.add(shapes_duration.setup("shape duration", 5, 0, 250)); drawgui.add(use_mask.setup("use mask", true)); drawgui.add(invert_mask.setup("invert mask", false)); drawgui.add(use_segmenter.setup("use segmenter", false)); @@ -115,7 +115,7 @@ void ofApp::setup(){ audiogui.add(plotter.bars.set("bars",true)); audiogui.add(plotter.mirror.set("mirror",false)); audiogui.add(plotter.width.set("point width", 2, 1, 256)); - audiogui.add(plotter.num_points.set("num points", 50, 1, 64)); + audiogui.add(plotter.num_points.set("num points", 50, 1, 512)); audiogui.add(plotter.history_size.set("num plots", 5, 1, 64)); audiogui.add(plotter.translate.set("translate",ofVec2f(0,0),ofVec2f(-50,-50),ofVec2f(50,50))); audiogui.add(plotter.rotate.set("rotate",0.0f,-10.0f,10.0f)); @@ -128,7 +128,7 @@ void ofApp::setup(){ //============================ MIDI midiIn.listInPorts(); - midiIn.openPort(0); + midiIn.openPort(1); midiIn.addListener(this); //======================================= //positioning interface @@ -755,6 +755,54 @@ void ofApp::drawOutput(ofEventArgs & args){ break; } case SVG_outlines:{ + if (!use_onset||onset_framegetSegments(segmenter_number,segmenter_length,phase); + for (auto segment=segments.begin();segment!=segments.end();segment++){ + //polyOutput.push_back(colourPolyline(*segment,ofColor(laser_R,laser_G,laser_B))); + polyOutput.push_back(*segment); + } + } + else { + //polyOutput.push_back(colourPolyline(shape->getPoly(),ofColor(laser_R,laser_G,laser_B))); + polyOutput.push_back(shape->getPoly()); + } + } + } + if (contour_useColour){ + vector newPolys; + for (auto p: polyOutput){ + newPolys.push_back(colourPolyline((ofPolyline)p,ofColor(laser_R,laser_G,laser_B))) ; + } + polyOutput=newPolys; + } + } + break; + } + /*{ if (shapes_randomise){ if (framecounter==0){ select_random_shapes(); @@ -764,11 +812,15 @@ void ofApp::drawOutput(ofEventArgs & args){ if (use_segmenter){ auto segments=segmenters[s].getSegments(segmenter_number,segmenter_length,phase); for (auto segment=segments.begin();segment!=segments.end();segment++){ - polyOutput.push_back(colourPolyline(*segment,ofColor(laser_R,laser_G,laser_B))); + polyOutput.push_back(contour_useColour? + colourPolyline(*segment): + colourPolyline(*segment,ofColor(laser_R,laser_G,laser_B))); } } else { - polyOutput.push_back(colourPolyline(segmenters[s].getPoly(),ofColor(laser_R,laser_G,laser_B))); + polyOutput.push_back(contour_useColour? + colourPolyline(segmenters[s].getPoly()): + colourPolyline(segmenters[s].getPoly(),ofColor(laser_R,laser_G,laser_B))); } } framecounter--; @@ -778,17 +830,21 @@ void ofApp::drawOutput(ofEventArgs & args){ if (use_segmenter){ auto segments=shape->getSegments(segmenter_number,segmenter_length,phase); for (auto segment=segments.begin();segment!=segments.end();segment++){ - polyOutput.push_back(colourPolyline(*segment,ofColor(laser_R,laser_G,laser_B))); + polyOutput.push_back(contour_useColour? + colourPolyline(*segment): + colourPolyline(*segment,ofColor(laser_R,laser_G,laser_B))); } } else { - polyOutput.push_back(colourPolyline(shape->getPoly(),ofColor(laser_R,laser_G,laser_B))); + polyOutput.push_back(contour_useColour? + colourPolyline(shape->getPoly()): + colourPolyline(shape->getPoly(),ofColor(laser_R,laser_G,laser_B))); } } } break; - } + }*/ case Audio:{ ofMatrix4x4 x=ofMatrix4x4(1.0f,0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f,0.0f, @@ -1068,7 +1124,49 @@ void ofApp::windowResized(int w, int h){ } -void ofApp::select_random_shapes(){ +float last_frame_time=0.0f; + +void ofApp::select_random_shapes(float duration,bool generate=true){ + float timedelta=ofGetElapsedTimef()-last_frame_time; + last_frame_time=ofGetElapsedTimef(); + //track how long each shape has been selected + for (int i=0;i0.0f){ + shape_selection_durations[i]=shape_selection_durations[i]-timedelta; + } + } + + shape_selection.clear(); + + for (int i=0;i0.0f){ + shape_selection.insert(i); + } + } + std::stringstream strom; + for (auto& s:shape_selection){ + strom << s <<":"< segmenters; + vector segmenters; // segmenters; // + vector shape_selection_durations; + set shape_selection; int framecounter; float phase,prev_time; //to calculate phase -- cgit v1.2.3