view SequenceController.h @ 23:055e0c43afe5

Leap MIDI works for 6 sliders, in exp and train modes.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Mon, 27 Oct 2014 15:52:04 +0000
parents 8124f46eda65
children 27cdf475aa4b
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"

#define MIN_TARGETS_IN_SEQUENCE 1
#define MAX_TARGETS_IN_SEQUENCE 5
#define MIN_TEMPO   60
#define MAX_TEMPO   120
#define NUM_TEMPO_STEPS 16
#define NUM_PRESETS 8


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();
    Step getNextStep();
    void setToStart();
    void stepForward();
    float getStartTickTime();
private:
    void generateSteps();
    void generateCountIn(int countInLength);
    void generateARun(int run, int numInSequence);
    
    
    int getRandomButNot(int max, vector<int> notThese);
protected:
    vector<Step> steps;
    vector<Step>::iterator currentStep;
    float tempoInc;
};

#endif /* defined(__riftathon__SequenceGenerator__) */