Mercurial > hg > tweakathon2ios
comparison 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 |
comparison
equal
deleted
inserted
replaced
9:d5e928887f51 | 10:e25d2b1b185e |
---|---|
10 #define __riftathon__SequenceController__ | 10 #define __riftathon__SequenceController__ |
11 | 11 |
12 #include <iostream> | 12 #include <iostream> |
13 #include "presetManager.h" | 13 #include "presetManager.h" |
14 | 14 |
15 #define MAX_TARGETS_IN_SEQUENCE 8 | |
16 #define MIN_TEMPO 80 | |
17 #define MAX_TEMPO 200 | |
18 #define NUM_TEMPO_STEPS 8 | |
19 #define NUM_PRESETS 16 | |
20 | |
21 | |
15 class Sequence{ | 22 class Sequence{ |
16 int tempo; | 23 int tempo; |
17 vector<Preset *> presetSequence; | 24 vector<Preset *> presetSequence; |
18 | 25 |
19 | 26 |
20 }; | 27 }; |
21 | 28 |
22 class SequenceControler{ | 29 class SequenceController{ |
30 public: | |
31 SequenceController(){ | |
32 makeSequences(); | |
33 }; | |
34 SequenceController(const vector<Preset>& presets) | |
35 : thePresets(presets) | |
23 | 36 |
24 SequenceControler(const vector<Preset>& presets); | 37 { |
38 | |
39 makeSequences(); | |
40 }; | |
41 Sequence getNextSequence(); | |
42 int getNextPresetIndex(){ | |
43 | |
44 // if end of sequence return something else so we can do something | |
45 // if end of tempo ramp return something else | |
46 | |
47 }; | |
48 protected: | |
49 void makeSequences(){ | |
50 | |
51 | |
52 for(int numInSequence = 1; numInSequence < MAX_TARGETS_IN_SEQUENCE; numInSequence++){ | |
53 for(int tempoLevel = 0; tempoLevel < NUM_TEMPO_STEPS; tempoLevel++){ | |
54 | |
55 vector<int> indexSequence; | |
56 | |
57 // repeat the same tests for xtra practice? | |
58 for(int n=0; n < numInSequence; n++){ | |
59 int next = getRandomButNot(NUM_PRESETS,indexSequence); | |
60 indexSequence.push_back(next); | |
61 | |
62 cout << next << ","; | |
63 } | |
64 cout << endl; | |
65 } | |
66 cout << "---" << endl; | |
67 } | |
68 }; | |
25 | 69 |
26 void makeSequences(); | 70 int getRandomButNot(int max, vector<int> notThese){ |
71 | |
72 bool there = true; | |
73 uint randomInt = rand() % max; | |
74 | |
75 if (notThese.size()){ | |
76 while(there){ | |
77 randomInt = rand() % max; | |
78 vector<int>::iterator result = std::find(notThese.begin(), notThese.end(), randomInt); | |
79 there = (result != notThese.end()); | |
80 } | |
81 } | |
82 return randomInt; | |
83 | |
84 }; | |
27 | 85 |
28 Sequence getNextSequence(); | |
29 | 86 |
30 private: | 87 private: |
31 const vector<Preset>& thePresets; | 88 const vector<Preset> thePresets; |
32 vector<Sequence> theSequences; | 89 vector<Sequence> theSequences; |
33 }; | 90 }; |
34 | 91 |
35 #endif /* defined(__riftathon__SequenceController__) */ | 92 #endif /* defined(__riftathon__SequenceController__) */ |