changeset 36:146033869165

ISSR fixed colors for stages more repetitions
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Tue, 02 Dec 2014 13:25:48 +0000
parents 3b10a26da293
children 52dbd5b4cfa9
files SequenceController.h SequenceController.mm TrainingMessageOrganiser.mm TrainingScoreManager.h UI code/6Dbox.h UI code/6Dbox.mm UI code/sliderPanel.mm testApp.mm
diffstat 8 files changed, 104 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/SequenceController.h	Wed Nov 26 18:18:20 2014 +0000
+++ b/SequenceController.h	Tue Dec 02 13:25:48 2014 +0000
@@ -13,14 +13,21 @@
 #include "ofMain.h"
 #include "presetManager.h"
 #include "TrainingScoreManager.h"
+
 #define MIN_TARGETS_IN_SEQUENCE 1
+#define NUM_REPETITIONS_AT_LEVEL 2
 #define MAX_TARGETS_IN_SEQUENCE 7
-#define MIN_TEMPO   60
-#define MAX_TEMPO   500
-#define NUM_TEMPO_STEPS 15
+#define MIN_TEMPO   70
+#define MAX_TEMPO   480
+#define TEMPO_RANDOM_AMOUNT
+#define MAX_TIME 2800
+#define MIN_TIME 200
+#define NUM_TEMPO_STEPS 17
+
 #define NUM_PRESETS 8
 #define SPACER_BARS false
 #define NO_GUIDES_LEVEL false
+
 class AnimStep{
 
     
@@ -38,9 +45,19 @@
                 stepType;
     
     stepType type;
-    
+    int getTimeAllowed(){
+        return timeAllowedMs;
+    }
     float getTimeBetweenTicks(){
-        return 1000* (60.0/tempo);
+        //return 1000* (60.0/tempo);
+        return timeAllowedMs/4.0;
+    }
+
+    void setTempoFromTime(){
+        tempo = 60.0 / (4* timeAllowedMs*1000.0);
+    }
+    void setTimeFromTempo(){
+        timeAllowedMs = 4*1000* (60.0/tempo);
     }
     int presetIndex;
     Preset * currentTargetPreset;
@@ -49,6 +66,8 @@
     bool isLastOfAll;
 
     int tempo;
+    int tempoLevel;
+    int timeAllowedMs;
     int seqNumber;
     int runNumber;
     int difficulty;
@@ -107,11 +126,6 @@
     void setAsMatchingInteraction();
     void setAsMatchingFeedback();
 
-    
-    float getTimeBetweenTicks(){
-        return 1000. * (60.0/tempo);
-    }
-
 };
 
 class SequenceController{
@@ -138,6 +152,7 @@
     vector<AnimStep> steps;
     vector<AnimStep>::iterator currentStep;
     float tempoInc;
+    int timeInc;
     bool soundOnlyMode;
     int totNumRuns;
 };
--- a/SequenceController.mm	Wed Nov 26 18:18:20 2014 +0000
+++ b/SequenceController.mm	Tue Dec 02 13:25:48 2014 +0000
@@ -24,6 +24,7 @@
     showsIcons = true;
     showsResultsAtEnd = false;
     difficulty = 0;
