Mercurial > hg > tweakathon2ios
diff MessageOrganiser.h @ 4:60b54ba87f6a
Preset save and recall works.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Thu, 16 Oct 2014 14:34:14 +0100 |
parents | c50de2d84732 |
children | 213df0baed47 |
line wrap: on
line diff
--- a/MessageOrganiser.h Fri Oct 10 18:22:14 2014 +0100 +++ b/MessageOrganiser.h Thu Oct 16 14:34:14 2014 +0100 @@ -32,6 +32,7 @@ #include "TextPanel.h" #include "CountdownText.h" #include "buttonPanel.h" +#include "presetManager.h" // event logger needs to know // which controls were showing in what mode @@ -51,6 +52,8 @@ extern EventLogger eventLogger; +extern PresetManager presetManager; + typedef boost::function<void(void)> AppModeChangeFunction; class MessageOrganiser { @@ -376,12 +379,18 @@ panel->setHintColor(c); }; + void setAllSlidersToValues(vector<int> values){ + for(int i = 0; i < values.size(); i++){ + setUIToParam(i, values[i]); + } + } // we want to set UI object void setUIToParam(int index, int value){ // e.g. from MIDI incoming, will handle both box and sliders... // theXY->setValueAndScale(candidateSynth.getParamValueForID(mids[i]), candidateSynth.getParamValueForID(mids[i+1])); UIElement* elem; // get the element if(panel->subElements.size() <= index){ + cout << "ERROR: index out of range for num sliders" << endl; return; } elem = panel->subElements[index]; @@ -645,6 +654,22 @@ showingHint = true; } } + if(mappingID == SAVE_PRESET_HIT){ + presetManager.savePreset("blah", candidateSynth.getAllParamValues()); + + } + if(mappingID == RECALL_PRESET_HIT){ + + loadPreset("blah"); + + + } + } + void loadPreset(string pname){ + + vector<int> values = presetManager.recallPreset(pname); + candidateSynth.setAllParams(values); + setAllSlidersToValues(values); } // called from UI void paramChangeCallback(int mappingID, int value){