# HG changeset patch # User Robert Tubb # Date 1413570210 -3600 # Node ID e25d2b1b185e3502e44fb71e5f4bdd1344f80ea1 # Parent d5e928887f5104a37d18115e691e5e98f9ee88b5 Sequence manager generates sequences of target sounds. psudocode for onTick() diff -r d5e928887f51 -r e25d2b1b185e ExplorePresetManager.h --- a/ExplorePresetManager.h Fri Oct 17 17:50:41 2014 +0100 +++ b/ExplorePresetManager.h Fri Oct 17 19:23:30 2014 +0100 @@ -87,6 +87,17 @@ void presentNextPreset(){ } + + Preset* getPreset(int index){ + + if (index >= thePresets.size()){ + cout << "ERROR: index exceeds number of presets" << endl; + return NULL; + }else{ + return thePresets[index]; + + } + }; protected: int filledSlots; string presetSlotFilename; diff -r d5e928887f51 -r e25d2b1b185e SearchMessageOrganiser.h --- a/SearchMessageOrganiser.h Fri Oct 17 17:50:41 2014 +0100 +++ b/SearchMessageOrganiser.h Fri Oct 17 19:23:30 2014 +0100 @@ -219,28 +219,9 @@ showingHint = true; } } - if(mappingID == SAVE_PRESET_HIT){ - expPresetManager.savePreset("blah", candidateSynth.getAllParamValues()); - - } - if(mappingID == RECALL_PRESET_HIT){ - - loadPreset("blah"); - //candidateSynth.startMetronome(); - - } + } - //TODO move this - void loadPreset(string pname){ - - vector values = expPresetManager.recallPreset(pname); - if (values.size()){ - candidateSynth.setAllParams(values); - setAllSlidersToValues(values); - }else{ - cout << "ERROR, no preset found" << endl; - } - } + // called from UI diff -r d5e928887f51 -r e25d2b1b185e SequenceController.h --- a/SequenceController.h Fri Oct 17 17:50:41 2014 +0100 +++ b/SequenceController.h Fri Oct 17 19:23:30 2014 +0100 @@ -12,6 +12,13 @@ #include #include "presetManager.h" +#define MAX_TARGETS_IN_SEQUENCE 8 +#define MIN_TEMPO 80 +#define MAX_TEMPO 200 +#define NUM_TEMPO_STEPS 8 +#define NUM_PRESETS 16 + + class Sequence{ int tempo; vector presetSequence; @@ -19,16 +26,66 @@ }; -class SequenceControler{ +class SequenceController{ +public: + SequenceController(){ + makeSequences(); + }; + SequenceController(const vector& presets) + : thePresets(presets) - SequenceControler(const vector& presets); + { + + makeSequences(); + }; + Sequence getNextSequence(); + int getNextPresetIndex(){ + + // if end of sequence return something else so we can do something + // if end of tempo ramp return something else + + }; +protected: + void makeSequences(){ + + + for(int numInSequence = 1; numInSequence < MAX_TARGETS_IN_SEQUENCE; numInSequence++){ + for(int tempoLevel = 0; tempoLevel < NUM_TEMPO_STEPS; tempoLevel++){ + + vector indexSequence; + + // repeat the same tests for xtra practice? + for(int n=0; n < numInSequence; n++){ + int next = getRandomButNot(NUM_PRESETS,indexSequence); + indexSequence.push_back(next); + + cout << next << ","; + } + cout << endl; + } + cout << "---" << endl; + } + }; - void makeSequences(); + int getRandomButNot(int max, vector notThese){ + + bool there = true; + uint randomInt = rand() % max; + + if (notThese.size()){ + while(there){ + randomInt = rand() % max; + vector::iterator result = std::find(notThese.begin(), notThese.end(), randomInt); + there = (result != notThese.end()); + } + } + return randomInt; + + }; - Sequence getNextSequence(); private: - const vector& thePresets; + const vector thePresets; vector theSequences; }; diff -r d5e928887f51 -r e25d2b1b185e TrainingMessageOrganiser.h --- a/TrainingMessageOrganiser.h Fri Oct 17 17:50:41 2014 +0100 +++ b/TrainingMessageOrganiser.h Fri Oct 17 19:23:30 2014 +0100 @@ -12,6 +12,10 @@ #include #include "trainingTestController.h" #include "MessageOrganiser.h" +#include "SequenceController.h" + +extern ExplorePresetManager expPresetManager; + class TrainingMessageOrganiser : public MessageOrganiser { public: void init( PDSynthWrapper& cs, PDSynthWrapper& ts){ @@ -52,8 +56,73 @@ }; + + void onNextTick(int tickNumber){ + if ( tickNumber % 2){ + // load next target preset + int i = sequenceController.getNextPresetIndex(); + + currentTargetPreset = expPresetManager.getPreset(i); + + if (sequencePreview){ + // show next target preset + + // show image + // show name + // show controllersettings + + + }else{ // the user is matching it + // show image + // show name + + // if guided + // show controller guide + } + + + }else{ // we're plying the sound + + // + if (sequencePreview){ + // send target values again + targetSynth.setAllParams(currentTargetPreset->getValues()); + targetSynth.trigger(); + + // flash the interface? + }else{ + // else the user should be hitting the play button + + } + } + } + protected: + + void loadPreset(string pname){ + + vector values = expPresetManager.recallPreset(pname); + if (values.size()){ + candidateSynth.setAllParams(values); + setAllSlidersToValues(values); + }else{ + cout << "ERROR, no preset found" << endl; + } + } + + + void showATargetPresetWithGuide(Preset * p){ // this is when demoing the sequence to the user + // p.show icon + vector values = p->getValues(); + if (values.size()){ + candidateSynth.setAllParams(values); + setAllSlidersToValues(values); + }else{ + cout << "WARNING, preset to show had no values" << endl; + } + } + void mapSlidersToParams(vector elems, vector mids){ vector::iterator elit; @@ -86,15 +155,27 @@ if(mappingID == VOLUME_CHANGE_ID){ targetSynth.sendVolume(value); candidateSynth.sendVolume(value); - + return; } if (mappingID == TRIGGER_CANDIDATE_ID){ triggerCandidateSound(); + // compare to target + return; + } + if(mappingID == SAVE_PRESET_HIT){ + expPresetManager.savePreset("blah", candidateSynth.getAllParamValues()); + return; + } + if(mappingID == RECALL_PRESET_HIT){ + + loadPreset("blah"); return; } } - + SequenceController sequenceController; TrainingTestController* trainingTestController; + bool sequencePreview; + Preset * currentTargetPreset; }; #endif /* defined(__riftathon__TrainingMessageOrganiser__) */