diff TrainingMessageOrganiser.h @ 10:e25d2b1b185e

Sequence manager generates sequences of target sounds. psudocode for onTick()
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Fri, 17 Oct 2014 19:23:30 +0100
parents d5e928887f51
children 91c3fba6e5b9
line wrap: on
line diff
--- a/TrainingMessageOrganiser.h	Fri Oct 17 17:50:41 2014 +0100
+++ b/TrainingMessageOrganiser.h	Fri Oct 17 19:23:30 2014 +0100
@@ -12,6 +12,10 @@
 #include <iostream>
 #include "trainingTestController.h"
 #include "MessageOrganiser.h"
+#include "SequenceController.h"
+
+extern ExplorePresetManager expPresetManager;
+
 class TrainingMessageOrganiser : public MessageOrganiser {
 public:
     void init( PDSynthWrapper& cs, PDSynthWrapper& ts){
@@ -52,8 +56,73 @@
 
         
     };
+    
+    void onNextTick(int tickNumber){
+        if ( tickNumber % 2){
+            // load next target preset
+            int i = sequenceController.getNextPresetIndex();
+            
+            currentTargetPreset =  expPresetManager.getPreset(i);
+            
+            if (sequencePreview){
+                // show next target preset
+             
+                // show image
+                // show name
+                // show controllersettings
+                
+                
+            }else{ // the user is matching it
+                // show image
+                // show name
+                
+                // if guided
+                    // show controller guide
+            }
+            
+            
+        }else{ // we're plying the sound
+         
+            //
+            if (sequencePreview){
+                // send target values again
+                targetSynth.setAllParams(currentTargetPreset->getValues());
+                targetSynth.trigger();
+                
+                // flash the interface?
+            }else{
+                // else the user should be hitting the play button
+                
+            }
+        }
+    }
+
    
 protected:
+
+    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 showATargetPresetWithGuide(Preset * p){ // this is when demoing the sequence to the user
+        // p.show icon
+        vector<int> values = p->getValues();
+        if (values.size()){
+            candidateSynth.setAllParams(values);
+            setAllSlidersToValues(values);
+        }else{
+            cout << "WARNING, preset to show had no values" << endl;
+        }
+    }
+    
     void mapSlidersToParams(vector<UIElement*> elems, vector<int> mids){
         
         vector<UIElement*>::iterator elit;
@@ -86,15 +155,27 @@
         if(mappingID == VOLUME_CHANGE_ID){
             targetSynth.sendVolume(value);
             candidateSynth.sendVolume(value);
-            
+            return;
         }
 
         if (mappingID == TRIGGER_CANDIDATE_ID){
             triggerCandidateSound();
+            // compare to target
+            return;
+        }
+        if(mappingID == SAVE_PRESET_HIT){
+            expPresetManager.savePreset("blah", candidateSynth.getAllParamValues());
+            return;
+        }
+        if(mappingID == RECALL_PRESET_HIT){
+            
+            loadPreset("blah");
             return;
         }
     }
-    
+    SequenceController sequenceController;
     TrainingTestController* trainingTestController;
+    bool sequencePreview;
+    Preset * currentTargetPreset;
 };
 #endif /* defined(__riftathon__TrainingMessageOrganiser__) */