diff options
Diffstat (limited to 'gistanalysis/src')
| -rw-r--r-- | gistanalysis/src/ofApp.cpp | 12 | ||||
| -rw-r--r-- | gistanalysis/src/ofApp.h | 90 |
2 files changed, 79 insertions, 23 deletions
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 <colourPolyline> 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 <colourPolyline> outdata; - - for (int i=0;i<data.size();i++){ - vector <colourPolyline> newdata; - for (int j=0;j<data[i].size();j++){ - colourPolyline line=lineTransformer::polyLineTransform(xform,data[i][j],fadefactor); - newdata.push_back(line); - outdata.push_back(line); + float fadefactor=decay<0.0f?1.0f-(1.0f/history_size):decay; + + vector <colourPolyline> outdata; + + for (int i=0;i<data.size();i++){ + vector <colourPolyline> newdata; + for (int j=0;j<data[i].size();j++){ + colourPolyline line=lineTransformer::polyLineTransform(xform,data[i][j]); //,fadefactor); + line.setColour((line.getColourAt(0)*fadefactor)+(endColour*(1.0f-fadefactor))); + //ofLog() << "set colour to "<<col; + newdata.push_back(line); + outdata.push_back(line); + } + data[i]=newdata; } - data[i]=newdata; - } - return outdata; + return outdata; } void addpoints(vector <float> &audio,int number){ int num=min(number,(int)audio.size()); int step=audio.size()/(num+1); vector <colourPolyline> newdata; - if (joined){ + if (chaos){ + + } + else if (joined){ colourPolyline line; - for (int i=0;i<num;i++){ - line.addVertex(((step*(i+1))*ofGetWidth())/audio.size(),audio[step*(i+1)]*ofGetHeight(),colour); + if (bars){ + for (int i=0;i<num-1;i++){ + line.addVertex(((step*(i+1))*ofGetWidth())/audio.size(),audio[step*(i+1)]*ofGetHeight(),startColour); + line.addVertex(((step*(i+2))*ofGetWidth())/audio.size(),audio[step*(i+1)]*ofGetHeight(),startColour); + line.addVertex(((step*(i+2))*ofGetWidth())/audio.size(),audio[step*(i+2)]*ofGetHeight(),startColour); + } } + else { + for (int i=0;i<num;i++){ + line.addVertex(((step*(i+1))*ofGetWidth())/audio.size(),audio[step*(i+1)]*ofGetHeight(),startColour); + } + } newdata.push_back(line); } else{ for (int i=0;i<num;i++){ colourPolyline line; - line.addVertex(((step*(i+1))*ofGetWidth())/audio.size(),audio[step*(i+1)]*ofGetHeight(),colour); - line.addVertex(((step*(i+1))*ofGetWidth())/audio.size()+2,audio[step*(i+1)]*ofGetHeight(),colour); + line.addVertex(((step*(i+1))*ofGetWidth())/audio.size(),audio[step*(i+1)]*ofGetHeight(),startColour); + line.addVertex(((step*(i+1))*ofGetWidth())/audio.size()+width,audio[step*(i+1)]*ofGetHeight(),startColour); newdata.push_back(line); } } @@ -91,8 +125,15 @@ public: private: vector < vector<colourPolyline>> 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<bool> fft; ofParameter<bool> joined; + ofParameter<bool> bars; + ofParameter<int> capWidth; ofParameter<int> numPoints; ofParameter<int> numPlots; ofParameter<float> scalePlot; @@ -181,5 +224,10 @@ class ofApp : public ofBaseApp, public ofxMidiListener{ ofParameter<ofVec2f> xform; ofParameter<float> rotate; ofParameter<ofVec2f> scale; + ofParameter<ofColor> startColour; + ofParameter<ofColor> endColour; + + ofxPanel chaospanel; + ofParameter<bool> bars; }; |
