diff options
| author | Tim Redfern <tim@getdrop.com> | 2022-10-20 23:16:40 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@getdrop.com> | 2022-10-20 23:16:40 +0100 |
| commit | 17275ae5aee3935920df1cab45652aa20a0b4513 (patch) | |
| tree | 4235285a72cb60a4c3e889f0c0da3f85c202865c /pluginchooser/src/pluginpanel.h | |
| parent | 0067bb80914da6e04f7f821fbe7b1fcb76fda799 (diff) | |
getting somewhere
Diffstat (limited to 'pluginchooser/src/pluginpanel.h')
| -rw-r--r-- | pluginchooser/src/pluginpanel.h | 81 |
1 files changed, 63 insertions, 18 deletions
diff --git a/pluginchooser/src/pluginpanel.h b/pluginchooser/src/pluginpanel.h index 6e8e07d..82c7e46 100644 --- a/pluginchooser/src/pluginpanel.h +++ b/pluginchooser/src/pluginpanel.h @@ -14,32 +14,78 @@ struct float_param { class loader { public: - loader(string _n,AChaosBase *_plugin,vector<float_param> _params={}){ + loader(string _n,AChaosBase *_plugin,int _dimension,int _input_index,vector<float_param> _params={}){ name=_n; plugin=_plugin; + dimension=_dimension; + input_index=_input_index; params=_params; + iv.resize(_params.size()+_dimension); } string name; AChaosBase *plugin; vector<float_param> params; + vector<REAL> iv; + int dimension; + int input_index; + void update(vector<ofParameter<float> > _params){ + int in=input_index==0?dimension:0; + for (int i=0;i<min(_params.size(),params.size());i++,in++){ + iv[in]=_params[i]; + params[i].val=_params[i]; + } + } + ofVec2f calc(ofVec2f point){ + iv[input_index]=point.x; + iv[input_index+1]=point.y; + plugin->set(iv); + plugin->calc(); + vector<REAL> ov=plugin->getVec(); + return ofVec2f(ov[0],ov[1]); + } }; +/* +some plugins have more or less dimensions of input/output +params are ordered differently +some allow t/dt control + +-> tag the first input dimension index +-> tag the first param index +-> tag the number of params + +*/ + class pluginPanel : public ofxPanel { public: pluginPanel(){ ofRegisterKeyEvents(this, defaultEventsPriority); plugins={ - loader("baker",&baker), - loader("clifford",&clifford,{ - {"a",0.0f,-1.0f,1.0f}, - {"b",0.0f,-1.0f,1.0f}, - {"c",0.0f,-1.0f,1.0f}, - {"d",0.0f,-1.0f,1.0f} + //loader("baker",&baker), //2,1 + loader("clifford",&clifford, + 2,4, //number of dimensions and index + { //4,2 a b c d nx ny + {"a",-1.4f,-2.0f,2.0f}, + {"b",1.6f,-2.0f,2.0f}, + {"c",1.0f,-2.0f,2.0f}, + {"d",0.7f,-2.0f,2.0f} + } + ), + //loader("collatz",&collatz), //3,1 + //loader("duffing",&duffing,{ //7,2 a b w nx ny dt t time, could be real time or magnified + // } //seems perfect + //), + //loader("ginger",&ginger), //3,2 seed nx ny maybe + loader("henon",&henon, //4,2 a b nx ny perfect + 2,2, + { + {"a",1.4f,-0.0f,2.0f}, + {"b",0.3f,-1.0f,1.0f} } ) }; index=0; - update(); + select(); } bool mouseMoved(ofMouseEventArgs & args){ if (args.x>getPosition().x&& @@ -71,7 +117,7 @@ class pluginPanel : public ofxPanel { if (index<0){ index=plugins.size()-1; } - update(); + select(); break; } case 57358:{ //right @@ -79,7 +125,7 @@ class pluginPanel : public ofxPanel { if (index==plugins.size()){ index=0; } - update(); + select(); break; } default: @@ -91,7 +137,7 @@ class pluginPanel : public ofxPanel { bool keyReleased(ofKeyEventArgs & args){ //required in order to call ofRegisterKeyEvents } - void update(){ + void select(){ ofLog()<<"selected "<<plugins[index].name; clear(); add(label.setup(plugins[index].name)); @@ -110,13 +156,12 @@ class pluginPanel : public ofxPanel { params.push_back(param); } } + void update(){ + //push params to plugin + plugins[index].update(params); + } ofVec2f calc(ofVec2f point){ - REAL iv[6]={point.x,point.y}; - for (int i=0;i<params.size();i++){ - iv[i+2]=params[i]; - } - plugins[index].plugin->set(iv); - plugins[index].plugin->calc(); + return plugins[index].calc(point); } private: int index; @@ -126,6 +171,6 @@ private: ofParameter<bool> active; ofParameter<float> amount; vector<ofParameter<float> > params; - AChaosBaker baker; AChaosClifford clifford; + AChaosHenon henon; };
\ No newline at end of file |
