annotate SequenceController.h @ 31:a677c027e3a0

Demo to Simon, kinda works. 4 reps of sequence.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Fri, 21 Nov 2014 17:07:56 +0000
parents e7af34b1af83
children 75202498bee9
rev   line source
rt300@8 1 //
rt300@14 2 // SequenceGenerator.h
rt300@8 3 // riftathon
rt300@8 4 //
rt300@14 5 // Created by Robert Tubb on 21/10/2014.
rt300@8 6 //
rt300@8 7 //
rt300@8 8
rt300@14 9 #ifndef __riftathon__SequenceGenerator__
rt300@14 10 #define __riftathon__SequenceGenerator__
rt300@8 11
rt300@8 12 #include <iostream>
rt300@14 13 #include "ofMain.h"
rt300@31 14 #include "presetManager.h"
rt300@31 15 #include "TrainingScoreManager.h"
rt300@31 16 #define MIN_TARGETS_IN_SEQUENCE 2
rt300@14 17 #define MAX_TARGETS_IN_SEQUENCE 5
rt300@22 18 #define MIN_TEMPO 60
rt300@28 19 #define MAX_TEMPO 300
rt300@28 20 #define NUM_TEMPO_STEPS 12
rt300@14 21 #define NUM_PRESETS 8
rt300@31 22 #define SPACER_BARS false
rt300@31 23 #define NO_GUIDES_LEVEL false
rt300@27 24 class AnimStep{
rt300@10 25
rt300@27 26
rt300@27 27 public:
rt300@27 28
rt300@27 29 AnimStep();
rt300@27 30 typedef enum {PREVIEW_NEUTRAL_COUNT,
rt300@27 31 MATCHING_NEUTRAL_COUNT,
rt300@27 32 PREVIEW_MOVE,
rt300@27 33 PREVIEW_HIT,
rt300@31 34 GUIDED_MOVE,
rt300@31 35 GUIDED_HIT,
rt300@27 36 MATCHING_MOVE,
rt300@27 37 MATCHING_HIT}
rt300@27 38 stepType;
rt300@27 39
rt300@27 40 stepType type;
rt300@27 41
rt300@27 42 float getTimeBetweenTicks(){
rt300@28 43 return 1000* (60.0/tempo);
rt300@27 44 }
rt300@27 45 int presetIndex;
rt300@31 46 Preset * currentTargetPreset;
rt300@31 47 Preset * nextTargetPreset;
rt300@27 48 int whichInSequence;
rt300@27 49 bool isLastOfAll;
rt300@27 50
rt300@27 51 int tempo;
rt300@27 52 int seqNumber;
rt300@27 53 int runNumber;
rt300@27 54 bool isLastOfSeq;
rt300@27 55 bool isLastOfRun;
rt300@27 56
rt300@27 57 bool showsGuides; // depends on 'level'
rt300@31 58 bool showsIcons;
rt300@31 59 bool showsResultsAtEnd;
rt300@27 60
rt300@27 61 vector<int> thisSequence; // so that we can show the whole sequence at the top?
rt300@31 62
rt300@31 63 TrainingTestResult result; // only applies to steps that were scored.
rt300@31 64
rt300@31 65
rt300@31 66 void saveResult(TrainingTestResult result);
rt300@27 67 };
rt300@22 68
rt300@31 69 // NOT USED
rt300@14 70 class Step{
rt300@13 71 public:
rt300@22 72 typedef enum {COUNT_IN, PREVIEW_PREPARER, PREVIEW_DISPLAYER, MATCHING_PREPARER, MATCHING_INTERACTION, MATCHING_RESULT} stepTypes;
rt300@21 73
rt300@21 74 Step();
rt300@21 75
rt300@14 76 // gui display
rt300@14 77 bool showsTargetIcon;
rt300@14 78 bool showsControlSettings;
rt300@14 79 bool showsControlGuides;
rt300@14 80 bool showsMatchResults;
rt300@14 81 // gui input
rt300@14 82 bool allowsCandidateControl;
rt300@14 83 // sound
rt300@14 84 bool playsTarget;
rt300@14 85 bool playsCandidate;
rt300@14 86 // control flow
rt300@14 87 stepTypes type;
rt300@14 88 bool isPreview;
rt300@14 89
rt300@14 90 int seqNumber;
rt300@14 91 int runNumber;
rt300@14 92 bool isLastOfSeq;
rt300@14 93 bool isLastOfRun;
rt300@22 94 bool showsCountDown;
rt300@22 95 bool hidesSliders;
rt300@14 96 int tempo;
rt300@14 97 // preset info
rt300@14 98 int presetIndex;
rt300@14 99 int numInSequence;
rt300@14 100 bool isLastOfAll;
rt300@21 101
rt300@22 102 void setAsBlankCounter();
rt300@22 103 void setAsPreviewPreparer();
rt300@21 104 void setAsPreviewPlayer();
rt300@21 105 void setAsMatchingPreparer();
rt300@22 106 void setAsMatchingInteraction();
rt300@22 107 void setAsMatchingFeedback();
rt300@31 108
rt300@13 109
rt300@14 110 float getTimeBetweenTicks(){
rt300@14 111 return 1000. * (60.0/tempo);
rt300@14 112 }
rt300@31 113
rt300@13 114 };
rt300@13 115
rt300@10 116 class SequenceController{
rt300@10 117 public:
rt300@21 118 SequenceController();
rt300@27 119 AnimStep getNextStep();
rt300@21 120 void setToStart();
rt300@21 121 void stepForward();
rt300@21 122 float getStartTickTime();
rt300@31 123 void saveResultForCurrentStep(TrainingTestResult result);
rt300@31 124 TrainingTestResult getResultForPreviousStep();
rt300@14 125 private:
rt300@21 126 void generateSteps();
rt300@21 127 void generateCountIn(int countInLength);
rt300@21 128 void generateARun(int run, int numInSequence);
rt300@27 129 vector<int> randomSequence(int numInSequence);
rt300@14 130
rt300@21 131 int getRandomButNot(int max, vector<int> notThese);
rt300@21 132 protected:
rt300@27 133 vector<AnimStep> steps;
rt300@27 134 vector<AnimStep>::iterator currentStep;
rt300@13 135 float tempoInc;
rt300@8 136 };
rt300@8 137
rt300@14 138 #endif /* defined(__riftathon__SequenceGenerator__) */