summaryrefslogtreecommitdiff
path: root/gui/src/AudioPlotter.h
blob: 40e3fc9bc55c8d19becd13f12f220e8722fe3b26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include "ofMain.h"
#include "ofxAChaoslib.h"

#include "lineTransformer.h"

class AChaosplugin{
    public:
        AChaosBase* plugin;
        vector <REAL> params;
        string name;
        AChaosplugin(AChaosBase* _plugin,string _name,vector <REAL> _params={0,0,0,0,0,0}){
            plugin=_plugin;
            params=_params;
            name=_name;
        }
};

class Chaos{
    public:
        vector <AChaosplugin> plugins;
        vector <vector <REAL>> params;
        int whichplugin;
        Chaos(){
            plugins.push_back(AChaosplugin(new AChaosBaker(),"Baker"));
            plugins.push_back(AChaosplugin(new AChaosClifford(),"Clifford"));
            plugins.push_back(AChaosplugin(new AChaosCollatz(),"Collatz"));
            plugins.push_back(AChaosplugin(new AChaosDuffing(),"Duffing"));
            plugins.push_back(AChaosplugin(new AChaosGinger(),"Ginger"));
            plugins.push_back(AChaosplugin(new AChaosHenon(),"Henon"));
            whichplugin=0;
        }
        void next(){
            whichplugin=(whichplugin+1)%plugins.size();
        }
        void previous(){
            whichplugin=whichplugin-1;
            if (whichplugin<0){
                whichplugin=plugins.size()-1;
            }
        }
        std::string &get_name(){
            return plugins[whichplugin].name;
        }
};

/*
    vector <string> names = { 
        "Baker",
        "Clifford",
        "Collatz",
        "Duffing",
        "Ginger",
        "Henon",
        "HenonF",
        "HenonHeilles",
        "HenonPhase",
        "Ikeda",
        "Jong",
        "Logistic",
        "Logistic1",
        "Lorenz",
        "LorenzEuler",
        "Lyapunov",
        "NavierStokes",
        "NavierStokesEuler",
        "Rossler",
        "Stein",
        "Stein1",
        "Torus",
        "Verhulst" 
    };
}
*/

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 <colourPolyline> output(float scale=1.0f,float decay=-1.0f);
    void addpoints(vector <float> &audio);
    void blankframe();
    int numpoints();

    ofParameter<bool> random;
    ofParameter<bool> joined;
    ofParameter<bool> bars;
    ofParameter<bool> mirror;
    ofParameter<int> width;
    ofParameter<int> history_size;
    ofParameter<int> num_points;

//feedback transformation
    ofParameter<ofVec2f> translate;
    ofParameter<float> rotate;
    ofParameter<ofVec2f> scale;

    ofParameter<ofColor> startColour;
    ofParameter<ofColor> endColour;

    ofParameter<bool> usechaos;
    ofParameter<float> chaosamount;
    ofParameter<float> chaosscale;
    ofParameter<float> chaos_a;
    ofParameter<float> chaos_b;
    ofParameter<float> chaos_k;
    ofParameter<float> chaos_p;

    Chaos chaosloader;

private:
    vector < vector<colourPolyline>> data;
    AChaosIkeda attractor;
    

};