annotate SequenceController.h @ 35:3b10a26da293

refactoring and log
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Wed, 26 Nov 2014 18:18:20 +0000
parents 3af380769779
children 146033869165
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@33 16 #define MIN_TARGETS_IN_SEQUENCE 1
rt300@34 17 #define MAX_TARGETS_IN_SEQUENCE 7
rt300@35 18 #define MIN_TEMPO 60
rt300@35 19 #define MAX_TEMPO 500
rt300@35 20 #define NUM_TEMPO_STEPS 15
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@35 33 PREVIEW_LAST,
rt300@31 34 GUIDED_MOVE,
rt300@31 35 GUIDED_HIT,
rt300@27 36 MATCHING_MOVE,
rt300@35 37 MATCHING_LAST}
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@35 54 int difficulty;
rt300@27 55 bool isLastOfSeq;
rt300@27 56 bool isLastOfRun;
rt300@27 57
rt300@27 58 bool showsGuides; // depends on 'level'
rt300@31 59 bool showsIcons;
rt300@31 60 bool showsResultsAtEnd;
rt300@27 61
rt300@27 62 vector<int> thisSequence; // so that we can show the whole sequence at the top?
rt300@31 63
rt300@31 64 TrainingTestResult result; // only applies to steps that were scored.
rt300@31 65
rt300@31 66
rt300@31 67 void saveResult(TrainingTestResult result);
rt300@27 68 };
rt300@22 69
rt300@31 70 // NOT USED
rt300@14 71 class Step{
rt300@13 72 public:
rt300@22 73 typedef enum {COUNT_IN, PREVIEW_PREPARER, PREVIEW_DISPLAYER, MATCHING_PREPARER, MATCHING_INTERACTION, MATCHING_RESULT} stepTypes;
rt300@21 74
rt300@21 75 Step();
rt300@21 76
rt300@14 77 // gui display
rt300@14 78 bool showsTargetIcon;
rt300@14 79 bool showsControlSettings;
rt300@14 80 bool showsControlGuides;
rt300@14 81 bool showsMatchResults;
rt300@14 82 // gui input
rt300@14 83 bool allowsCandidateControl;
rt300@14 84 // sound
rt300@14 85 bool playsTarget;
rt300@14 86 bool playsCandidate;
rt300@14 87 // control flow
rt300@14 88 stepTypes type;
rt300@14 89 bool isPreview;
rt300@14 90
rt300@14 91 int seqNumber;
rt300@14 92 int runNumber;
rt300@14 93 bool isLastOfSeq;
rt300@14 94 bool isLastOfRun;
rt300@22 95 bool showsCountDown;
rt300@22 96 bool hidesSliders;
rt300@14 97 int tempo;
rt300@14 98 // preset info
rt300@14 99 int presetIndex;
rt300@14 100 int numInSequence;
rt300@14 101 bool isLastOfAll;
rt300@21 102
rt300@22 103 void setAsBlankCounter();
rt300@22 104 void setAsPreviewPreparer();
rt300@21 105 void setAsPreviewPlayer();
rt300@21 106 void setAsMatchingPreparer();
rt300@22 107 void setAsMatchingInteraction();
rt300@22 108 void setAsMatchingFeedback();
rt300@31 109
rt300@13 110
rt300@14 111 float getTimeBetweenTicks(){
rt300@14 112 return 1000. * (60.0/tempo);
rt300@14 113 }
rt300@31 114
rt300@13 115 };
rt300@13 116
rt300@10 117 class SequenceController{
rt300@10 118 public:
rt300@21 119 SequenceController();
rt300@32 120 void init(bool asoundOnlyMode);
rt300@27 121 AnimStep getNextStep();
rt300@21 122 void setToStart();
rt300@21 123 void stepForward();
rt300@21 124 float getStartTickTime();
rt300@31 125 void saveResultForCurrentStep(TrainingTestResult result);
rt300@31 126 TrainingTestResult getResultForPreviousStep();
rt300@32 127 int getTotNumRuns(){return totNumRuns;};
rt300@14 128 private:
rt300@21 129 void generateSteps();
rt300@21 130 void generateCountIn(int countInLength);
rt300@21 131 void generateARun(int run, int numInSequence);
rt300@34 132 void generateAnEasyRun(int run, int numInSequence = 1);
rt300@32 133 void generateASoundOnlyRun(int run, int numInSequence);
rt300@27 134 vector<int> randomSequence(int numInSequence);
rt300@32 135 vector<int> nonRandomSequence(int numInSequence);
rt300@21 136 int getRandomButNot(int max, vector<int> notThese);
rt300@21 137 protected:
rt300@27 138 vector<AnimStep> steps;
rt300@27 139 vector<AnimStep>::iterator currentStep;
rt300@13 140 float tempoInc;
rt300@32 141 bool soundOnlyMode;
rt300@32 142 int totNumRuns;
rt300@8 143 };
rt300@8 144
rt300@14 145 #endif /* defined(__riftathon__SequenceGenerator__) */