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