summaryrefslogtreecommitdiff
path: root/gistanalysis/src/ofApp.h
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2018-05-28 23:35:47 +0100
committerTim Redfern <tim@getdrop.com>2018-05-28 23:35:47 +0100
commitefd0d6840649caf02f7b242a505bcae3bc7aa986 (patch)
tree7ee3eb741b606fd0596c5123dcf0beb4086e1a20 /gistanalysis/src/ofApp.h
parent7d91c0a084e12591b8b51c3479811742ad1be952 (diff)
making fractal
Diffstat (limited to 'gistanalysis/src/ofApp.h')
-rw-r--r--gistanalysis/src/ofApp.h90
1 files changed, 69 insertions, 21 deletions
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;
};