+    setTimeFromTempo();
 }
 
 void AnimStep::saveResult(TrainingTestResult aresult){
@@ -162,6 +163,7 @@
 void SequenceController::init(bool asoundOnlyMode){
     soundOnlyMode = asoundOnlyMode;
     tempoInc = float(MAX_TEMPO - MIN_TEMPO) / float(NUM_TEMPO_STEPS);
+    timeInc = (MAX_TIME - MIN_TIME) / NUM_TEMPO_STEPS;
     generateSteps();
     setToStart();
 };
@@ -199,6 +201,9 @@
     
     
     for(int numInSequence = MIN_TARGETS_IN_SEQUENCE; numInSequence <= MAX_TARGETS_IN_SEQUENCE; numInSequence++){
+        
+        for(int rep = 0; rep < NUM_REPETITIONS_AT_LEVEL; rep++){
+        
         generateCountIn(1);
         
         if (soundOnlyMode){
@@ -211,6 +216,7 @@
         steps.back().isLastOfRun = true;
         run++;
         cout << "-generate run finished-" << endl;
+        }
     }
     totNumRuns = run;
     steps.back().isLastOfAll = true;
@@ -224,6 +230,7 @@
     for (int i = 0; i < countInLength; i++){
         countStep.whichInSequence = countInLength - i + 1;
         countStep.type = AnimStep::PREVIEW_NEUTRAL_COUNT;
+        countStep.showsResultsAtEnd = false;
         steps.push_back(countStep);
         
     }
@@ -271,6 +278,8 @@
         nextStep.seqNumber = seqNo;
         nextStep.whichInSequence = 0;
         nextStep.tempo = curTempo;
+        nextStep.tempoLevel = tempoLevel;
+        nextStep.setTimeFromTempo();
         nextStep.showsGuides = true;
         nextStep.difficulty = 0;
         nextStep.type = AnimStep::PREVIEW_NEUTRAL_COUNT;
@@ -290,7 +299,6 @@
             nextStep.runNumber = run;
             nextStep.seqNumber = seqNo;
             nextStep.whichInSequence = n;
-            nextStep.tempo = curTempo;
             nextStep.showsGuides = true;
             nextStep.showsIcons = true;
             nextStep.showsResultsAtEnd = false;
@@ -318,6 +326,7 @@
             nextStep.seqNumber = seqNo;
             nextStep.whichInSequence = n;
             nextStep.tempo = curTempo;
+            nextStep.setTimeFromTempo();
             nextStep.showsGuides = true;
             nextStep.showsIcons = true;
             nextStep.showsResultsAtEnd = true;
@@ -347,7 +356,7 @@
             nextStep.runNumber = run;
             nextStep.seqNumber = seqNo;
             nextStep.whichInSequence = n;
-            nextStep.tempo = curTempo;
+
             nextStep.showsGuides = true;
             nextStep.showsIcons = true;
             nextStep.showsResultsAtEnd = true;
@@ -398,7 +407,7 @@
         steps.push_back(nextStep);
         
         steps.back().isLastOfSeq = true;
-        curTempo += tempoInc;
+        curTempo += tempoInc*0.6; // easier!!!
         seqNo++;
         cout << endl;
         
@@ -512,6 +521,8 @@
         nextStep.seqNumber = seqNo;
         nextStep.whichInSequence = 0;
         nextStep.tempo = curTempo;
+        nextStep.tempoLevel = tempoLevel;
+        nextStep.setTimeFromTempo();
         nextStep.showsGuides = true;
         nextStep.type = AnimStep::PREVIEW_NEUTRAL_COUNT;
         nextStep.showsResultsAtEnd = false;
@@ -530,7 +541,7 @@
             nextStep.runNumber = run;
             nextStep.seqNumber = seqNo;
             nextStep.whichInSequence = n;
-            nextStep.tempo = curTempo;
+
             nextStep.showsGuides = true;
             nextStep.showsIcons = true;
             nextStep.showsResultsAtEnd = false;
@@ -558,10 +569,9 @@
             // put loader
             nextStep.difficulty = 1;
             nextStep.presetIndex = *si;
-            nextStep.runNumber = run;
             nextStep.seqNumber = seqNo;
             nextStep.whichInSequence = n;
-            nextStep.tempo = curTempo;
+
             nextStep.showsGuides = true;
             nextStep.showsIcons = true;
             nextStep.showsResultsAtEnd = true;
--- a/TrainingMessageOrganiser.mm	Wed Nov 26 18:18:20 2014 +0000
+++ b/TrainingMessageOrganiser.mm	Tue Dec 02 13:25:48 2014 +0000
@@ -28,6 +28,8 @@
     setupDefaultMapping(whichInterfaceAreWeUsing);
     
     controlPanel->setValues(zeros<int>(TOTAL_NUM_PARAMS));
+    
+    doHand(true);
 }
 //----------------------------------------------------------------------------------------
 void TrainingMessageOrganiser::setMiddlePanel(TextPanel* tp){
@@ -108,10 +110,11 @@
     candidateSynth.stopMetronome();
     stringstream s;
     
-    s << "FINISHED RUN " << which << " OF " << sequenceController.getTotNumRuns() << endl;
+    s << "FINISHED RUN " << which+1 << " OF " << sequenceController.getTotNumRuns() << endl;
     controlPanel->hide();
+    controlPanel->setColor(ofColor::black);
     middlePanel->setColor(ofColor::white);
-    middlePanel->setText("FINISHED RUN");
+    middlePanel->setText(s.str());
     middlePanel->show();
     //playCandidateButton->setLabel("NEXT");
     bottomPanel->show();
@@ -123,8 +126,9 @@
     candidateSynth.stopMetronome();
     cout << "FINISHED BLOCK" << endl;
     controlPanel->hide();
+    controlPanel->setColor(ofColor::black);
     middlePanel->setColor(ofColor::white);
-    middlePanel->setText("FINISHED BLOCK!");
+    middlePanel->setText("CONGRATULATIONS. FINISHED BLOCK!");
     middlePanel->show();
     bottomPanel->show();
     seqNumPanel->hide();
@@ -270,14 +274,16 @@
     presetIconPanel->show();
 
     controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage());
-    controlPanel->setActive(false);
+    doHand(false);
+    controlPanel->show();
     
     targetSynth.setAllParams(newTargetValues);
-    candidateSynth.setAllParams(newTargetValues);
+    //candidateSynth.setAllParams(newTargetValues);
     
     displayInstructions("Get ready for preview");
     seqNumPanel->hide();
     oldTargetValues = newTargetValues;
+    controlPanel->setColor(ofColor::black);
 }
 //-----------------------------------------------------------------------------
 void TrainingMessageOrganiser::previewMove(AnimStep newStep, Preset * currentTargetPreset){
@@ -301,6 +307,8 @@
     displayInstructions("PREVIEW");
     showSeqNum(newStep.whichInSequence);
     oldTargetValues = newTargetValues;
+    
+    controlPanel->setColor(ofColor::black);
 }
 
 
