From 31a9010253e555091992515c09760ff4118a224b Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 31 May 2018 18:49:38 +0100 Subject: add audioplotter source --- gui/src/AudioPlotter.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ gui/src/AudioPlotter.h | 53 +++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 gui/src/AudioPlotter.cpp create mode 100644 gui/src/AudioPlotter.h (limited to 'gui/src') diff --git a/gui/src/AudioPlotter.cpp b/gui/src/AudioPlotter.cpp new file mode 100644 index 0000000..dba6765 --- /dev/null +++ b/gui/src/AudioPlotter.cpp @@ -0,0 +1,86 @@ +#include "Audioplotter.h" + +colourPolyline Audioplotter::compute_chaos(colourPolyline& poly,float colourFade){ + colourPolyline tempPoly; + for (int i=0;i Audioplotter::output(float scale,float decay){ + + ofMatrix4x4 x = ofMatrix4x4::newIdentityMatrix(); + x.translate((-ofGetWidth()/2)+((ofVec2f)translate).x,(-ofGetHeight()/2)+((ofVec2f)translate).y,0); + x.rotate(rotate,0,0,1); + //x.scale(((ofVec2f)scale).x,((ofVec2f)scale).y,1.0f); + x.translate((ofGetWidth()/2),(ofGetHeight()/2),0); + //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 &audio){ + int num=min((int)num_points,(int)audio.size()); + float step=((float)audio.size())/(num+1); + vector newdata; + if (joined){ + colourPolyline line; + if (bars){ + for (int i=0;ihistory_size) { + data.pop_back(); + } +} +int Audioplotter::numpoints(){ + int num=0; + for (auto d=data.begin();d!=data.end();d++){ + num+=d->size(); + } + return num; +} \ No newline at end of file diff --git a/gui/src/AudioPlotter.h b/gui/src/AudioPlotter.h new file mode 100644 index 0000000..a1495c3 --- /dev/null +++ b/gui/src/AudioPlotter.h @@ -0,0 +1,53 @@ +#include "ofMain.h" +#include "ofxAChaoslib.h" + +#include "lineTransformer.h" + +class Audioplotter{ + //store and draw a numbr of audio samples + //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,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){ + history_size=_size; + joined=_joined; + bars=_bars; + width=_width; + startColour=ofColor(255,255,255); + endColour=ofColor(0,0,0); + attractor.setup(); + } + colourPolyline compute_chaos(colourPolyline& poly,float colourFade=1.0f); + vector output(float scale=1.0f,float decay=-1.0f); + void addpoints(vector &audio); + int numpoints(); + + ofParameter joined; + ofParameter bars; + ofParameter width; + ofParameter history_size; + ofParameter num_points; + +//feedback transformation + ofParameter translate; + ofParameter rotate; + ofParameter scale; + + ofParameter startColour; + ofParameter endColour; + + ofParameter usechaos; + ofParameter chaosamount; + ofParameter chaos_a; + ofParameter chaos_b; + ofParameter chaos_k; + ofParameter chaos_p; + +private: + vector < vector> data; + AChaosIkeda attractor; + +}; \ No newline at end of file -- cgit v1.2.3