diff ExpMessageOrganiser.h @ 17:2a7320a8cbed

explore mode shows stuff, can go thru saving various presets.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Tue, 21 Oct 2014 18:58:25 +0100
parents
children 36cdb73691da
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ExpMessageOrganiser.h	Tue Oct 21 18:58:25 2014 +0100
@@ -0,0 +1,109 @@
+//
+//  expMessageOrganiser.h
+//  riftathon
+//
+//  Created by Robert Tubb on 21/10/2014.
+//
+//
+
+#ifndef __riftathon__expMessageOrganiser__
+#define __riftathon__expMessageOrganiser__
+
+#include <iostream>
+#include "MessageOrganiser.h"
+#include "SequenceController.h"
+#include "globalVariables.h"
+
+extern ExplorePresetManager expPresetManager;
+
+class ExpMessageOrganiser : public MessageOrganiser {
+    
+public:
+    void init( PDSynthWrapper& cs, PDSynthWrapper& ts){
+        numParamsToUse = TOTAL_NUM_PARAMS;
+        MessageOrganiser::init(cs,ts);
+        
+        
+    }
+    void setup(){
+        // do stuff like load first slot
+        setupDefaultMapping();
+        expPresetManager.goToFirstEmptySlot();
+        showCurrentSlot();
+        
+  
+    }
+    
+    
+    void setupDefaultMapping(){
+        vector<int> mappingIDsForChangeableParams = getMappingIDsFromSynths();
+        
+        controlPanelType cpt = REVISITABLE;
+        vector<controllerType> elemList;
+        for(int i = 0; i < numParamsToUse; i++){
+            elemList.push_back(SLIDER);
+        }
+        
+        vector<UIElement*> UIElemHandles = panel->generateControls(elemList, cpt);
+        
+        mapSlidersToParams(UIElemHandles, mappingIDsForChangeableParams);
+        
+        bottomPanel->show();
+    }
+    
+    vector<int> getMappingIDsFromSynths(){
+        vector<int> index;
+        for(int i = 0; i < numParamsToUse; i++){
+            index.push_back(i);
+        }
+        vector<int> mids = candidateSynth.getMappingIDForIndices(index);
+        
+        return mids;
+    }
+    
+    void showCurrentSlot(){
+        currentPresetSlot =  expPresetManager.getCurrentPresetSlot();
+        presetIconPanel->setTextAndImage(currentPresetSlot->name, currentPresetSlot->getImage());
+    }
+    
+    void loadPreset(string pname){
+        
+        vector<int> values = expPresetManager.recallPreset(pname);
+        if (values.size()){
+            candidateSynth.setAllParams(values);
+            setAllSlidersToValues(values);
+        }else{
+            cout << "ERROR, no preset found" << endl;
+        }
+    }
+    
+    
+    
+    //-----------------------------------------------------------------------------
+    
+    void buttonPressCallback(int mappingID, int value){
+        
+        
+        if (mappingID == TRIGGER_CANDIDATE_ID){
+            triggerCandidateSound();
+            
+            return;
+        }
+        if(mappingID == SAVE_PRESET_HIT){
+
+            expPresetManager.writeValuesToSlot(candidateSynth.getAllParamValues());
+            showCurrentSlot();
+
+            return;
+        }
+        
+    }
+
+    
+private:
+    Preset* currentPresetSlot;
+    int numParamsToUse;
+};
+
+
+#endif /* defined(__riftathon__expMessageOrganiser__) */