view SequenceController.h @ 33:93317878abef

more event logging
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Tue, 25 Nov 2014 18:37:54 +0000
parents 75202498bee9
children 3af380769779
line wrap: on
line source
//
//  SequenceGenerator.h
//  riftathon
//
//  Created by Robert Tubb on 21/10/2014.
//
//

#ifndef __riftathon__SequenceGenerator__
#define __riftathon__SequenceGenerator__

#include <iostream>
#include "ofMain.h"
#include "presetManager.h"
#include "TrainingScoreManager.h"
#define MIN_TARGETS_IN_SEQUENCE 1
#define MAX_TARGETS_IN_SEQUENCE 2
#define MIN_TEMPO   80
#define MAX_TEMPO   400
#define NUM_TEMPO_STEPS 12
#define NUM_PRESETS 8
#define SPACER_BARS false
#define NO_GUIDES_LEVEL false
class AnimStep{

    
public:
    
    AnimStep();
    typedef enum {PREVIEW_NEUTRAL_COUNT,
                MATCHING_NEUTRAL_COUNT,
                PREVIEW_MOVE,
                PREVIEW_HIT,
                GUIDED_MOVE,
                GUIDED_HIT,
                MATCHING_MOVE,
                MATCHING_HIT}
                stepType;
    
    stepType type;
    
    float getTimeBetweenTicks(){
        return 1000* (60.0/tempo);
    }
    int presetIndex;
    Preset * currentTargetPreset;
    Preset * nextTargetPreset;
    int whichInSequence;
    bool isLastOfAll;

    int tempo;
    int seqNumber;
    int runNumber;
    bool isLastOfSeq;
    bool isLastOfRun;
    
    bool showsGuides; // depends on 'level'
    bool showsIcons;
    bool showsResultsAtEnd;
    
    vector<int> thisSequence; // so that we can show the whole sequence at the top?
    
    TrainingTestResult result; // only applies to steps that were scored.
    
    
    void saveResult(TrainingTestResult result);
};

// NOT USED
class Step{
public:
    typedef enum {COUNT_IN, PREVIEW_PREPARER, PREVIEW_DISPLAYER, MATCHING_PREPARER, MATCHING_INTERACTION, MATCHING_RESULT} stepTypes;
    
    Step();
    
// gui display
    bool showsTargetIcon;
    bool showsControlSettings;
    bool showsControlGuides;
    bool showsMatchResults;
// gui input
    bool allowsCandidateControl;
// sound
    bool playsTarget;
    bool playsCandidate;
// control flow
    stepTypes type;
    bool isPreview;
    
    int seqNumber;
    int runNumber;
    bool isLastOfSeq;
    bool isLastOfRun;
    bool showsCountDown;
    bool hidesSliders;
    int tempo;
// preset info
    int presetIndex;
    int numInSequence;
    bool isLastOfAll;

    void setAsBlankCounter();
    void setAsPreviewPreparer();
    void setAsPreviewPlayer();
    void setAsMatchingPreparer();
    void setAsMatchingInteraction();
    void setAsMatchingFeedback();

    
    float getTimeBetweenTicks(){
        return 1000. * (60.0/tempo);
    }

};

class SequenceController{
public:
    SequenceController();
    void init(bool asoundOnlyMode);
    AnimStep getNextStep();
    void setToStart();
    void stepForward();
    float getStartTickTime();
    void saveResultForCurrentStep(TrainingTestResult result);
    TrainingTestResult getResultForPreviousStep();
    int getTotNumRuns(){return totNumRuns;};
private:
    void generateSteps();
    void generateCountIn(int countInLength);
    void generateARun(int run, int numInSequence);
    void generateASoundOnlyRun(int run, int numInSequence);
    vector<int> randomSequence(int numInSequence);
    vector<int> nonRandomSequence(int numInSequence);
    int getRandomButNot(int max, vector<int> notThese);
protected:
    vector<AnimStep> steps;
    vector<AnimStep>::iterator currentStep;
    float tempoInc;
    bool soundOnlyMode;
    int totNumRuns;
};

#endif /* defined(__riftathon__SequenceGenerator__) */