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