diff SequenceController.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 d59de9fd3496
children af71bf84660f
line wrap: on
line diff
--- a/SequenceController.h	Fri Oct 17 17:50:41 2014 +0100
+++ b/SequenceController.h	Fri Oct 17 19:23:30 2014 +0100
@@ -12,6 +12,13 @@
 #include <iostream>
 #include "presetManager.h"
 
+#define MAX_TARGETS_IN_SEQUENCE 8
+#define MIN_TEMPO   80
+#define MAX_TEMPO   200
+#define NUM_TEMPO_STEPS 8
+#define NUM_PRESETS 16
+
+
 class Sequence{
     int tempo;
     vector<Preset *> presetSequence;
@@ -19,16 +26,66 @@
     
 };
 
-class SequenceControler{
+class SequenceController{
+public:
+    SequenceController(){
+        makeSequences();
+    };
+    SequenceController(const vector<Preset>& presets)
+    : thePresets(presets)
     
-    SequenceControler(const vector<Preset>& presets);
+    {
+        
+        makeSequences();
+    };
+    Sequence getNextSequence();
+    int getNextPresetIndex(){
+        
+        // if end of sequence return something else so we can do something
+        // if end of tempo ramp return something else
+        
+    };
+protected:
+    void makeSequences(){
+        
+        
+        for(int numInSequence = 1; numInSequence < MAX_TARGETS_IN_SEQUENCE; numInSequence++){
+            for(int tempoLevel = 0; tempoLevel < NUM_TEMPO_STEPS; tempoLevel++){
+                
+                vector<int> indexSequence;
+                
+                // repeat the same tests for xtra practice?
+                for(int n=0; n < numInSequence; n++){
+                    int next = getRandomButNot(NUM_PRESETS,indexSequence);
+                    indexSequence.push_back(next);
+                    
+                    cout << next << ",";
+                }
+                cout << endl;
+            }
+            cout << "---" << endl;
+        }
+    };
 
-    void makeSequences();
+    int getRandomButNot(int max, vector<int> notThese){
+        
+        bool there = true;
+        uint randomInt = rand() % max;
+        
+        if (notThese.size()){
+        while(there){
+            randomInt = rand() % max;
+            vector<int>::iterator result = std::find(notThese.begin(), notThese.end(), randomInt);
+            there =  (result != notThese.end());
+        }
+        }
+        return randomInt;
+        
+    };
     
-    Sequence getNextSequence();
     
 private:
-    const vector<Preset>& thePresets;
+    const vector<Preset> thePresets;
     vector<Sequence> theSequences;
 };