@@ -321,6 +329,8 @@
 
     showSeqNum(newStep.whichInSequence);
     displayInstructions("Preview FINISHED");
+    
+    controlPanel->setColor(ofColor::darkMagenta);
 }
 
 //-----------------------------------------------------------------------------
@@ -432,7 +442,11 @@
 
 
     oldTargetValues = newTargetValues;
-
+    if (newStep.showsGuides){
+        controlPanel->setColor(ofColor::seaGreen);
+    }else{
+        controlPanel->setColor(ofColor::darkMagenta);
+    }
 }
 //-----------------------------------------------------------------------------
 void TrainingMessageOrganiser::matchingLast(AnimStep newStep, Preset * currentTargetPreset){
@@ -453,6 +467,11 @@
 
     triggerCandidateSound();
     oldTargetValues = newTargetValues;
+    if (newStep.showsGuides){
+        controlPanel->setColor(ofColor::seaGreen);
+    }else{
+        controlPanel->setColor(ofColor::darkMagenta);
+    }
 }
 //-----------------------------------------------------------------------------
 
@@ -466,8 +485,12 @@
     trainingScoreManager.getScoreForAnswer(targetPreset->getValues(),
                                            startingPosition,
                                            currentPosition,
-                                           step.getTimeBetweenTicks(),
-                                           step.difficulty, step.whichInSequence, step.presetIndex);
+                                           step.getTimeAllowed(),
+                                           step.difficulty,
+                                           step.whichInSequence,
+                                           step.presetIndex,
+                                           step.tempoLevel,
+                                           step.runNumber);
     
     sequenceController.saveResultForCurrentStep(result);
     instructionPanel->setColor(result.colorBand);
--- a/TrainingScoreManager.h	Wed Nov 26 18:18:20 2014 +0000
+++ b/TrainingScoreManager.h	Tue Dec 02 13:25:48 2014 +0000
@@ -43,16 +43,23 @@
                                          int timeAllowed,
                                          int difficulty,
                                          int whichInSequence,
-                                         int presetIndex) {
+                                         int presetIndex,
+                                         int tempoLevel,
+                                         int runNumber) {
         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 initDist = euclideanDistance(targetParams, startPosition);
         float dist = euclideanDistance(targetParams, answer);
+        if (initDist <= 0) {
+            initDist = 0.001;
+        }
+        if (dist <= 0) dist = 0.001;
         float TP = calculateThroughput(TOTAL_NUM_PARAMS, dist, initDist, timeAllowed/1000.);
+        cout << "Preset index " << presetIndex << endl;
+        cout << "whichInSequence " << whichInSequence << endl;
         
         auto dimComp = sqrt(TOTAL_NUM_PARAMS);
         int band = -1;
@@ -126,7 +133,8 @@
         }
         result.colorBand = c;
 
-        totalScored += score;
+        if(score > 0) totalScored += score;
+        
         
         vector<int> details;
         
