Mercurial > hg > tweakathon2ios
changeset 21:5cf2b80909fc
Hints and sliders show ok for training sequences.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Wed, 22 Oct 2014 18:12:12 +0100 |
parents | 1e6d4ece1572 |
children | 8124f46eda65 |
files | ExpMessageOrganiser.mm IntroViewController.xib MessageOrganiser.h MessageOrganiser.mm SequenceController.h SequenceController.mm TrainingMessageOrganiser.h TrainingMessageOrganiser.mm UI code/ButtronSlider.mm UI code/sliderPanel.h testApp.mm |
diffstat | 11 files changed, 469 insertions(+), 408 deletions(-) [+] |
line wrap: on
line diff
--- a/ExpMessageOrganiser.mm Wed Oct 22 16:47:11 2014 +0100 +++ b/ExpMessageOrganiser.mm Wed Oct 22 18:12:12 2014 +0100 @@ -19,7 +19,8 @@ setupDefaultMapping(); expPresetManager.goToFirstEmptySlot(); showCurrentSlot(); - + instructionPanel->setLabel("Find a sound\n that expresses:"); + instructionPanel->show(); }
--- a/IntroViewController.xib Wed Oct 22 16:47:11 2014 +0100 +++ b/IntroViewController.xib Wed Oct 22 18:12:12 2014 +0100 @@ -17,7 +17,7 @@ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <subviews> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="4"> - <rect key="frame" x="328" y="626" width="154" height="61"/> + <rect key="frame" x="267" y="529" width="154" height="61"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <state key="normal" title="EXP" backgroundImage="buttron.png"> <color key="titleColor" red="0.28581259671449843" green="0.80918817934782605" blue="0.73026968770868927" alpha="1" colorSpace="calibratedRGB"/> @@ -29,7 +29,7 @@ </connections> </button> <button appearanceType="aqua" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="WDx-XU-GHx"> - <rect key="frame" x="510" y="626" width="142" height="61"/> + <rect key="frame" x="449" y="529" width="142" height="61"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <state key="normal" title="TRAIN" backgroundImage="buttron.png"> <color key="titleColor" red="0.28581259669999998" green="0.80918817929999998" blue="0.7302696877" alpha="1" colorSpace="calibratedRGB"/> @@ -41,7 +41,7 @@ </connections> </button> <button appearanceType="aqua" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="ngS-Bg-YOQ"> - <rect key="frame" x="679" y="626" width="152" height="61"/> + <rect key="frame" x="618" y="529" width="152" height="61"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <state key="normal" title="SEARCH" backgroundImage="buttron.png"> <color key="titleColor" red="0.28581259669999998" green="0.80918817929999998" blue="0.7302696877" alpha="1" colorSpace="calibratedRGB"/> @@ -52,7 +52,7 @@ <action selector="hide:" destination="-1" eventType="touchUpInside" id="pSz-nO-BgA"/> </connections> </button> - <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="Welcome to RIFTATHON." lineBreakMode="tailTruncation" numberOfLines="39" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="14"> + <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="Welcome to RIFTATHON." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="39" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="14"> <rect key="frame" x="158" y="-139" width="773" height="735"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
--- a/MessageOrganiser.h Wed Oct 22 16:47:11 2014 +0100 +++ b/MessageOrganiser.h Wed Oct 22 18:12:12 2014 +0100 @@ -101,6 +101,7 @@ void setSlidersToTarget(); void setSlidersToDefault(); + void showTargetAsHints(); bool onlyChangeCandidateOnTrigger; };
--- a/MessageOrganiser.mm Wed Oct 22 16:47:11 2014 +0100 +++ b/MessageOrganiser.mm Wed Oct 22 18:12:12 2014 +0100 @@ -184,6 +184,15 @@ setUIToParam(i, vals[i]); } } +void MessageOrganiser::showTargetAsHints(){ +// int i = 0; +// vector<int> vals = targetSynth.getAllParamValues(); +// for(auto elit=elems.begin(); elit<elems.end();elit++){ +// ButtronSlider* theSlider = (ButtronSlider*)(*elit); +// theSlider->setHintValue(vals[i]); +// i++; +// } +} void MessageOrganiser::setSlidersToDefault(){ for(int i=1; i < targetSynth.getNumParams(); i++){ setUIToParam(i, 0);
--- a/SequenceController.h Wed Oct 22 16:47:11 2014 +0100 +++ b/SequenceController.h Wed Oct 22 18:12:12 2014 +0100 @@ -14,14 +14,17 @@ #define MIN_TARGETS_IN_SEQUENCE 3 #define MAX_TARGETS_IN_SEQUENCE 5 -#define MIN_TEMPO 80 -#define MAX_TEMPO 150 +#define MIN_TEMPO 120 +#define MAX_TEMPO 250 #define NUM_TEMPO_STEPS 16 #define NUM_PRESETS 8 class Step{ public: typedef enum {COUNT_IN, PREVIEW_DISPLAY, PREVIEW_PLAY, MATCHING_INTERACTION, MATCHING_RESULT} stepTypes; + + Step(); + // gui display bool showsTargetIcon; bool showsControlSettings; @@ -46,84 +49,11 @@ int presetIndex; int numInSequence; bool isLastOfAll; - - Step(){ - type = COUNT_IN; - - showsTargetIcon = false; - showsControlSettings = false; - showsControlGuides = false; - showsMatchResults = false; - isPreview = false; - - allowsCandidateControl = false; - playsTarget = false; - playsCandidate = false; - - playsMetroClick = true; - - isLastOfSeq = false; - isLastOfRun = false; - isLastOfAll = false; - presetIndex = -1; - seqNumber = -1; - runNumber = -1; - - tempo = MIN_TEMPO; - } - void setAsPreviewShower(){ - type = PREVIEW_DISPLAY; - showsTargetIcon = true; - showsControlSettings = true; - showsMatchResults = false; - isPreview = true; - - allowsCandidateControl = false; - playsTarget = true; - playsCandidate = false; - playsMetroClick = false; - } - void setAsPreviewPlayer(){ - type = PREVIEW_PLAY; - showsTargetIcon = true; - showsControlSettings = false; - showsMatchResults = false; - isPreview = true; - - allowsCandidateControl = false; - playsTarget = true; - playsCandidate = false; - - playsMetroClick = false; - } - void setAsMatchingPreparer(){ - type = MATCHING_INTERACTION; - showsTargetIcon = true; - showsControlSettings = false; - showsControlGuides = true; - showsMatchResults = false; - isPreview = false; - - allowsCandidateControl = true; - playsTarget = false; - playsCandidate = false; - - playsMetroClick = false; - } - void setAsMatchingReckoner(){ - type = MATCHING_RESULT; - showsTargetIcon = true; - showsControlSettings = false; - showsControlGuides = true; - showsMatchResults = true; // shows how far off you were? - isPreview = false; - - allowsCandidateControl = false; - playsTarget = false; - playsCandidate = true; - - playsMetroClick = false; - } + + void setAsPreviewShower(); + void setAsPreviewPlayer(); + void setAsMatchingPreparer(); + void setAsMatchingReckoner(); float getTimeBetweenTicks(){ return 1000. * (60.0/tempo); @@ -132,138 +62,19 @@ class SequenceController{ public: - SequenceController(){ - tempoInc = float(MAX_TEMPO - MIN_TEMPO) / float(NUM_TEMPO_STEPS); - generateSteps(); - setToStart(); - }; - Step getNextStep(){ - - currentStep++; - if ((*currentStep).isLastOfRun){ - // uh - } - if ((*currentStep).isLastOfSeq){ - - } - return (*currentStep); - - }; - void setToStart(){ - currentStep = steps.begin(); - } - void stepForward(){ - currentStep++; - }; - float getStartTickTime(){ - return 1000. * (60.0/MIN_TEMPO); - } + SequenceController(); + Step getNextStep(); + void setToStart(); + void stepForward(); + float getStartTickTime(); private: - void generateSteps(){ - srand (time(NULL)); - - int run = 0; - - - - for(int numInSequence = MIN_TARGETS_IN_SEQUENCE; numInSequence <= MAX_TARGETS_IN_SEQUENCE; numInSequence++){ - generateCountIn(2); - generateARun(run, numInSequence); - - steps.back().isLastOfRun = true; - run++; - cout << "-generate run finished-" << endl; - } - steps.back().isLastOfAll = true; - }; - void generateCountIn(int countInLength){ - Step countStep; - for (int i = 0; i < countInLength; i++){ - countStep.numInSequence = countInLength - i + 1; - steps.push_back(countStep); - - } - }; - void generateARun(int run, int numInSequence){ - float curTempo = MIN_TEMPO; - int seqNo = 0; - - for(int tempoLevel = 0; tempoLevel < NUM_TEMPO_STEPS; tempoLevel++){ - - vector<int> stepPreset; - - // get some random ints - for(int n=0; n < numInSequence; n++){ - int nextPreset = getRandomButNot(NUM_PRESETS,stepPreset); - stepPreset.push_back(nextPreset); - cout << nextPreset << ","; - } - // put preview - Step nextStep; - - int n = 0; - for(auto si = stepPreset.begin(); si < stepPreset.end(); si++){ - // put loader - - nextStep.presetIndex = *si; - nextStep.runNumber = run; - nextStep.seqNumber = seqNo; - nextStep.numInSequence = n; - nextStep.tempo = curTempo; - nextStep.setAsPreviewShower(); - steps.push_back(nextStep); - - // put player -// -// nextStep.setAsPreviewPlayer(); -// steps.push_back(nextStep); - n++; - } - // last one in sequence allows control ? - steps.back().allowsCandidateControl = true; - // put in matching sequence - n = 0; - for(auto si = stepPreset.begin(); si < stepPreset.end(); si++){ - // put loader - - nextStep.presetIndex = *si; - nextStep.numInSequence = n; - nextStep.setAsMatchingPreparer(); - steps.push_back(nextStep); - - // put player - - nextStep.setAsMatchingReckoner(); - steps.push_back(nextStep); - n++; - } - - steps.back().isLastOfSeq = true; - curTempo += tempoInc; - seqNo++; - cout << endl; - - } - - } + void generateSteps(); + void generateCountIn(int countInLength); + void generateARun(int run, int numInSequence); - int getRandomButNot(int max, vector<int> notThese){ - - bool there = true; - int randomInt = rand() % max; - - if (notThese.size()){ - while(there){ - randomInt = rand() % max; - vector<int>::iterator result = std::find(notThese.begin(), notThese.end(), randomInt); - there = (result != notThese.end()); - } - } - return randomInt; - - }; - + int getRandomButNot(int max, vector<int> notThese); +protected: vector<Step> steps; vector<Step>::iterator currentStep; float tempoInc;
--- a/SequenceController.mm Wed Oct 22 16:47:11 2014 +0100 +++ b/SequenceController.mm Wed Oct 22 18:12:12 2014 +0100 @@ -7,3 +7,221 @@ // #include "SequenceController.h" + +Step::Step(){ + type = COUNT_IN; + + showsTargetIcon = false; + showsControlSettings = false; + showsControlGuides = false; + showsMatchResults = false; + isPreview = false; + + allowsCandidateControl = false; + playsTarget = false; + playsCandidate = false; + + playsMetroClick = true; + + isLastOfSeq = false; + isLastOfRun = false; + isLastOfAll = false; + presetIndex = -1; + seqNumber = -1; + runNumber = -1; + + tempo = MIN_TEMPO; +} + +void Step::setAsPreviewShower(){ + type = PREVIEW_DISPLAY; + showsTargetIcon = true; + showsControlSettings = true; + showsControlGuides = true; + showsMatchResults = false; + isPreview = true; + + allowsCandidateControl = false; + playsTarget = true; + playsCandidate = false; + playsMetroClick = false; +} +void Step::setAsPreviewPlayer(){ + type = PREVIEW_PLAY; + showsTargetIcon = true; + showsControlSettings = true; + showsControlGuides = true; + showsMatchResults = false; + isPreview = true; + + allowsCandidateControl = false; + playsTarget = true; + playsCandidate = false; + + playsMetroClick = false; +} +void Step::setAsMatchingPreparer(){ + type = MATCHING_INTERACTION; + showsTargetIcon = true; + showsControlSettings = false; + showsControlGuides = true; + showsMatchResults = false; + isPreview = false; + + allowsCandidateControl = true; + playsTarget = false; + playsCandidate = false; + + playsMetroClick = false; +} +void Step::setAsMatchingReckoner(){ + type = MATCHING_RESULT; + showsTargetIcon = true; + showsControlSettings = false; + showsControlGuides = true; + showsMatchResults = true; // shows how far off you were? + isPreview = false; + + allowsCandidateControl = false; + playsTarget = false; + playsCandidate = true; + + playsMetroClick = false; +} + + +//================================================================= +//================================================================= +//================================================================= + +SequenceController::SequenceController(){ + tempoInc = float(MAX_TEMPO - MIN_TEMPO) / float(NUM_TEMPO_STEPS); + generateSteps(); + setToStart(); +}; +Step SequenceController::getNextStep(){ + + currentStep++; + if ((*currentStep).isLastOfRun){ + // uh + } + if ((*currentStep).isLastOfSeq){ + + } + return (*currentStep); + +}; +void SequenceController::setToStart(){ + currentStep = steps.begin(); +} +void SequenceController::stepForward(){ + currentStep++; +}; +float SequenceController::getStartTickTime(){ + return 1000. * (60.0/MIN_TEMPO); +} + +void SequenceController::generateSteps(){ + srand (time(NULL)); + + int run = 0; + + + + for(int numInSequence = MIN_TARGETS_IN_SEQUENCE; numInSequence <= MAX_TARGETS_IN_SEQUENCE; numInSequence++){ + generateCountIn(2); + generateARun(run, numInSequence); + + steps.back().isLastOfRun = true; + run++; + cout << "-generate run finished-" << endl; + } + steps.back().isLastOfAll = true; +}; +void SequenceController::generateCountIn(int countInLength){ + Step countStep; + for (int i = 0; i < countInLength; i++){ + countStep.numInSequence = countInLength - i + 1; + steps.push_back(countStep); + + } +}; +void SequenceController::generateARun(int run, int numInSequence){ + float curTempo = MIN_TEMPO; + int seqNo = 0; + + for(int tempoLevel = 0; tempoLevel < NUM_TEMPO_STEPS; tempoLevel++){ + + vector<int> stepPreset; + + // get some random ints + for(int n=0; n < numInSequence; n++){ + int nextPreset = getRandomButNot(NUM_PRESETS,stepPreset); + stepPreset.push_back(nextPreset); + cout << nextPreset << ","; + } + // put preview + Step nextStep; + + int n = 0; + for(auto si = stepPreset.begin(); si < stepPreset.end(); si++){ + // put loader + + nextStep.presetIndex = *si; + nextStep.runNumber = run; + nextStep.seqNumber = seqNo; + nextStep.numInSequence = n; + nextStep.tempo = curTempo; + nextStep.setAsPreviewShower(); + steps.push_back(nextStep); + + // put player + // + nextStep.setAsPreviewPlayer(); + steps.push_back(nextStep); + n++; + } + // last one in sequence allows control ? + steps.back().allowsCandidateControl = true; + // put in matching sequence + n = 0; + for(auto si = stepPreset.begin(); si < stepPreset.end(); si++){ + // put loader + + nextStep.presetIndex = *si; + nextStep.numInSequence = n; + nextStep.setAsMatchingPreparer(); + steps.push_back(nextStep); + + // put player + + nextStep.setAsMatchingReckoner(); + steps.push_back(nextStep); + n++; + } + + steps.back().isLastOfSeq = true; + curTempo += tempoInc; + seqNo++; + cout << endl; + + } + +} + + +int SequenceController::getRandomButNot(int max, vector<int> notThese){ + + bool there = true; + int randomInt = rand() % max; + + if (notThese.size()){ + while(there){ + randomInt = rand() % max; + vector<int>::iterator result = std::find(notThese.begin(), notThese.end(), randomInt); + there = (result != notThese.end()); + } + } + return randomInt; + +}; \ No newline at end of file
--- a/TrainingMessageOrganiser.h Wed Oct 22 16:47:11 2014 +0100 +++ b/TrainingMessageOrganiser.h Wed Oct 22 18:12:12 2014 +0100 @@ -20,198 +20,28 @@ class TrainingMessageOrganiser : public MessageOrganiser { public: int numParamsToUse; - void init( PDSynthWrapper& cs, PDSynthWrapper& ts){ - - MessageOrganiser::init(cs,ts); - - TickListenerFunction callback; - callback = boost::bind(&TrainingMessageOrganiser::onNextTick, this, _1); - candidateSynth.registerForTicks(callback); - - numParamsToUse = TOTAL_NUM_PARAMS; - - } + void init( PDSynthWrapper& cs, PDSynthWrapper& ts); - void setupDefaultMapping(){ - vector<int> mappingIDsForChangeableParams = getMappingIDsFromSynths(); - - controlPanelType cpt = REVISITABLE; - vector<controllerType> elemList; - for(int i = 0; i < numParamsToUse; i++){ - elemList.push_back(SLIDER); - } - - vector<UIElement*> UIElemHandles = panel->generateControls(elemList, cpt); - - mapSlidersToParams(UIElemHandles, mappingIDsForChangeableParams); - - bottomPanel->show(); - } - - vector<int> getMappingIDsFromSynths(){ - vector<int> index; - for(int i = 0; i < numParamsToUse; i++){ - index.push_back(i); - } - vector<int> mids = candidateSynth.getMappingIDForIndices(index); - - return mids; - } - - -//----------------------------------------------------------------------- - void displayInstructions(Step s){ - - - if (s.type == Step::COUNT_IN){ - instructionPanel->setText("GET READY"); - } - if (s.type == Step::PREVIEW_DISPLAY){ - instructionPanel->setText("MEMORISE"); - panel->setColor(ofColor(0,0,0)); - } - if (s.type == Step::PREVIEW_PLAY){ - instructionPanel->setText("MEMORISE"); - panel->setColor(ofColor(0,0,0)); - } - if (s.type == Step::MATCHING_INTERACTION){ - instructionPanel->setText("MATCH:"); - panel->setColor(ofColor(100,0,0)); - } - if (s.type == Step::MATCHING_RESULT){ - instructionPanel->setText("RESULT"); - panel->setColor(ofColor(0,100,0)); - } - } -//----------------------------------------------------------------------- - void onNextTick(int tickNumber){ - cout << "TICK " << tickNumber << endl; - - // only first beat in bar is active one - if ( tickNumber % 4 != 0){ - return; - } - // load next target preset - - Step newStep = sequenceController.getNextStep(); - displayInstructions(newStep); - - if(newStep.isLastOfAll){ - // do finished run stuff, show summary - candidateSynth.stopMetronome(); - cout << "FINISHED BLOCK" << endl; - } - if(newStep.isLastOfRun){ - // do finished run stuff, show summary - candidateSynth.stopMetronome(); - cout << "FINISHED RUN" << endl; - } - - float t = newStep.getTimeBetweenTicks(); - candidateSynth.setMetroTime(t); - - if(newStep.type == Step::COUNT_IN){ - // count in - return; - } - - if(newStep.presetIndex >= 0 && newStep.presetIndex <= 8){ - currentTargetPreset = expPresetManager.getPresetAtIndex(newStep.presetIndex); - } - - if(newStep.showsTargetIcon){ - bool showTick = true; - presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), showTick); - presetIconPanel->show(); - }else{ - presetIconPanel->hide(); - } - - if(newStep.showsControlSettings){ - targetSynth.setAllParams(currentTargetPreset->getValues()); - setSlidersToTarget(); - - }else{ - //setSlidersToDefault(); - - } - - if(newStep.playsTarget){ - targetSynth.setAllParams(currentTargetPreset->getValues()); - targetSynth.trigger(); - } - - if(newStep.playsCandidate){ - triggerCandidateSound(); - } - - if(newStep.allowsCandidateControl){ - panel->setActive(true); - }else{ - panel->setActive(false); - } - - if(newStep.showsMatchResults){ - // do something - } - - if(newStep.showsControlGuides){ - - panel->setHintValues(currentTargetPreset->getValues()); - panel->showHint(true); - }else{ - panel->showHint(false); - } - - } + void setupDefaultMapping(); + vector<int> getMappingIDsFromSynths(); + void displayInstructions(Step s); + void onNextTick(int tickNumber); //----------------------------------------------------------------------- protected: - void showUserHowTheyDid(){ - // colour flash - // distance ? - // score - - } - + void showUserHowTheyDid(); + void buttonPressCallback(int mappingID, int value); - - //----------------------------------------------------------------------- - void showATargetPresetWithGuide(Preset * p){ // this is when demoing the sequence to the user - // p.show icon - vector<int> values = p->getValues(); - if (values.size()){ - candidateSynth.setAllParams(values); - setAllSlidersToValues(values); - }else{ - cout << "WARNING, preset to show had no values" << endl; + void debugVals(vector<int> vals){ + cout << "DEBUG VALS: " << endl; + for(int i = 0; i< vals.size(); i++){ + cout << vals[i] << ", "; } - } - //----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- - - void buttonPressCallback(int mappingID, int value){ - if(mappingID == VOLUME_CHANGE_ID){ - targetSynth.sendVolume(value); - candidateSynth.sendVolume(value); - return; - } - - if (mappingID == TRIGGER_CANDIDATE_ID){ - //triggerCandidateSound(); - // compare to target - candidateSynth.setMetroTime(sequenceController.getStartTickTime()); - candidateSynth.startMetronome(); - return; - } - + cout << endl; } //----------------------------------------------------------------------------- SequenceController sequenceController; - Preset * currentTargetPreset; - }; #endif /* defined(__riftathon__TrainingMessageOrganiser__) */
--- a/TrainingMessageOrganiser.mm Wed Oct 22 16:47:11 2014 +0100 +++ b/TrainingMessageOrganiser.mm Wed Oct 22 18:12:12 2014 +0100 @@ -7,3 +7,191 @@ // #include "TrainingMessageOrganiser.h" + +void TrainingMessageOrganiser::init( PDSynthWrapper& cs, PDSynthWrapper& ts){ + + MessageOrganiser::init(cs,ts); + + TickListenerFunction callback; + callback = boost::bind(&TrainingMessageOrganiser::onNextTick, this, _1); + candidateSynth.registerForTicks(callback); + + numParamsToUse = TOTAL_NUM_PARAMS; + +} + +void TrainingMessageOrganiser::setupDefaultMapping(){ + vector<int> mappingIDsForChangeableParams = getMappingIDsFromSynths(); + + controlPanelType cpt = REVISITABLE; + vector<controllerType> elemList; + for(int i = 0; i < numParamsToUse; i++){ + elemList.push_back(SLIDER); + } + + vector<UIElement*> UIElemHandles = panel->generateControls(elemList, cpt); + + mapSlidersToParams(UIElemHandles, mappingIDsForChangeableParams); + + bottomPanel->show(); + + ofColor c = ofColor::yellow; + panel->setHintColor(c); +} + +vector<int> TrainingMessageOrganiser::getMappingIDsFromSynths(){ + vector<int> index; + for(int i = 0; i < numParamsToUse; i++){ + index.push_back(i); + } + vector<int> mids = candidateSynth.getMappingIDForIndices(index); + + return mids; +} + + +//----------------------------------------------------------------------- +void TrainingMessageOrganiser::displayInstructions(Step s){ + + + if (s.type == Step::COUNT_IN){ + instructionPanel->setText("GET READY"); + } + if (s.type == Step::PREVIEW_DISPLAY){ + instructionPanel->setText("MEMORISE"); + panel->setColor(ofColor(0,0,0)); + } + if (s.type == Step::PREVIEW_PLAY){ + instructionPanel->setText("MEMORISE"); + panel->setColor(ofColor(0,0,0)); + } + if (s.type == Step::MATCHING_INTERACTION){ + instructionPanel->setText("MATCH:"); + panel->setColor(ofColor(100,0,0)); + } + if (s.type == Step::MATCHING_RESULT){ + instructionPanel->setText("RESULT"); + panel->setColor(ofColor(0,100,0)); + } +} +//----------------------------------------------------------------------- +void TrainingMessageOrganiser::onNextTick(int tickNumber){ + cout << "TICK " << tickNumber << endl; + + // only first beat in bar is active one + if ( tickNumber % 4 != 0){ + return; + } + // load next target preset + + Step newStep = sequenceController.getNextStep(); + displayInstructions(newStep); + + if(newStep.isLastOfAll){ + // do finished run stuff, show summary + candidateSynth.stopMetronome(); + cout << "FINISHED BLOCK" << endl; + } + if(newStep.isLastOfRun){ + // do finished run stuff, show summary + candidateSynth.stopMetronome(); + cout << "FINISHED RUN" << endl; + } + + float t = newStep.getTimeBetweenTicks(); + candidateSynth.setMetroTime(t); + + if(newStep.type == Step::COUNT_IN){ + // count in + return; + } + + Preset * currentTargetPreset; + + if(newStep.presetIndex >= 0 && newStep.presetIndex <= 8){ + currentTargetPreset = expPresetManager.getPresetAtIndex(newStep.presetIndex); + } + + vector<int> newValues = currentTargetPreset->getValues(); + debugVals(newValues); + + if(newStep.showsTargetIcon){ + bool showTick = true; + presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), showTick); + presetIconPanel->show(); + }else{ + presetIconPanel->hide(); + } + + if(newStep.allowsCandidateControl){ + panel->setActive(true); + }else{ + panel->setActive(false); + } + + if(newStep.showsControlSettings){ + // actually alters the slider values + targetSynth.setAllParams(newValues); + setAllSlidersToValues(newValues); + + }else{ + //setSlidersToDefault(); + + } + + + + if(newStep.showsControlGuides){ + // shows visual target lines on sliders (or target hand in VR) + + panel->setHintValues(newValues); + panel->showHint(true); + }else{ + panel->showHint(false); + } + + + if(newStep.showsMatchResults){ + // do something + } + + if(newStep.playsTarget){ + targetSynth.setAllParams(newValues); + targetSynth.trigger(); + } + if(newStep.playsCandidate){ + triggerCandidateSound(); + } + +} + +//----------------------------------------------------------------------- + +void TrainingMessageOrganiser::showUserHowTheyDid(){ + // colour flash + // distance ? + // score + +} + +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- + +void TrainingMessageOrganiser::buttonPressCallback(int mappingID, int value){ + if(mappingID == VOLUME_CHANGE_ID){ + targetSynth.sendVolume(value); + candidateSynth.sendVolume(value); + return; + } + + if (mappingID == TRIGGER_CANDIDATE_ID){ + //triggerCandidateSound(); + // compare to target + candidateSynth.setMetroTime(sequenceController.getStartTickTime()); + candidateSynth.startMetronome(); + return; + } + +} +//-----------------------------------------------------------------------------
--- a/UI code/ButtronSlider.mm Wed Oct 22 16:47:11 2014 +0100 +++ b/UI code/ButtronSlider.mm Wed Oct 22 18:12:12 2014 +0100 @@ -77,7 +77,7 @@ void ButtronSlider::drawHintIndicator(){ ofSetColor(hintColor); - float hthick = 1; + float hthick = 3; double loc = y + hthick + (1 - hintValue)*(height-3*hthick); ofRect(x+thickness,loc, width-2*thickness,hthick);
--- a/UI code/sliderPanel.h Wed Oct 22 16:47:11 2014 +0100 +++ b/UI code/sliderPanel.h Wed Oct 22 18:12:12 2014 +0100 @@ -22,6 +22,7 @@ #include "ButtronXY.h" #include "3Dbox.h" #include "3DboxGL.h" +#include "ButtronSlider.h" // panel with sliders and xy pads class SliderPanel : public UIElementContainer{ @@ -36,16 +37,18 @@ void showHint(bool value){ vector<UIElement *>::iterator UIitr; for(UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){ - (*UIitr)->showHint(value); + + ButtronSlider* thisSlider = (ButtronSlider *)(*UIitr); + thisSlider->showHint(value); } } // void setHintValues(vector<int> vals){ - auto valItr = vals.begin(); + int i = 0; for(auto UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){ - if (++valItr != vals.end()){ - (*UIitr)->setHintValue(*valItr); - } + ButtronSlider* thisSlider = (ButtronSlider *)(*UIitr); + thisSlider->setHintValue(vals[i]); + i++; } } void setHintColor(ofColor c){
--- a/testApp.mm Wed Oct 22 16:47:11 2014 +0100 +++ b/testApp.mm Wed Oct 22 18:12:12 2014 +0100 @@ -148,13 +148,13 @@ IconPanel* iconPanel = new IconPanel(420, 10, 150, 150, *props); trainingMessageOrganiser.setIconPanel(iconPanel); UIElements.push_back(iconPanel); - iconPanel->show(); + iconPanel->hide(); TextPanel * instructionPanel = new TextPanel("Instrcution panel", 10, 50, 300,150,(*props)); instructionPanel->setFontSize(LARGEFONT); UIElements.push_back(instructionPanel); trainingMessageOrganiser.setInstructionPanel(instructionPanel); - instructionPanel->show(); + instructionPanel->hide(); } //-------------------------------------------------------------- @@ -227,10 +227,10 @@ newTestButton->hide(); searchMessageOrganiser.setNewTestButton(newTestButton); - TargetSymbol* targetSymbol = new TargetSymbol(ofGetWidth()*0.5,160,30,(*props)); - searchMessageOrganiser.setTargetSymbol(targetSymbol); - UIElements.push_back(targetSymbol); - +// TargetSymbol* targetSymbol = new TargetSymbol(ofGetWidth()*0.5,160,30,(*props)); +// searchMessageOrganiser.setTargetSymbol(targetSymbol); +// UIElements.push_back(targetSymbol); +// } //-------------------------------------------------------------- void testApp::setupSliderPanel(){