From b720d6d730a0d23425ca4c3ef7c156e1c7760ea1 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 4 Jul 2018 09:29:52 +0100 Subject: plugin architecture --- gui/src/AudioPlotter.h | 37 ++++++++++++++++++++--------- gui/src/ofApp.cpp | 9 +------ gui/src/ofApp.h | 64 ++++++++++++++++++++++++++++++++++++++++++++++---- 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 params; + vector > params; string name; AChaosplugin(AChaosBase* _plugin,string _name,vector _params={0,0,0,0,0,0}){ plugin=_plugin; - params=_params; name=_name; + //plugin.setup(); + load_defaults(); + ofLog()<<"constructor "<iv){ + ofLog()<<"iv: "<().set(ofToString(i),i,0,i*5)); + } } }; class Chaos{ public: - vector plugins; + vector plugins; vector > params; int whichplugin; ofParameter 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 active; + ofParameter amount; + ofParameter scale; //?per plugin?? bool mouseMoved(ofMouseEventArgs & args){ if (args.x>getPosition().x&& args.x-getPosition().x + 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()< plugin_name; }; @@ -185,8 +242,7 @@ class ofApp: public ofBaseApp, public ofxMidiListener { //======== chaos gui chaosPanel chaosgui; - ofxLabel plugin_label; - ofParameter plugin_name; + // best architecture for the chaos plugin? // how to use it on an arbitrary set of data -- cgit v1.2.3