# HG changeset patch # User Robert Tubb # Date 1413830199 -3600 # Node ID ab3e0e980c820d5cb95a3a72bdfd46e7a065771b # Parent af71bf84660f817ebc504ac1b0f34dba5cd0e8e0 Sequence conrtollrer FINALLY works. diff -r af71bf84660f -r ab3e0e980c82 PDSynthWrapper.h --- a/PDSynthWrapper.h Mon Oct 20 14:12:23 2014 +0100 +++ b/PDSynthWrapper.h Mon Oct 20 19:36:39 2014 +0100 @@ -37,8 +37,8 @@ timbreParams.push_back(SynthParam(64,aCore,"FiltTyp",sp)); timbreParams.push_back(SynthParam(64,aCore,"FiltFrq",sp)); - //timbreParams.push_back(SynthParam(64,aCore,"SPAM",sp)); - //timbreParams.push_back(SynthParam(64,aCore,"FILTH",sp)); + timbreParams.push_back(SynthParam(64,aCore,"SPAM",sp)); + timbreParams.push_back(SynthParam(64,aCore,"FILTH",sp)); //timbreParams.push_back(SynthParam(64,aCore,"reson",sp)); if (timbreParams.size() != TOTAL_NUM_PARAMS){ diff -r af71bf84660f -r ab3e0e980c82 PresetView.h --- a/PresetView.h Mon Oct 20 14:12:23 2014 +0100 +++ b/PresetView.h Mon Oct 20 19:36:39 2014 +0100 @@ -21,20 +21,10 @@ if (imageFileName != ""){ // these are NOT put in images/ directory for some reason... string fname = ofFilePath::getAbsolutePath(ofToDataPath(imageFileName)); - ofFile f = ofFile(fname); - - - cout << fname << endl; - cout << f.exists() << endl; - image.loadImage(fname); } - - name = aName; - - }; diff -r af71bf84660f -r ab3e0e980c82 SequenceController.h --- a/SequenceController.h Mon Oct 20 14:12:23 2014 +0100 +++ b/SequenceController.h Mon Oct 20 19:36:39 2014 +0100 @@ -12,59 +12,190 @@ #include #include "presetManager.h" -#define MAX_TARGETS_IN_SEQUENCE 8 +#define MAX_TARGETS_IN_SEQUENCE 2 #define MIN_TEMPO 80 #define MAX_TEMPO 200 -#define NUM_TEMPO_STEPS 8 +#define NUM_TEMPO_STEPS 3 #define NUM_PRESETS 16 +//=============================================================================== + class Sequence{ - int tempo; - vector presetSequence; +public: + Sequence(vector si, int t, bool pv){ + tempo = t; + presetSequence = si; + isSequencePreview = pv; + curStep = 0; + }; + bool moveToNextStep(){ + curStep++; + + if (curStep >= presetSequence.size()){ + return false; + }else{ + return true; + } + }; + int getCurrentPresetIndex(){ + cout << "step : " << curStep << endl; + if (curStep >= presetSequence.size()){ + cout << "ERROR: off end of seq" << endl; + return 0; + } + int i = presetSequence[curStep]; + if(i < 0){ + cout << "ERROR: negative index" << endl; + } + return i; + + }; + int getStepNo(){ + return curStep; + } + float tempo; + bool isSequencePreview; // true if demoing the seq to the user, false if user is matching a seq + vector presetSequence; + int curStep; }; +//=============================================================================== + +class Run{ +public: + Run(vector vs, int sl){ + theSequences = vs; + sequenceLength = sl; + curSeq = 0; + }; + bool moveToNextStep(){ + if (curSeq >= theSequences.size()){ + return false; + } + + bool stepFound = theSequences[curSeq].moveToNextStep(); + if (stepFound){ + return true; + }else{ + curSeq++; + if (curSeq >= theSequences.size()){ + return false; + + }else{ + return true; + } + } + + return false; + }; + int getCurrentPresetIndex(){ + cout << "seq : " << curSeq << endl; + if (curSeq >= theSequences.size()){ + cout << "ERROR: get preset" << endl; + return 0; + } + return theSequences[curSeq].getCurrentPresetIndex(); + + }; + int getSequenceNo(){ + return curSeq; + } + + vector theSequences; + int curSeq; + int sequenceLength; + +}; +//=============================================================================== + class SequenceController{ public: + SequenceController(){ makeSequences(); + tempoInc = float(MAX_TEMPO - MIN_TEMPO) / float(NUM_TEMPO_STEPS); + curRun = 0; }; - SequenceController(const vector& presets) - : thePresets(presets) - - { + + int stepForward(){ + cout << "run : " << curRun << endl; + if (curRun >= theRuns.size()){ + return -1; + } + + bool stepFound = theRuns[curRun].moveToNextStep(); + if (stepFound){ + return curRun; + }else{ + curRun++; + if (curRun >= theRuns.size()){ + cout << " END OF RUNS " << endl; + return -1; + + }else{ + return -2; // in order to stop the metro, next tick will just start thjings agaaain + } + } - makeSequences(); - }; - Sequence getNextSequence(); - int getNextPresetIndex(){ + return false; + + } + + int getCurrentPresetIndex(){ // if end of sequence return something else so we can do something // if end of tempo ramp return something else - uint randomInt = rand() % 8; - return randomInt; + if (curRun >= theRuns.size()){ + cout << "DAAAAHHH" << endl; + return -1; + } + int nextIndex = theRuns[curRun].getCurrentPresetIndex(); + + return nextIndex; + }; + vector getCurrentRunSeqAndStep(){ + vector rss; +// int r = curRun - theRuns.begin(); +// int sq = (*curRun).getSequenceNo(); +// int s = 4534534; +// rss.push_back(r); +// rss.push_back(sq); +// rss.push_back(s); + return rss; - }; + } protected: void makeSequences(){ + srand (time(NULL)); - - for(int numInSequence = 1; numInSequence < MAX_TARGETS_IN_SEQUENCE; numInSequence++){ + + for(int numInSequence = 1; numInSequence <= MAX_TARGETS_IN_SEQUENCE; numInSequence++){ + float curTempo = MIN_TEMPO; + vector seqsForRun; + for(int tempoLevel = 0; tempoLevel < NUM_TEMPO_STEPS; tempoLevel++){ - vector indexSequence; + vector stepsForSequence; // repeat the same tests for xtra practice? for(int n=0; n < numInSequence; n++){ - int next = getRandomButNot(NUM_PRESETS,indexSequence); - indexSequence.push_back(next); + int next = getRandomButNot(NUM_PRESETS,stepsForSequence); + stepsForSequence.push_back(next); cout << next << ","; } + seqsForRun.push_back(Sequence(stepsForSequence, curTempo, true)); + seqsForRun.push_back(Sequence(stepsForSequence, curTempo, false)); + curTempo += tempoInc; cout << endl; + } + + theRuns.push_back( Run(seqsForRun,numInSequence) ); + cout << "---" << endl; } }; @@ -72,7 +203,7 @@ int getRandomButNot(int max, vector notThese){ bool there = true; - uint randomInt = rand() % max; + int randomInt = rand() % max; if (notThese.size()){ while(there){ @@ -84,11 +215,15 @@ return randomInt; }; - + private: - const vector thePresets; - vector theSequences; + + vector theRuns; + int curRun; + + float tempoInc; }; +//=============================================================================== #endif /* defined(__riftathon__SequenceController__) */ diff -r af71bf84660f -r ab3e0e980c82 TrainingMessageOrganiser.h --- a/TrainingMessageOrganiser.h Mon Oct 20 14:12:23 2014 +0100 +++ b/TrainingMessageOrganiser.h Mon Oct 20 19:36:39 2014 +0100 @@ -10,7 +10,6 @@ #define __riftathon__TrainingMessageOrganiser__ #include -#include "trainingTestController.h" #include "MessageOrganiser.h" #include "SequenceController.h" #include "globalVariables.h" @@ -22,8 +21,6 @@ public: void init( PDSynthWrapper& cs, PDSynthWrapper& ts){ - trainingTestController = new TrainingTestController; - MessageOrganiser::init(cs,ts); TickListenerFunction callback; @@ -70,15 +67,16 @@ void onNextTick(int tickNumber){ cout << "TICK " << tickNumber << endl; - if ( tickNumber % 2){ + if ( !(tickNumber % 2)){ // load next target preset - int i = sequenceController.getNextPresetIndex(); + + int i = sequenceController.getCurrentPresetIndex(); currentTargetPreset = expPresetManager.getPreset(i); if (sequencePreview){ // show next target preset - presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage()); + // presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage()); // show image // show name @@ -100,6 +98,7 @@ if (sequencePreview){ // send target values again targetSynth.setAllParams(currentTargetPreset->getValues()); + setSlidersToTarget(); targetSynth.trigger(); // flash the interface? @@ -110,6 +109,18 @@ } } + + int run = sequenceController.stepForward(); + if (run == -2){ + // do finished run stuff, show summary + candidateSynth.stopMetronome(); + cout << "FINISHED RUN" << endl; + } + if (run == -1){ + // finished whole block + candidateSynth.stopMetronome(); + cout << "FINISHED BLOCK" << endl; + } } @@ -195,7 +206,6 @@ } } SequenceController sequenceController; - TrainingTestController* trainingTestController; bool sequencePreview; Preset * currentTargetPreset; IconPanel* presetIconPanel; diff -r af71bf84660f -r ab3e0e980c82 globalVariables.h --- a/globalVariables.h Mon Oct 20 14:12:23 2014 +0100 +++ b/globalVariables.h Mon Oct 20 19:36:39 2014 +0100 @@ -29,7 +29,7 @@ #define ALTERNATION_SPEED 180 // ms that target / candidate sounds play // globles -#define TOTAL_NUM_PARAMS 6 +#define TOTAL_NUM_PARAMS 8 #define TARGET_SCORE_CC_BAND 6 // number of cc vals per target band in dartboard typedef enum {TOUCH_DOWN, TOUCH_MOVED, TOUCH_UP} touchType; typedef enum {INTRO,QUESTIONNAIRE, HELP, TEST_IN_PROGRESS, SCORE_AND_HINT, COUNT_DOWN, READY_FOR_NEXT} interfaceType; diff -r af71bf84660f -r ab3e0e980c82 presetManager.h --- a/presetManager.h Mon Oct 20 14:12:23 2014 +0100 +++ b/presetManager.h Mon Oct 20 19:36:39 2014 +0100 @@ -58,8 +58,6 @@ double timemsd = [NSDate timeIntervalSinceReferenceDate]; creationTime = (unsigned long long)(timemsd*1000); - cout << "Create preset sys time: " << creationTime << "\n"; - //TODO color / texture? imageFileName = imageFile; if (imageFileName != ""){ diff -r af71bf84660f -r ab3e0e980c82 presetManager.mm --- a/presetManager.mm Mon Oct 20 14:12:23 2014 +0100 +++ b/presetManager.mm Mon Oct 20 19:36:39 2014 +0100 @@ -12,6 +12,20 @@ extern EventLogger eventLogger; +template +vector makeVector8(T a1, T a2,T a3,T a4,T a5,T a6, T a7, T a8){ + + vector vec; + vec.push_back(a1); + vec.push_back(a2); + vec.push_back(a3); + vec.push_back(a4); + vec.push_back(a5); + vec.push_back(a6); + vec.push_back(a7); + vec.push_back(a8); + return vec; +} //--------------------------------------------------------------------------- Json::Value Preset::presetToJson(){ @@ -145,7 +159,7 @@ } //----------------------------------------------------------------------------- void PresetManager::generatePresetSlot(const string name, const string imagefn){ - vector values; // empty + vector values = makeVector8(0,0,0,0,45,0,0,0); // empty thePresets.push_back(new Preset(values, name, nextID, eventLogger.userName, eventLogger.deviceID, imagefn)); } diff -r af71bf84660f -r ab3e0e980c82 trainingTestController.h --- a/trainingTestController.h Mon Oct 20 14:12:23 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -// -// trainingController.h -// riftathon -// -// Created by Robert Tubb on 10/10/2014. -// -// this controls the sequence fo events, for both the slider UI and the VR one -// it sends and recieves messages from a wrapper, it doesn't care which interface you're using -// it only cares about the sequence of events - - -#ifndef __riftathon__trainingController__ -#define __riftathon__trainingController__ -#include "presetManager.h" -#include - -// include message types ( or use defines? ) these message type should be sendable by osc / midi -class TrainingTestController { -public: - int numParams; - vector presetSequence; - - // inputs - void soundSubmitted(); - void readyForNextSequence(); - - // outputs - void presentTheSequence(); - void showCountdown(); - void startSearch(); - - // - void makePresetSequence(int sequenceLength); - - Preset getRandomPreset(); - - - -}; -#endif /* defined(__riftathon__trainingController__) */ diff -r af71bf84660f -r ab3e0e980c82 trainingTestController.mm --- a/trainingTestController.mm Mon Oct 20 14:12:23 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -// -// trainingController.mm -// riftathon -// -// Created by Robert Tubb on 10/10/2014. -// -// - -#include "trainingTestController.h"