From 347ff04d88cb01fb10eb26513031c03665e0068c Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Tue, 29 May 2018 23:38:41 +0100 Subject: some chaos --- gistanalysis/src/ofApp.cpp | 37 +++++++++++++------------ gistanalysis/src/ofApp.h | 69 ++++++++++++++++++++++++++-------------------- 2 files changed, 59 insertions(+), 47 deletions(-) (limited to 'gistanalysis') diff --git a/gistanalysis/src/ofApp.cpp b/gistanalysis/src/ofApp.cpp index cf3240c..bc3ec34 100644 --- a/gistanalysis/src/ofApp.cpp +++ b/gistanalysis/src/ofApp.cpp @@ -45,22 +45,29 @@ void ofApp::setup(){ mfccPlots.push_back(graph); } - - gui.setup("panel"); // most of the time you don't need a name but don't forget to call setup + plotter.setup(5,true); + + gui.setup("transform"); // most of the time you don't need a name but don't forget to call setup gui.add(fft.set("fft",false)); - gui.add(joined.set("joined",true)); - gui.add(bars.set("bars",true)); - gui.add(capWidth.set("point width", 2, 1, 256)); - gui.add(numPoints.set("num points", 50, 1, 256)); - gui.add(numPlots.set("num plots", 5, 1, 100)); + gui.add(plotter.joined.set("joined",true)); + gui.add(plotter.bars.set("bars",true)); + gui.add(plotter.width.set("point width", 2, 1, 256)); + gui.add(plotter.num_points.set("num points", 50, 1, 256)); + gui.add(plotter.history_size.set("num plots", 5, 1, 100)); gui.add(scalePlot.set("scale plot", 0.1f, 0.0f, 1.0f )); gui.add(decayPlot.set("decay", 0.9f, 0.0f, 1.0f )); gui.add(xform.set("xform",ofVec2f(0,0),ofVec2f(-50,-50),ofVec2f(50,50))); gui.add(rotate.set("rotate", 0.0f, -30.0f, 30.0f )); gui.add(scale.set("scale",ofVec2f(1.0f,1.0f),ofVec2f(0.5f,0.5f),ofVec2f(2.0f,2.0f))); - gui.add(startColour.set("start",ofColor(255,255,255))); - gui.add(endColour.set("end",ofColor(0,0,0))); - + gui.add(plotter.startColour.set("start",ofColor(255,255,255))); + gui.add(plotter.endColour.set("end",ofColor(0,0,0))); + + + + chaosgui.setup("chaos","",230,10); // most of the time you don't need a name but don't forget to call setup + chaosgui.add(plotter.usechaos.set("use",false)); + chaosgui.add(plotter.chaosamount.set("amount", 0.5f, 0.0f, 1.0f)); + /* //add special crest graph ofxHistoryPlot*crest = addGraph("CREST_AVG",1.0,ofColor(ofRandom(100)+150,ofRandom(100)+150,ofRandom(100)+150)); @@ -88,7 +95,7 @@ void ofApp::setup(){ loadSong("passades/1 The Ninth Set-sector1:sector2pt.1.aiff"); //loadSong("assets/sounds/Coltrane_acc_VUIMM.wav"); - plotter=Audioplotter(5,true); + laser.set_pts(MAX_POINTS); laser.set_intensity(LASER_INTENSITY); @@ -124,12 +131,7 @@ void ofApp::updateOutput(ofEventArgs& e){ processAudio(&output[0], bufferSize, 2); fftSmoothed = player.getFFT(); - plotter.set_joined(joined); - plotter.set_size(numPlots); - plotter.set_width(capWidth); - plotter.set_bars(bars); - plotter.set_colours(startColour.get(),endColour.get()); - plotter.addpoints(fft?fftSmoothed:centre,numPoints); + plotter.addpoints(fft?fftSmoothed:centre); } } @@ -192,6 +194,7 @@ void ofApp::updateOutput(ofEventArgs& e){ void ofApp::draw(){ ofBackground(0); gui.draw(); + chaosgui.draw(); } //-------------------------------------------------------------- void ofApp::drawOutput(ofEventArgs & args){ diff --git a/gistanalysis/src/ofApp.h b/gistanalysis/src/ofApp.h index 7dd2245..350e53f 100644 --- a/gistanalysis/src/ofApp.h +++ b/gistanalysis/src/ofApp.h @@ -26,12 +26,16 @@ class Audioplotter{ //how best to handle length of history data - fixed number that can be set, or line budget? public: Audioplotter(int _size=1,bool _joined=true,bool _bars=false,int _width=2){ + setup(_size,_joined,_bars,_width); + } + void setup(int _size=1,bool _joined=true,bool _bars=false,int _width=2){ set_size(_size); set_joined(_joined); set_bars(_bars); set_width(_width); startColour=ofColor(255,255,255); endColour=ofColor(0,0,0); + attractor.setup(); } void set_size(int _size){ history_size=_size; @@ -49,11 +53,17 @@ public: startColour=_start; endColour=_end; } - ofPoint compute_chaos(const ofPoint input){ - REAL iv[6]={input.x,input.x,attractor.a,attractor.b,attractor.k,attractor.p}; - attractor.set(iv); - attractor.calc(); - return ofPoint(attractor.nx,attractor.ny); + colourPolyline compute_chaos(colourPolyline& poly,float colourFade=1.0f){ + colourPolyline tempPoly; + for (int i=0;i output(const ofMatrix4x4 xform=ofMatrix4x4(1.0f,0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f,0.0f, @@ -70,7 +80,14 @@ public: vector newdata; for (int j=0;j &audio,int number){ - int num=min(number,(int)audio.size()); + void addpoints(vector &audio){ + int num=min((int)num_points,(int)audio.size()); int step=audio.size()/(num+1); vector newdata; - if (chaos){ - - } - else if (joined){ + if (joined){ colourPolyline line; if (bars){ for (int i=0;i joined; + ofParameter bars; + ofParameter width; + ofParameter history_size; + ofParameter num_points; + + ofParameter startColour; + ofParameter endColour; + + ofParameter usechaos; + ofParameter chaosamount; + private: vector < vector> data; - bool joined; - bool bars; - int history_size; - int width; - ofColor startColour; - ofColor endColour; - AChaosIkeda attractor; - float chaos_amount; }; - class ofApp : public ofBaseApp, public ofxMidiListener{ public: @@ -214,20 +231,12 @@ class ofApp : public ofBaseApp, public ofxMidiListener{ ofxPanel gui; ofParameter fft; - ofParameter joined; - ofParameter bars; - ofParameter capWidth; - ofParameter numPoints; - ofParameter numPlots; ofParameter scalePlot; ofParameter decayPlot; ofParameter xform; ofParameter rotate; ofParameter scale; - ofParameter startColour; - ofParameter endColour; - ofxPanel chaospanel; - ofParameter bars; + ofxPanel chaosgui; }; -- cgit v1.2.3