@@ -138,7 +146,8 @@
         details.push_back(whichInSequence);
         details.push_back(initDist*1000);
         details.push_back(presetIndex);
-        
+        details.push_back(tempoLevel);
+        details.push_back(runNumber);
         eventLogger.logEvent(TRAINING_RESULT, details);
         details.clear();
         details.insert(details.begin(), targetParams.begin(), targetParams.end());
@@ -148,14 +157,16 @@
         return result;
     }
     
-    int getScore(){return totalScored;};
+    int getScore(){
+        cout << "RUNNING SCORE: " << totalScored << endl;
+        return totalScored;
+    };
     
 private:
     
     
     float calculateThroughput(int numDims, float endDistance, float startDistance, float time) const{
-        if (startDistance == 0) startDistance = 1;
-        if (endDistance == 0) endDistance = 1;
+
         float ISSR = numDims * log2( startDistance / endDistance);
         cout << "==========Result======= " << endl;
         cout << "start: " << startDistance << endl;
--- a/UI code/6Dbox.h	Wed Nov 26 18:18:20 2014 +0000
+++ b/UI code/6Dbox.h	Tue Dec 02 13:25:48 2014 +0000
@@ -88,7 +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, bool showResultColor = false);
     void setHandTexture(ofImage* img);
-    
+
     void setValue(int index, int value);
     void setValueAndScale(int index, int value);
     
--- a/UI code/6Dbox.mm	Wed Nov 26 18:18:20 2014 +0000
+++ b/UI code/6Dbox.mm	Tue Dec 02 13:25:48 2014 +0000
@@ -39,24 +39,23 @@
     
     string fname = ofFilePath::getAbsolutePath(ofToDataPath("buttron.png"));
     defaultImage.loadImage(fname);
-    
-    fname = ofFilePath::getAbsolutePath(ofToDataPath("white.jpeg"));
-    hintImage.loadImage(fname);
 
     fname = ofFilePath::getAbsolutePath(ofToDataPath("wallGrid.jpg"));
     wallGrid.loadImage(fname);
     
     fname = ofFilePath::getAbsolutePath(ofToDataPath("neurons.jpg"));
     animImage.loadImage(fname);
-    
-    setHandTexture(&defaultImage);
-    setHintTexture(&hintImage);
+
     setUpHandMesh();
     
     showHint(true);
     
     myType = LEAP6D;
     showScoreForFrames = 0;
+    
+    
+    setHandTexture(&defaultImage);
+    setHintTexture(&hintImage);
 }
 
 void Leap6DBox::setHintValues(vector<int> vals){
@@ -325,7 +324,8 @@
 
 
 void Leap6DBox::drawIndicatorBlob(float x, float y, float z, ofColor c, bool isHint){
-    ofImage * atexImg;
+    handTextureRef = &defaultImage;
+
     if (isHint){
         draw6DOFIndicatorBlob(x, y, z, c, hintRoll, hintPitch, 	hintYaw, hintImageRef);
 
--- a/UI code/sliderPanel.mm	Wed Nov 26 18:18:20 2014 +0000
+++ b/UI code/sliderPanel.mm	Tue Dec 02 13:25:48 2014 +0000
@@ -270,7 +270,7 @@
         if (subElements[0]->getType() == LEAP6D){
             Leap6DBox * box = (Leap6DBox*)subElements[0];
             
-            box->setTexture(texture);
+            box->setHandTexture(texture);
         }
         
     }
--- a/testApp.mm	Wed Nov 26 18:18:20 2014 +0000
+++ b/testApp.mm	Tue Dec 02 13:25:48 2014 +0000
@@ -142,6 +142,8 @@
     bottomButtonPanel->addButton(playCandidateButton);
     bottomButtonPanel->hide();
     
+    
+    
     trainingMessageOrganiser.setBottomPanel(bottomButtonPanel);
     UIElements.push_back(bottomButtonPanel);
     bottomButtonPanel->hide();
@@ -277,7 +279,7 @@
     searchMessageOrganiser.setSeqNumPanel(seqNumPanel);
     seqNumPanel->setFontSize(LARGEFONT);
     UIElements.push_back(seqNumPanel);
-    seqNumPanel->hide();
+    seqNumPanel->show();
     
     TextPanel* scoreNumPanel = new TextPanel("SCORE: ",700, 60, 150, 150, *props);
     trainingMessageOrganiser.setScoreNumPanel(scoreNumPanel);