summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2018-07-04 09:29:52 +0100
committerTim Redfern <tim@getdrop.com>2018-07-04 09:29:52 +0100
commitb720d6d730a0d23425ca4c3ef7c156e1c7760ea1 (patch)
treea3f60eef23a131ce53bf1f35fa9ce75beffa56cc /gui
parentefda4fd446da89ccd3909c988b6c1e932efa24bb (diff)
plugin architecture
Diffstat (limited to 'gui')
-rw-r--r--gui/src/AudioPlotter.h37
-rw-r--r--gui/src/ofApp.cpp9
-rw-r--r--gui/src/ofApp.h64
3 files changed, 87 insertions, 23 deletions
diff --git a/gui/src/AudioPlotter.h b/gui/src/AudioPlotter.h
index 716a1dd..c5774ff 100644
--- a/gui/src/AudioPlotter.h
+++ b/gui/src/AudioPlotter.h
@@ -6,31 +6,45 @@
class AChaosplugin{
public:
AChaosBase* plugin;
- vector <REAL> params;
+ vector <ofParameter <float>> params;
string name;
AChaosplugin(AChaosBase* _plugin,string _name,vector <REAL> _params={0,0,0,0,0,0}){
plugin=_plugin;
- params=_params;
name=_name;
+ //plugin.setup();
+ load_defaults();
+ ofLog()<<"constructor "<<name;
+ }
+ void load_defaults(){
+ params.clear();
+ for (auto i:plugin->iv){
+ ofLog()<<"iv: "<<i;
+ params.push_back(ofParameter <float>().set(ofToString(i),i,0,i*5));
+ }
}
};
class Chaos{
public:
- vector <AChaosplugin> plugins;
+ vector <AChaosplugin*> plugins;
vector <vector <REAL>> params;
int whichplugin;
ofParameter <string> name;
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"));
+ //can only use those that have 2 output params?
+ //or just make it 1 dimensional? only affect the x axis?
+ plugins.push_back(new AChaosplugin(new AChaosBaker(),"Baker"));
+ plugins.push_back(new AChaosplugin(new AChaosClifford(),"Clifford"));
+ plugins.push_back(new AChaosplugin(new AChaosCollatz(),"Collatz"));
+ plugins.push_back(new AChaosplugin(new AChaosDuffing(),"Duffing"));
+ plugins.push_back(new AChaosplugin(new AChaosGinger(),"Ginger"));
+ plugins.push_back(new AChaosplugin(new AChaosHenon(),"Henon"));
whichplugin=0;
update_name();
}
+ AChaosplugin &get(){
+ return *plugins[whichplugin];
+ }
void next(){
whichplugin=(whichplugin+1)%plugins.size();
update_name();
@@ -43,10 +57,11 @@ class Chaos{
update_name();
}
void update_name(){
- name=plugins[whichplugin].name;
+ name=plugins[whichplugin]->name;
+ //save old params & load new
}
std::string &get_name(){
- return plugins[whichplugin].name;
+ return plugins[whichplugin]->name;
}
};
diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp
index caa9195..cfa9df1 100644
--- a/gui/src/ofApp.cpp
+++ b/gui/src/ofApp.cpp
@@ -73,14 +73,7 @@ void ofApp::setup(){
onset_frame=0;
chaosgui.setup("chaos","",460,820);
- chaosgui.add(plugin_label.setup(chaosgui.chaosloader.name));
- chaosgui.add(plotter.usechaos.set("use",false));
- chaosgui.add(plotter.chaosamount.set("amount", 0.0f, -0.1f, 0.1f));
- chaosgui.add(plotter.chaosscale.set("scale", 100.0f, 1.0f, 1000.0f));
- chaosgui.add(plotter.chaos_a.set("a", 0.85f, 0.0f, 10.0f));
- chaosgui.add(plotter.chaos_b.set("b", 0.9f, 0.0f, 10.0f));
- chaosgui.add(plotter.chaos_k.set("k", 0.4f, 0.0f, 10.0f));
- chaosgui.add(plotter.chaos_p.set("p", 7.7f, 0.0f, 10.0f));
+ chaosgui.update_sliders();
drawgui.setup("drawing","",10,0);
drawgui.add(contour_threshold.setup("threshold", 140, 0, 255));
diff --git a/gui/src/ofApp.h b/gui/src/ofApp.h
index 4d766e9..ddc54d7 100644
--- a/gui/src/ofApp.h
+++ b/gui/src/ofApp.h
@@ -43,6 +43,9 @@ class chaosPanel : public ofxPanel {
ofRegisterKeyEvents(this, defaultEventsPriority);
}
bool isSelected;
+ ofParameter<bool> active;
+ ofParameter<float> amount;
+ ofParameter<float> scale; //?per plugin??
bool mouseMoved(ofMouseEventArgs & args){
if (args.x>getPosition().x&&
args.x-getPosition().x<getWidth()&&
@@ -82,12 +85,66 @@ class chaosPanel : public ofxPanel {
bool keyReleased(ofKeyEventArgs & args){
//required in order to call ofRegisterKeyEvents
}
+ //this is a bit tangled
+ /*
+ audioplotter stores drawings that it extracts from audio
+ chaosloader manages a set of plugins that affect polylines
+ audio plotter calls chaosloader a set of lines and it affects them
+ chaosloader should own it's own params (use,scale,amount)
+ should expose compute(vector polyline)
+
+ so we could have
+
+ audio source
+ <>
+ transformer
+ <>
+ chaos
+ <>
+ drawing
+
+ */
+
+ int shown=0;
+
void update_sliders(){
- //delete sliders
+ clear();
+ add(plugin_label.setup(chaosloader.name));
+ add(active.set("use",false));
+ add(amount.set("amount", 0.0f, -0.1f, 0.1f));
+ add(scale.set("scale", 100.0f, 1.0f, 1000.0f));
+ //delete variable sliders, is this even possible?
+
//get number of params
- //create sliders with stored values, names
+ //create sliders with stored values
+ //how to ignore the nx & ny params? I think nx & ny can be moved to the end
+ //I think nx & ny (or value) can be removed and use ov[0] & ov[1] / ov[0]
+ //add(plotter.chaos_a.set("a", 0.85f, 0.0f, 10.0f));
+ //add(plotter.chaos_b.set("b", 0.9f, 0.0f, 10.0f));
+ //add(plotter.chaos_k.set("k", 0.4f, 0.0f, 10.0f));
+ //add(plotter.chaos_p.set("p", 7.7f, 0.0f, 10.0f));
+
+ //can the float sliders be dynamically generated?
+ //get the number of parameters in the selected plugin - iv.size()
+ //create the parameters when the object is initialised
+ //when switching to the plugin, add sliders for the parameters
+ //if we reorder the params will the plugns function the same?
+
+ int size=chaosloader.get().params.size();
+
+ if (shown!=size) {
+ ofLog()<<size<<" items";
+ shown=size;
+ }
+
+ for (auto p:chaosloader.get().params){
+ add(p);
+ }
}
+private:
Chaos chaosloader;
+ ofxLabel plugin_label;
+ ofParameter<string> plugin_name;
};
@@ -185,8 +242,7 @@ class ofApp: public ofBaseApp, public ofxMidiListener {
//======== chaos gui
chaosPanel chaosgui;
- ofxLabel plugin_label;
- ofParameter<string> plugin_name;
+
// best architecture for the chaos plugin?
// how to use it on an arbitrary set of data