comparison TrainingMessageOrganiser.h @ 14:f83635861187

rewrote sequence controller. ticks show relevant UI modes. images show for preset textures (but greenish?)
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Tue, 21 Oct 2014 16:39:39 +0100
parents ab3e0e980c82
children 2da0350a4aa2
comparison
equal deleted inserted replaced
13:ab3e0e980c82 14:f83635861187
17 17
18 extern ExplorePresetManager expPresetManager; 18 extern ExplorePresetManager expPresetManager;
19 19
20 class TrainingMessageOrganiser : public MessageOrganiser { 20 class TrainingMessageOrganiser : public MessageOrganiser {
21 public: 21 public:
22 int numParamsToUse;
22 void init( PDSynthWrapper& cs, PDSynthWrapper& ts){ 23 void init( PDSynthWrapper& cs, PDSynthWrapper& ts){
23 24
24 MessageOrganiser::init(cs,ts); 25 MessageOrganiser::init(cs,ts);
25 26
26 TickListenerFunction callback; 27 TickListenerFunction callback;
27 callback = boost::bind(&TrainingMessageOrganiser::onNextTick, this, _1); 28 callback = boost::bind(&TrainingMessageOrganiser::onNextTick, this, _1);
28 candidateSynth.registerForTicks(callback); 29 candidateSynth.registerForTicks(callback);
29 30
30 sequencePreview = true; 31 numParamsToUse = 3;
31 } 32
32 33 }
34
33 void setupDefaultMapping(){ 35 void setupDefaultMapping(){
34 vector<int> mappingIDsForChangeableParams = getMappingIDsFromSynths(); 36 vector<int> mappingIDsForChangeableParams = getMappingIDsFromSynths();
35 37
36 controlPanelType cpt = REVISITABLE; 38 controlPanelType cpt = REVISITABLE;
37 vector<controllerType> elemList; 39 vector<controllerType> elemList;
38 for(int i = 0; i < TOTAL_NUM_PARAMS; i++){ 40 for(int i = 0; i < numParamsToUse; i++){
39 elemList.push_back(SLIDER); 41 elemList.push_back(SLIDER);
40 } 42 }
41 43
42 vector<UIElement*> UIElemHandles = panel->generateControls(elemList, cpt); 44 vector<UIElement*> UIElemHandles = panel->generateControls(elemList, cpt);
43 45
46 bottomPanel->show(); 48 bottomPanel->show();
47 } 49 }
48 50
49 vector<int> getMappingIDsFromSynths(){ 51 vector<int> getMappingIDsFromSynths(){
50 vector<int> index; 52 vector<int> index;
51 for(int i = 0; i < TOTAL_NUM_PARAMS; i++){ 53 for(int i = 0; i < numParamsToUse; i++){
52 index.push_back(i); 54 index.push_back(i);
53 } 55 }
54 vector<int> mids = candidateSynth.getMappingIDForIndices(index); 56 vector<int> mids = candidateSynth.getMappingIDForIndices(index);
55 57
56 return mids; 58 return mids;
57 } 59 }
58 60
59 void setupNewTest(){ 61 void setupNewTest(){
60 62
61 63
62 }; 64 };
63 65
64 void setIconPanel(IconPanel * ip){ 66 void setIconPanel(IconPanel * ip){
65 presetIconPanel = ip; 67 presetIconPanel = ip;
66 } 68 }
69 void setInstructionPanel(TextPanel * ip){
70 instructionPanel = ip;
71 instructionPanel->show();
72 }
73 //-----------------------------------------------------------------------
74 void displayInstructions(Step s){
75
76
77 if (s.type == Step::COUNT_IN){
78 instructionPanel->setText("GET READY");
79 }
80 if (s.type == Step::PREVIEW_DISPLAY){
81 instructionPanel->setText("MEMORISE");
82 panel->setColor(ofColor(0,0,0));
83 }
84 if (s.type == Step::PREVIEW_PLAY){
85 instructionPanel->setText("MEMORISE");
86 panel->setColor(ofColor(0,0,0));
87 }
88 if (s.type == Step::MATCHING_INTERACTION){
89 instructionPanel->setText("MATCH:");
90 panel->setColor(ofColor(100,0,0));
91 }
92 if (s.type == Step::MATCHING_RESULT){
93 instructionPanel->setText("RESULT");
94 panel->setColor(ofColor(0,100,0));
95 }
96 }
97 //-----------------------------------------------------------------------
67 void onNextTick(int tickNumber){ 98 void onNextTick(int tickNumber){
68 cout << "TICK " << tickNumber << endl; 99 cout << "TICK " << tickNumber << endl;
69 100
70 if ( !(tickNumber % 2)){ 101 // only first beat in bar is active one
71 // load next target preset 102 if ( tickNumber % 4 != 0){
72 103 return;
73 int i = sequenceController.getCurrentPresetIndex(); 104 }
74 105 // load next target preset
75 currentTargetPreset = expPresetManager.getPreset(i); 106
76 107 Step newStep = sequenceController.getNextStep();
77 if (sequencePreview){ 108 displayInstructions(newStep);
78 // show next target preset 109
79 // presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage()); 110 if(newStep.isLastOfAll){
80 111 // do finished run stuff, show summary
81 // show image 112 candidateSynth.stopMetronome();
82 // show name 113 cout << "FINISHED BLOCK" << endl;
83 // show controllersettings 114 }
84 115 if(newStep.isLastOfRun){
85
86 }else{ // the user is matching it
87 // show image
88 // show name
89
90 // if guided
91 // show controller guide
92 }
93
94
95 }else{ // we're plying the sound
96
97 //
98 if (sequencePreview){
99 // send target values again
100 targetSynth.setAllParams(currentTargetPreset->getValues());
101 setSlidersToTarget();
102 targetSynth.trigger();
103
104 // flash the interface?
105 }else{
106 // has this been done? yes. candidateSynth.setAllParams(ui stuff);
107 candidateSynth.trigger();
108 showUserHowTheyDid();
109
110 }
111 }
112
113 int run = sequenceController.stepForward();
114 if (run == -2){
115 // do finished run stuff, show summary 116 // do finished run stuff, show summary
116 candidateSynth.stopMetronome(); 117 candidateSynth.stopMetronome();
117 cout << "FINISHED RUN" << endl; 118 cout << "FINISHED RUN" << endl;
118 } 119 }
119 if (run == -1){ 120
120 // finished whole block 121 float t = newStep.getTimeBetweenTicks();
121 candidateSynth.stopMetronome(); 122 candidateSynth.setMetroTime(t);
122 cout << "FINISHED BLOCK" << endl; 123
123 } 124 if(newStep.type == Step::COUNT_IN){
124 } 125 // count in
125 126 return;
126 127 }
128
129 if(newStep.presetIndex >= 0 && newStep.presetIndex <= 8){
130 currentTargetPreset = expPresetManager.getPreset(newStep.presetIndex);
131 }
132
133 if(newStep.showsTargetIcon){
134 presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage());
135 presetIconPanel->show();
136 }else{
137 presetIconPanel->hide();
138 }
139
140 if(newStep.showsControlSettings){
141 targetSynth.setAllParams(currentTargetPreset->getValues());
142 setSlidersToTarget();
143
144 }else{
145 //setSlidersToDefault();
146
147 }
148
149 if(newStep.playsTarget){
150 targetSynth.setAllParams(currentTargetPreset->getValues());
151 targetSynth.trigger();
152 }
153
154 if(newStep.playsCandidate){
155 triggerCandidateSound();
156 }
157
158 if(newStep.allowsCandidateControl){
159 panel->setActive(true);
160 }else{
161 panel->setActive(false);
162 }
163
164 if(newStep.showsMatchResults){
165 // do something
166 }
167
168 if(newStep.showsControlGuides){
169
170 panel->setHintValues(currentTargetPreset->getValues());
171 panel->showHint(true);
172 }else{
173 panel->showHint(false);
174 }
175
176 }
177
178 //-----------------------------------------------------------------------
127 protected: 179 protected:
128 void showUserHowTheyDid(){ 180 void showUserHowTheyDid(){
129 // colour flash 181 // colour flash
130 // distance ? 182 // distance ?
131 // score 183 // score
141 cout << "ERROR, no preset found" << endl; 193 cout << "ERROR, no preset found" << endl;
142 } 194 }
143 } 195 }
144 196
145 197
198 //-----------------------------------------------------------------------
146 void showATargetPresetWithGuide(Preset * p){ // this is when demoing the sequence to the user 199 void showATargetPresetWithGuide(Preset * p){ // this is when demoing the sequence to the user
147 // p.show icon 200 // p.show icon
148 vector<int> values = p->getValues(); 201 vector<int> values = p->getValues();
149 if (values.size()){ 202 if (values.size()){
150 candidateSynth.setAllParams(values); 203 candidateSynth.setAllParams(values);
151 setAllSlidersToValues(values); 204 setAllSlidersToValues(values);
152 }else{ 205 }else{
153 cout << "WARNING, preset to show had no values" << endl; 206 cout << "WARNING, preset to show had no values" << endl;
154 } 207 }
155 } 208 }
209 //-----------------------------------------------------------------------------
156 210
157 void mapSlidersToParams(vector<UIElement*> elems, vector<int> mids){ 211 void mapSlidersToParams(vector<UIElement*> elems, vector<int> mids){
158 212
159 vector<UIElement*>::iterator elit; 213 vector<UIElement*>::iterator elit;
160 vector<int> typeListLog; 214 vector<int> typeListLog;
179 } 233 }
180 } 234 }
181 235
182 eventLogger.logEvent(CONTROL_LIST,typeListLog); 236 eventLogger.logEvent(CONTROL_LIST,typeListLog);
183 }; 237 };
238 //-----------------------------------------------------------------------------
184 239
185 void buttonPressCallback(int mappingID, int value){ 240 void buttonPressCallback(int mappingID, int value){
186 if(mappingID == VOLUME_CHANGE_ID){ 241 if(mappingID == VOLUME_CHANGE_ID){
187 targetSynth.sendVolume(value); 242 targetSynth.sendVolume(value);
188 candidateSynth.sendVolume(value); 243 candidateSynth.sendVolume(value);
189 return; 244 return;
190 } 245 }
191 246
192 if (mappingID == TRIGGER_CANDIDATE_ID){ 247 if (mappingID == TRIGGER_CANDIDATE_ID){
193 triggerCandidateSound(); 248 //triggerCandidateSound();
194 // compare to target 249 // compare to target
250 candidateSynth.setMetroTime(sequenceController.getStartTickTime());
195 candidateSynth.startMetronome(); 251 candidateSynth.startMetronome();
196 return; 252 return;
197 } 253 }
198 if(mappingID == SAVE_PRESET_HIT){ 254 if(mappingID == SAVE_PRESET_HIT){
199 expPresetManager.savePreset("blah", candidateSynth.getAllParamValues()); 255 expPresetManager.savePreset("blah", candidateSynth.getAllParamValues());
203 259
204 loadPreset("blah"); 260 loadPreset("blah");
205 return; 261 return;
206 } 262 }
207 } 263 }
264 //-----------------------------------------------------------------------------
265
208 SequenceController sequenceController; 266 SequenceController sequenceController;
209 bool sequencePreview; 267 bool sequencePreview;
210 Preset * currentTargetPreset; 268 Preset * currentTargetPreset;
211 IconPanel* presetIconPanel; 269 IconPanel* presetIconPanel;
270 TextPanel* instructionPanel;
212 }; 271 };
213 #endif /* defined(__riftathon__TrainingMessageOrganiser__) */ 272 #endif /* defined(__riftathon__TrainingMessageOrganiser__) */