From efd0d6840649caf02f7b242a505bcae3bc7aa986 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 28 May 2018 23:35:47 +0100 Subject: making fractal --- gistanalysis/addons.make | 1 + gistanalysis/notes | 3 ++ gistanalysis/src/ofApp.cpp | 12 +++++-- gistanalysis/src/ofApp.h | 90 +++++++++++++++++++++++++++++++++++----------- 4 files changed, 83 insertions(+), 23 deletions(-) (limited to 'gistanalysis') diff --git a/gistanalysis/addons.make b/gistanalysis/addons.make index 1b485c8..e66c6c6 100644 --- a/gistanalysis/addons.make +++ b/gistanalysis/addons.make @@ -4,3 +4,4 @@ ofxHistoryPlot ofxHelios ofxMidi ofxGui +ofxAChaoslib diff --git a/gistanalysis/notes b/gistanalysis/notes index 995c22c..e55b867 100644 --- a/gistanalysis/notes +++ b/gistanalysis/notes @@ -79,5 +79,8 @@ n- scriptable transforms - fix length overlap - some kind of svg thing for ambulance with audio animation +scale isn't scaling from centre +rotate isn't working at all +need to hook up midi diff --git a/gistanalysis/src/ofApp.cpp b/gistanalysis/src/ofApp.cpp index 1ee92d1..cf3240c 100644 --- a/gistanalysis/src/ofApp.cpp +++ b/gistanalysis/src/ofApp.cpp @@ -49,6 +49,8 @@ void ofApp::setup(){ gui.setup("panel"); // 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(scalePlot.set("scale plot", 0.1f, 0.0f, 1.0f )); @@ -56,7 +58,8 @@ void ofApp::setup(){ 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))); /* //add special crest graph @@ -123,6 +126,9 @@ void ofApp::updateOutput(ofEventArgs& e){ 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); } } @@ -152,6 +158,8 @@ void ofApp::updateOutput(ofEventArgs& e){ if (mfccSmoothed[f] < mfcc[i] || damping >.999f){ mfccSmoothed[f] = mfcc[i]; } + + // let the smoothed value sink to zero: mfccSmoothed[i] *= damping; f++; @@ -289,7 +297,7 @@ void ofApp::drawOutput(ofEventArgs & args){ ofMatrix4x4 t; t.makeTranslationMatrix(xform->x,xform->y,0); ofMatrix4x4 r; - r.makeRotationMatrix(rotate,ofVec3f(0,1,0)); + r.makeRotationMatrix(rotate,ofVec3f(0,1,07)); ofMatrix4x4 s; r.makeScaleMatrix(scale->x,scale->y,1.0f); diff --git a/gistanalysis/src/ofApp.h b/gistanalysis/src/ofApp.h index 52d67cd..7dd2245 100644 --- a/gistanalysis/src/ofApp.h +++ b/gistanalysis/src/ofApp.h @@ -2,6 +2,7 @@ #include "ofMain.h" #include "ofxHelios.h" +#include "ofxAChaoslib.h" #include "lineTransformer.h" //This is included only as a way of getting buffer out of loaded sound. @@ -24,10 +25,13 @@ class Audioplotter{ //how best to handle transforms - maybe pass in a transform to be added to 2nd and subsequent //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){ + Audioplotter(int _size=1,bool _joined=true,bool _bars=false,int _width=2){ set_size(_size); set_joined(_joined); - colour=ofColor(255,255,255); + set_bars(_bars); + set_width(_width); + startColour=ofColor(255,255,255); + endColour=ofColor(0,0,0); } void set_size(int _size){ history_size=_size; @@ -35,6 +39,22 @@ public: void set_joined(bool _joined){ joined=_joined; } + void set_bars(bool _bars){ + bars=_bars; + } + void set_width(int _width){ + width=_width; + } + void set_colours(const ofColor _start,const ofColor _end){ + 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); + } vector output(const ofMatrix4x4 xform=ofMatrix4x4(1.0f,0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f,0.0f, 0.0f,0.0f,1.0f,0.0f, @@ -42,37 +62,51 @@ public: float scale=1.0f, float decay=-1.0f){ //destructive or non? - float fadefactor=decay<0.0f?1.0f-(1.0f/history_size):decay; - - vector outdata; - - for (int i=0;i newdata; - for (int j=0;j outdata; + + for (int i=0;i newdata; + for (int j=0;j &audio,int number){ int num=min(number,(int)audio.size()); int step=audio.size()/(num+1); vector newdata; - if (joined){ + if (chaos){ + + } + else if (joined){ colourPolyline line; - for (int i=0;i> data; bool joined; + bool bars; int history_size; - ofColor colour; + int width; + ofColor startColour; + ofColor endColour; + + AChaosIkeda attractor; + float chaos_amount; + }; @@ -174,6 +215,8 @@ class ofApp : public ofBaseApp, public ofxMidiListener{ ofxPanel gui; ofParameter fft; ofParameter joined; + ofParameter bars; + ofParameter capWidth; ofParameter numPoints; ofParameter numPlots; ofParameter scalePlot; @@ -181,5 +224,10 @@ class ofApp : public ofBaseApp, public ofxMidiListener{ ofParameter xform; ofParameter rotate; ofParameter scale; + ofParameter startColour; + ofParameter endColour; + + ofxPanel chaospanel; + ofParameter bars; }; -- cgit v1.2.3