Mercurial > hg > tweakathon2ios
changeset 29:e7af34b1af83
animated sliders
throughput calculation
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Mon, 03 Nov 2014 18:27:58 +0000 |
parents | 953db6518738 |
children | 78b51f924ec1 |
files | SequenceController.h SequenceController.mm TrainingMessageOrganiser.mm TrainingScoreManager.h UI code/6Dbox.h UI code/6Dbox.mm UI code/ButtronSlider.h UI code/ButtronSlider.mm UI code/sliderPanel.mm globalVariables.h testApp.mm |
diffstat | 11 files changed, 90 insertions(+), 153 deletions(-) [+] |
line wrap: on
line diff
--- a/SequenceController.h Thu Oct 30 18:35:00 2014 +0000 +++ b/SequenceController.h Mon Nov 03 18:27:58 2014 +0000 @@ -12,12 +12,13 @@ #include <iostream> #include "ofMain.h" -#define MIN_TARGETS_IN_SEQUENCE 2 +#define MIN_TARGETS_IN_SEQUENCE 1 #define MAX_TARGETS_IN_SEQUENCE 5 #define MIN_TEMPO 60 #define MAX_TEMPO 300 #define NUM_TEMPO_STEPS 12 #define NUM_PRESETS 8 +#define SPACER_BARS true #define NO_GUIDES_LEVEL true class AnimStep{
--- a/SequenceController.mm Thu Oct 30 18:35:00 2014 +0000 +++ b/SequenceController.mm Mon Nov 03 18:27:58 2014 +0000 @@ -261,8 +261,10 @@ nextStep.type = AnimStep::PREVIEW_MOVE; steps.push_back(nextStep); - nextStep.type = AnimStep::PREVIEW_HIT; - steps.push_back(nextStep); + if (SPACER_BARS){ + nextStep.type = AnimStep::PREVIEW_HIT; + steps.push_back(nextStep); + } n++; } @@ -283,10 +285,12 @@ } nextStep.type = AnimStep::MATCHING_MOVE; steps.push_back(nextStep); - n++; - nextStep.type = AnimStep::MATCHING_HIT; - steps.push_back(nextStep); + if (SPACER_BARS){ + nextStep.type = AnimStep::MATCHING_HIT; + steps.push_back(nextStep); + + } n++; }
--- a/TrainingMessageOrganiser.mm Thu Oct 30 18:35:00 2014 +0000 +++ b/TrainingMessageOrganiser.mm Mon Nov 03 18:27:58 2014 +0000 @@ -88,11 +88,12 @@ return; } - if (mappingID == TRIGGER_CANDIDATE_ID){ + if (mappingID == START_TRAINING_SEQUENCE_ID){ //triggerCandidateSound(); // compare to target candidateSynth.setMetroTime(sequenceController.getStartTickTime()); candidateSynth.startMetronome(); + bottomPanel->hide(); return; } @@ -102,7 +103,7 @@ //----------------------------------------------------------------------- void TrainingMessageOrganiser::onNextTick(int tickNumber){ static int showingCountdown = false; - cout << "TICK " << tickNumber << endl; + downCounter = 4 - tickNumber % 4; if (showingCountdown){ @@ -115,134 +116,6 @@ 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; - controlPanel->hide(); - middlePanel->setColor(ofColor::white); - middlePanel->setText("FINISHED BLOCK"); - return; - } - if(newStep.isLastOfRun){ - // do finished run stuff, show summary - candidateSynth.stopMetronome(); - cout << "FINISHED RUN" << endl; - controlPanel->hide(); - middlePanel->setColor(ofColor::white); - middlePanel->setText("FINISHED RUN"); - middlePanel->show(); - return; - } - - candidateSynth.setMetroTime(newStep.getTimeBetweenTicks()); - - if(newStep.showsCountDown){ - // count in - showingCountdown = true; - middlePanel->show(); - }else{ - showingCountdown = false; - } - - Preset * currentTargetPreset; - - if(newStep.presetIndex >= 0 && newStep.presetIndex <= 8){ - currentTargetPreset = expPresetManager.getPresetAtIndex(newStep.presetIndex); - }else{ - assert(newStep.type == Step::COUNT_IN); - // nothing happens here - return; - } - - vector<int> newTargetValues = currentTargetPreset->getValues(); - debugVals(newTargetValues); - - if(newStep.hidesSliders){ - controlPanel->hide(); - middlePanel->setBackground(ofColor(255,0,0)); - middlePanel->show(); - }else{ - controlPanel->show(); - middlePanel->hide(); - } - - if(newStep.showsTargetIcon){ - bool showTick = true; - presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), showTick); - presetIconPanel->show(); - box6D->setHintTexture(currentTargetPreset->getImage()); - }else{ - presetIconPanel->hide(); - } - - if(newStep.allowsCandidateControl){ - setCandidateAndSlidersToRandom(); - controlPanel->setActive(true); - okToGetMidi = true; - }else{ - controlPanel->setActive(false); - okToGetMidi = false; - } - - if(newStep.showsControlSettings){ - // actually alters the slider values - targetSynth.setAllParams(newTargetValues); - setAllSlidersToValues(newTargetValues); - box6D->setValues(newTargetValues); - }else{ - - - } - - controlPanel->setHintValues(newTargetValues); - box6D->setHintValues(newTargetValues); - - if(newStep.showsControlGuides){ - // shows visual target lines on sliders (or target hand in VR) - - controlPanel->showHint(true); - box6D->showHint(true); - }else{ - controlPanel->showHint(false); - box6D->showHint(false); - } - - - if(newStep.showsMatchResults){ - // do something - //newStep->calculateResults(); - TrainingTestResult result = - trainingScoreManager.getScoreForAnswer(candidateSynth.getAllParamValues(), - newTargetValues, - newStep.getTimeBetweenTicks()); - - - //middlePanel->setLabel(result.displayText); - middlePanel->setColor(result.colorBand); - middlePanel->setText(result.displayText); - controlPanel->setHintColor(result.colorBand); - controlPanel->showHint(true); - middlePanel->show(); - }else{ - middlePanel->setText(""); - } - - if(newStep.playsTarget){ - targetSynth.setAllParams(newTargetValues); - targetSynth.trigger(); - } - if(newStep.playsCandidate){ - triggerCandidateSound(); - } - */ } void TrainingMessageOrganiser::lastOfRun(){ @@ -252,14 +125,16 @@ middlePanel->setColor(ofColor::white); middlePanel->setText("FINISHED RUN"); middlePanel->show(); + bottomPanel->show(); } void TrainingMessageOrganiser::lastOfAll(){ candidateSynth.stopMetronome(); - cout << "FINISHED RUN" << endl; + cout << "FINISHED BLOCK" << endl; controlPanel->hide(); middlePanel->setColor(ofColor::white); - middlePanel->setText("FINISHED RUN"); + middlePanel->setText("FINISHED BLOCK"); middlePanel->show(); + bottomPanel->show(); } //----------------------------------------------------------------------------- void TrainingMessageOrganiser::onNextTickAnim(int tickNumber){ @@ -356,6 +231,8 @@ //controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage()); controlPanel->animateToNewHintValues(newTargetValues, newStep.getTimeBetweenTicks()*4, currentTargetPreset->getImage()); displayInstructions("preview Move"); + + targetSynth.trigger(); } //----------------------------------------------------------------------------- void TrainingMessageOrganiser::previewHit(AnimStep newStep){ @@ -425,7 +302,7 @@ displayInstructions("Match MOVE"); - + triggerCandidateSound(); } //----------------------------------------------------------------------------- @@ -444,10 +321,11 @@ triggerCandidateSound(); displayInstructions("Match HIT"); - + vector<int> startPosition = expPresetManager.getNeutralPreset()->getValues(); TrainingTestResult result = trainingScoreManager.getScoreForAnswer(candidateSynth.getAllParamValues(), + startPosition, newTargetValues, newStep.getTimeBetweenTicks());
--- a/TrainingScoreManager.h Thu Oct 30 18:35:00 2014 +0000 +++ b/TrainingScoreManager.h Mon Nov 03 18:27:58 2014 +0000 @@ -23,6 +23,7 @@ int score; ofColor colorBand; string displayText; + float bits; }; class TrainingScoreManager{ @@ -30,15 +31,21 @@ // equiv of score bit of testController public: - TrainingTestResult getScoreForAnswer(vector<int> targetParams, vector<int> answer, int timeAllowed) const { + TrainingTestResult getScoreForAnswer(vector<int> targetParams, vector<int> startPosition, vector<int> answer, int timeAllowed) const { TrainingTestResult result; stringstream msg; int score = 0; // work out euc distance from actual point //for_each(answer.begin(),answer.end(),printThing<int>()); //for_each(targetParams.begin(),targetParams.end(),printThing<int>()); + float initDist = euclideanDistance(startPosition, answer); float dist = euclideanDistance(targetParams, answer); - auto dimComp = sqrt(6.0); + + float TP = calculateThroughput(TOTAL_NUM_PARAMS, dist, initDist, timeAllowed/1000.); + + cout << TP << endl; + + auto dimComp = sqrt(TOTAL_NUM_PARAMS); int band = -1; if (dist < TARGET_SCORE_CC_BAND*dimComp){ score = 50; @@ -114,7 +121,15 @@ return result; } private: - + float calculateThroughput(int numDims, float endDistance, float startDistance, float time) const{ + + float ISSR = numDims * log2( startDistance / endDistance); + cout << "start: " << startDistance << endl; + cout << "end: " << endDistance << endl; + cout << "ISSR: " << ISSR << endl; + float TP = ISSR / time; + return TP; + } float euclideanDistance(vector<int> v1, vector<int> v2) const{ if (v1.size() != v2.size()){ cout << "ERROR ERROR: vectors must be same length for Mr Euclid";
--- a/UI code/6Dbox.h Thu Oct 30 18:35:00 2014 +0000 +++ b/UI code/6Dbox.h Mon Nov 03 18:27:58 2014 +0000 @@ -66,6 +66,13 @@ }; }; +class GuideHand { + Node pose; + + ofMesh handMesh; + ofImage* textureImageRef; +}; + class Leap6DBox : public Leap3DBoxGL { public: @@ -81,6 +88,7 @@ void drawIndicatorBlob(float x, float y, float z, ofColor c, bool isHint = false); void draw6DOFIndicatorBlob(float x, float y, float z, ofColor c, float r, float p, float yaw,ofImage* texImg); void setTexture(ofImage* img); + void setValue(int index, int value); void setValueAndScale(int index, int value);
--- a/UI code/6Dbox.mm Thu Oct 30 18:35:00 2014 +0000 +++ b/UI code/6Dbox.mm Mon Nov 03 18:27:58 2014 +0000 @@ -21,7 +21,7 @@ float azx, float azy, const UIProps& props) : -Leap3DBoxGL(ax,ay,awidth, aheight, azx, azy, props) + Leap3DBoxGL(ax,ay,awidth, aheight, azx, azy, props) { rollVal = 0.0;
--- a/UI code/ButtronSlider.h Thu Oct 30 18:35:00 2014 +0000 +++ b/UI code/ButtronSlider.h Mon Nov 03 18:27:58 2014 +0000 @@ -74,7 +74,8 @@ minVal = lo; maxVal = hi; } - + void animateHintToNewValue(int newVal, float timeToTake); + void update(); private: void drawIndicator(double proportion); float minVal; @@ -83,9 +84,11 @@ SliderType sliderType; float value; // [0. 1.] float hintValue; + float posAnimIncr; bool hintShowing; bool indicatorShowing; ofColor hintColor; + bool animating; }; #endif /* defined(__emptyExample__ButtronSlider__) */
--- a/UI code/ButtronSlider.mm Thu Oct 30 18:35:00 2014 +0000 +++ b/UI code/ButtronSlider.mm Mon Nov 03 18:27:58 2014 +0000 @@ -84,6 +84,18 @@ } +void ButtronSlider::animateHintToNewValue(int newVal, float timeToTake){ + float targVal = (newVal - minVal)/(maxVal - minVal); + + float amtPerFrame = 1000./(ofGetFrameRate() * timeToTake); + posAnimIncr = (targVal - hintValue )*amtPerFrame; + animating = true; +} + +void ButtronSlider::update(){ + if (!animating) return; + hintValue += posAnimIncr; +} //--------------------------------------------------------------------- bool ButtronSlider::handleMyTouch(int tx, int ty, touchType ttype, int touchID){ @@ -104,4 +116,5 @@ if(callback) callback(myParamID,scaleVal); return true; -} \ No newline at end of file +} +
--- a/UI code/sliderPanel.mm Thu Oct 30 18:35:00 2014 +0000 +++ b/UI code/sliderPanel.mm Mon Nov 03 18:27:58 2014 +0000 @@ -129,12 +129,12 @@ box->setHintValues(vals); } }else if(thisPanelType == ALL_SLIDERS){ - int i = 0; - for(auto UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){ - ButtronSlider* thisSlider = (ButtronSlider *)(*UIitr); - thisSlider->setHintValue(vals[i]); - i++; - } + int i = 0; + for(auto UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){ + ButtronSlider* thisSlider = (ButtronSlider *)(*UIitr); + thisSlider->setHintValue(vals[i]); + i++; + } } } //------------------------ @@ -278,6 +278,14 @@ box->animateHintToNewValues(newTargetValues, timeToTake, newTexture); } + }else if(thisPanelType == ALL_SLIDERS){ + int i = 0; + for(auto UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){ + ButtronSlider* thisSlider = (ButtronSlider *)(*UIitr); + + thisSlider->animateHintToNewValue(newTargetValues[i], timeToTake); + i++; + } } } @@ -291,6 +299,12 @@ box->update(); } + }else if(thisPanelType == ALL_SLIDERS){ + for(auto UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){ + ButtronSlider* thisSlider = (ButtronSlider *)(*UIitr); + thisSlider->update(); + + } } }
--- a/globalVariables.h Thu Oct 30 18:35:00 2014 +0000 +++ b/globalVariables.h Mon Nov 03 18:27:58 2014 +0000 @@ -24,6 +24,7 @@ #define RESTART_EXPERIMENT_ID 99658290 #define SPEED_CHANGE_ID 99573012 #define VOLUME_CHANGE_ID 99263748 +#define START_TRAINING_SEQUENCE_ID 99189938 #define SAVE_PRESET_HIT 99245748 #define RECALL_PRESET_HIT 99298750 #define ALTERNATION_SPEED 180 // ms that target / candidate sounds play
--- a/testApp.mm Thu Oct 30 18:35:00 2014 +0000 +++ b/testApp.mm Mon Nov 03 18:27:58 2014 +0000 @@ -138,7 +138,7 @@ // play and submit are now same thing Buttron * playCandidateButton = new Buttron(props->buttonWidth*1.4,680, *props); playCandidateButton->setLabel("START"); - trainingMessageOrganiser.mapButtonToAction(playCandidateButton, TRIGGER_CANDIDATE_ID); + trainingMessageOrganiser.mapButtonToAction(playCandidateButton, START_TRAINING_SEQUENCE_ID); bottomButtonPanel->addButton(playCandidateButton); bottomButtonPanel->hide();