comparison 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
comparison
equal deleted inserted replaced
16:2da0350a4aa2 17:2a7320a8cbed
1 //
2 // expMessageOrganiser.h
3 // riftathon
4 //
5 // Created by Robert Tubb on 21/10/2014.
6 //
7 //
8
9 #ifndef __riftathon__expMessageOrganiser__
10 #define __riftathon__expMessageOrganiser__
11
12 #include <iostream>
13 #include "MessageOrganiser.h"
14 #include "SequenceController.h"
15 #include "globalVariables.h"
16
17 extern ExplorePresetManager expPresetManager;
18
19 class ExpMessageOrganiser : public MessageOrganiser {
20
21 public:
22 void init( PDSynthWrapper& cs, PDSynthWrapper& ts){
23 numParamsToUse = TOTAL_NUM_PARAMS;
24 MessageOrganiser::init(cs,ts);
25
26
27 }
28 void setup(){
29 // do stuff like load first slot
30 setupDefaultMapping();
31 expPresetManager.goToFirstEmptySlot();
32 showCurrentSlot();
33
34
35 }
36
37
38 void setupDefaultMapping(){
39 vector<int> mappingIDsForChangeableParams = getMappingIDsFromSynths();
40
41 controlPanelType cpt = REVISITABLE;
42 vector<controllerType> elemList;
43 for(int i = 0; i < numParamsToUse; i++){
44 elemList.push_back(SLIDER);
45 }
46
47 vector<UIElement*> UIElemHandles = panel->generateControls(elemList, cpt);
48
49 mapSlidersToParams(UIElemHandles, mappingIDsForChangeableParams);
50
51 bottomPanel->show();
52 }
53
54 vector<int> getMappingIDsFromSynths(){
55 vector<int> index;
56 for(int i = 0; i < numParamsToUse; i++){
57 index.push_back(i);
58 }
59 vector<int> mids = candidateSynth.getMappingIDForIndices(index);
60
61 return mids;
62 }
63
64 void showCurrentSlot(){
65 currentPresetSlot = expPresetManager.getCurrentPresetSlot();
66 presetIconPanel->setTextAndImage(currentPresetSlot->name, currentPresetSlot->getImage());
67 }
68
69 void loadPreset(string pname){
70
71 vector<int> values = expPresetManager.recallPreset(pname);
72 if (values.size()){
73 candidateSynth.setAllParams(values);
74 setAllSlidersToValues(values);
75 }else{
76 cout << "ERROR, no preset found" << endl;
77 }
78 }
79
80
81
82 //-----------------------------------------------------------------------------
83
84 void buttonPressCallback(int mappingID, int value){
85
86
87 if (mappingID == TRIGGER_CANDIDATE_ID){
88 triggerCandidateSound();
89
90 return;
91 }
92 if(mappingID == SAVE_PRESET_HIT){
93
94 expPresetManager.writeValuesToSlot(candidateSynth.getAllParamValues());
95 showCurrentSlot();
96
97 return;
98 }
99
100 }
101
102
103 private:
104 Preset* currentPresetSlot;
105 int numParamsToUse;
106 };
107
108
109 #endif /* defined(__riftathon__expMessageOrganiser__) */