changeset 35:3b10a26da293

refactoring and log
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Wed, 26 Nov 2014 18:18:20 +0000
parents 3af380769779
children 146033869165
files MessageOrganiser.mm SequenceController.h SequenceController.mm TrainingMessageOrganiser.h TrainingMessageOrganiser.mm TrainingScoreManager.h UI code/6Dbox.h UI code/6Dbox.mm
diffstat 8 files changed, 337 insertions(+), 312 deletions(-) [+]
line wrap: on
line diff
--- a/MessageOrganiser.mm	Wed Nov 26 14:04:05 2014 +0000
+++ b/MessageOrganiser.mm	Wed Nov 26 18:18:20 2014 +0000
@@ -276,8 +276,8 @@
 
 void MessageOrganiser::midiFromLeap(int ctl_num, int ctl_val){
     static long int howManyLogged;
-    static vector<int> lastLoggedVals = zeros<int>(6);
-    static vector<int> newVals = zeros<int>(6);
+    static vector<int> lastLoggedVals = zeros<int>(TOTAL_NUM_PARAMS);
+    static vector<int> newVals = zeros<int>(TOTAL_NUM_PARAMS);
     static long long lastLogTime;
     
     if (!okToGetMidi){
@@ -306,7 +306,7 @@
         lastLoggedVals = newVals;
         howManyLogged++;
     }else{
-        cout << "skipped! so far logged " << howManyLogged << endl;
+        //cout << "skipped! so far logged " << howManyLogged << endl;
     }
 
     
--- a/SequenceController.h	Wed Nov 26 14:04:05 2014 +0000
+++ b/SequenceController.h	Wed Nov 26 18:18:20 2014 +0000
@@ -15,9 +15,9 @@
 #include "TrainingScoreManager.h"
 #define MIN_TARGETS_IN_SEQUENCE 1
 #define MAX_TARGETS_IN_SEQUENCE 7
-#define MIN_TEMPO   80
-#define MAX_TEMPO   400
-#define NUM_TEMPO_STEPS 12
+#define MIN_TEMPO   60
+#define MAX_TEMPO   500
+#define NUM_TEMPO_STEPS 15
 #define NUM_PRESETS 8
 #define SPACER_BARS false
 #define NO_GUIDES_LEVEL false
@@ -30,11 +30,11 @@
     typedef enum {PREVIEW_NEUTRAL_COUNT,
                 MATCHING_NEUTRAL_COUNT,
                 PREVIEW_MOVE,
-                PREVIEW_HIT,
+                PREVIEW_LAST,
                 GUIDED_MOVE,
                 GUIDED_HIT,
                 MATCHING_MOVE,
-                MATCHING_HIT}
+                MATCHING_LAST}
                 stepType;
     
     stepType type;
@@ -51,6 +51,7 @@
     int tempo;
     int seqNumber;
     int runNumber;
+    int difficulty;
     bool isLastOfSeq;
     bool isLastOfRun;
     
--- a/SequenceController.mm	Wed Nov 26 14:04:05 2014 +0000
+++ b/SequenceController.mm	Wed Nov 26 18:18:20 2014 +0000
@@ -23,6 +23,7 @@
     showsGuides = false;
     showsIcons = true;
     showsResultsAtEnd = false;
+    difficulty = 0;
 }
 
 void AnimStep::saveResult(TrainingTestResult aresult){
@@ -271,6 +272,7 @@
         nextStep.whichInSequence = 0;
         nextStep.tempo = curTempo;
         nextStep.showsGuides = true;
+        nextStep.difficulty = 0;
         nextStep.type = AnimStep::PREVIEW_NEUTRAL_COUNT;
         nextStep.showsResultsAtEnd = false;
         steps.push_back(nextStep);
@@ -280,7 +282,7 @@
         nextStep.thisSequence = stepPresetIndices;
         
         // MAKE PREVIEW
-        int n = 0;
+        int n = 1;
         for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
             // put loader
             
@@ -294,25 +296,23 @@
             nextStep.showsResultsAtEnd = false;
             nextStep.type = AnimStep::PREVIEW_MOVE;
             steps.push_back(nextStep);
-            
-            if (SPACER_BARS){
-                nextStep.type = AnimStep::PREVIEW_HIT;
-                steps.push_back(nextStep);
-            }
+
             n++;
         }
         
         // move back to neutral
         nextStep.presetIndex = -1;
-        nextStep.type = AnimStep::PREVIEW_MOVE;
+        nextStep.type = AnimStep::PREVIEW_LAST;
+        nextStep.whichInSequence = 0;
+        nextStep.difficulty = 0;
         nextStep.showsResultsAtEnd = false;
         steps.push_back(nextStep);
         
         // make GUIDED sequence (1)
-        n = 0;
+        n = 1;
         for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
             // put loader
-            
+            nextStep.difficulty = 1;
             nextStep.presetIndex = *si;
             nextStep.runNumber = run;
             nextStep.seqNumber = seqNo;
@@ -321,26 +321,28 @@
             nextStep.showsGuides = true;
             nextStep.showsIcons = true;
             nextStep.showsResultsAtEnd = true;
-            nextStep.type = AnimStep::GUIDED_MOVE;
+            nextStep.type = AnimStep::MATCHING_MOVE;
             steps.push_back(nextStep);
             
             if (SPACER_BARS){
-                nextStep.type = AnimStep::GUIDED_HIT;
+                nextStep.type = AnimStep::MATCHING_LAST;
                 steps.push_back(nextStep);
             }
             n++;
         }
         // move back to neutral
         nextStep.presetIndex = -1;
-        nextStep.type = AnimStep::GUIDED_MOVE;
+        nextStep.type = AnimStep::MATCHING_LAST;
+        nextStep.whichInSequence = 0;
+        nextStep.difficulty = 0;
         nextStep.showsResultsAtEnd = false;
         steps.push_back(nextStep);
         
         // make GUIDED sequence (2)
-        n = 0;
+        n = 1;
         for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
             // put loader
-            
+            nextStep.difficulty = 1;
             nextStep.presetIndex = *si;
             nextStep.runNumber = run;
             nextStep.seqNumber = seqNo;
@@ -349,26 +351,28 @@
             nextStep.showsGuides = true;
             nextStep.showsIcons = true;
             nextStep.showsResultsAtEnd = true;
-            nextStep.type = AnimStep::GUIDED_MOVE;
+            nextStep.type = AnimStep::MATCHING_MOVE;
             steps.push_back(nextStep);
             
             if (SPACER_BARS){
-                nextStep.type = AnimStep::GUIDED_HIT;
+                nextStep.type = AnimStep::MATCHING_LAST;
                 steps.push_back(nextStep);
             }
             n++;
         }
         // move back to neutral
         nextStep.presetIndex = -1;
-        nextStep.type = AnimStep::GUIDED_MOVE;
+        nextStep.type = AnimStep::MATCHING_LAST;
+        nextStep.whichInSequence = 0;
+        nextStep.difficulty = 0;
         nextStep.showsResultsAtEnd = false;
         steps.push_back(nextStep);
         
         // make matching sequence with icon seq help
-        n = 0;
+        n = 1;
         for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
             // put loader
-            
+            nextStep.difficulty = 2;
             nextStep.presetIndex = *si;
             nextStep.whichInSequence = n;
             
@@ -379,7 +383,7 @@
             steps.push_back(nextStep);
             
             if (SPACER_BARS){
-                nextStep.type = AnimStep::MATCHING_HIT;
+                nextStep.type = AnimStep::MATCHING_LAST;
                 steps.push_back(nextStep);
                 
             }
@@ -387,7 +391,9 @@
             
         }
         
-        nextStep.type = AnimStep::MATCHING_HIT;
+        nextStep.type = AnimStep::MATCHING_LAST;
+        nextStep.whichInSequence = 0;
+        nextStep.difficulty = 0;
         nextStep.showsResultsAtEnd = false;
         steps.push_back(nextStep);
         
@@ -415,6 +421,7 @@
         nextStep.runNumber = run;
         nextStep.seqNumber = seqNo;
         nextStep.whichInSequence = 0;
+        nextStep.difficulty = 0;
         nextStep.tempo = curTempo;
         nextStep.showsGuides = true; // guide shown for neutral point
         nextStep.type = AnimStep::PREVIEW_NEUTRAL_COUNT;
@@ -426,7 +433,7 @@
         nextStep.thisSequence = stepPresetIndices;
         
         // make preview sequence
-        int n = 0;
+        int n = 1;
         for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
             // put loader
             
@@ -442,7 +449,7 @@
             steps.push_back(nextStep);
             
             if (SPACER_BARS){
-                nextStep.type = AnimStep::PREVIEW_HIT;
+                nextStep.type = AnimStep::PREVIEW_LAST;
                 steps.push_back(nextStep);
             }
             n++;
@@ -450,15 +457,17 @@
         
         // move back to neutral
         nextStep.presetIndex = -1;
-        nextStep.type = AnimStep::PREVIEW_MOVE;
+        nextStep.type = AnimStep::PREVIEW_LAST;
+        nextStep.whichInSequence = 0;
+        nextStep.difficulty = 0;
         nextStep.showsResultsAtEnd = false;
         steps.push_back(nextStep);
         
         // make matching sequence WITHOUT icon seq help
-        n = 0;
+        n = 1;
         for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
             // put loader
-            
+            nextStep.difficulty = 3;
             nextStep.presetIndex = *si;
             nextStep.whichInSequence = n;
             
@@ -473,7 +482,9 @@
             
         }
         
-        nextStep.type = AnimStep::MATCHING_HIT;
+        nextStep.type = AnimStep::MATCHING_LAST;
+        nextStep.whichInSequence = 0;
+        nextStep.difficulty = 0;
         nextStep.showsResultsAtEnd = false;
         steps.push_back(nextStep);
         
@@ -511,7 +522,7 @@
         nextStep.thisSequence = stepPresetIndices;
 
         // make preview sequence
-        int n = 0;
+        int n = 1;
         for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
             // put loader
             
@@ -527,7 +538,7 @@
             steps.push_back(nextStep);
             
             if (SPACER_BARS){
-                nextStep.type = AnimStep::PREVIEW_HIT;
+                nextStep.type = AnimStep::PREVIEW_LAST;
                 steps.push_back(nextStep);
             }
             n++;
@@ -536,14 +547,16 @@
         // move back to neutral
         nextStep.presetIndex = -1;
         nextStep.type = AnimStep::PREVIEW_MOVE;
-        nextStep.showsResultsAtEnd = false;
+        nextStep.difficulty = 0;
+        nextStep.whichInSequence = 0;
+        nextStep.showsResultsAtEnd = true;
         steps.push_back(nextStep);
         
         // make GUIDED sequence
-        n = 0;
+        n = 1;
         for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
             // put loader
-            
+            nextStep.difficulty = 1;
             nextStep.presetIndex = *si;
             nextStep.runNumber = run;
             nextStep.seqNumber = seqNo;
@@ -552,26 +565,26 @@
             nextStep.showsGuides = true;
             nextStep.showsIcons = true;
             nextStep.showsResultsAtEnd = true;
-            nextStep.type = AnimStep::GUIDED_MOVE;
+            nextStep.type = AnimStep::MATCHING_MOVE;
             steps.push_back(nextStep);
 
             if (SPACER_BARS){
-                nextStep.type = AnimStep::GUIDED_HIT;
+                nextStep.type = AnimStep::MATCHING_LAST;
                 steps.push_back(nextStep);
             }
             n++;
         }
         // move back to neutral
         nextStep.presetIndex = -1;
-        nextStep.type = AnimStep::GUIDED_MOVE;
+        nextStep.type = AnimStep::MATCHING_LAST;
         nextStep.showsResultsAtEnd = false;
         steps.push_back(nextStep);
         
         // make matching sequence with icon seq help
-        n = 0;
+        n = 1;
         for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
             // put loader
-            
+            nextStep.difficulty = 2;
             nextStep.presetIndex = *si;
             nextStep.whichInSequence = n;
 
@@ -582,7 +595,7 @@
             steps.push_back(nextStep);
             
             if (SPACER_BARS){
-                nextStep.type = AnimStep::MATCHING_HIT;
+                nextStep.type = AnimStep::MATCHING_LAST;
                 steps.push_back(nextStep);
             
             }
@@ -592,27 +605,28 @@
         
         // move back to neutral
         nextStep.presetIndex = -1;
-        nextStep.type = AnimStep::GUIDED_MOVE;
+        nextStep.type = AnimStep::MATCHING_LAST;
         nextStep.showsResultsAtEnd = false;
         steps.push_back(nextStep);
         
         // make matching sequence WITHOUT icon seq help
-        n = 0;
+        n = 1;
         for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
             // put loader
-            
+            nextStep.difficulty = 3;
             nextStep.presetIndex = *si;
             nextStep.whichInSequence = n;
             
             nextStep.showsGuides = false;
+            nextStep.showsIcons = false;
             
             nextStep.type = AnimStep::MATCHING_MOVE;
             nextStep.showsResultsAtEnd = true;
-            nextStep.showsIcons = false;
+            
             steps.push_back(nextStep);
             
             if (SPACER_BARS){
-                nextStep.type = AnimStep::MATCHING_HIT;
+                nextStep.type = AnimStep::MATCHING_LAST;
                 steps.push_back(nextStep);
                 
             }
@@ -620,7 +634,8 @@
             
         }
         
-        nextStep.type = AnimStep::MATCHING_HIT;
+        nextStep.type = AnimStep::MATCHING_LAST;
+        nextStep.presetIndex = -1;
         nextStep.showsResultsAtEnd = false;
         steps.push_back(nextStep);
         
--- a/TrainingMessageOrganiser.h	Wed Nov 26 14:04:05 2014 +0000
+++ b/TrainingMessageOrganiser.h	Wed Nov 26 18:18:20 2014 +0000
@@ -59,17 +59,19 @@
                                  vector<int> startingPosition,
                                  vector<int> currentPosition	);
     
-    void previewNeutralCount(AnimStep newStep);
-    void previewMove(AnimStep newStep);
-    void previewHit(AnimStep newStep);
-    void matchingNeutralCount(AnimStep newStep);
-    void matchingMove(AnimStep newStep);
-    void matchingHit(AnimStep newStep);
-    void guidedMove(AnimStep newStep);
-    void guidedHit(AnimStep newStep);
+    void previewNeutralCount(AnimStep newStep, Preset * currentTargetPreset);
+    void previewMove(AnimStep newStep, Preset * currentTargetPreset);
+    void previewLast(AnimStep newStep, Preset * currentTargetPreset);
+    //void matchingNeutralCount(AnimStep newStep);
+    void matchingMove(AnimStep newStep, Preset * currentTargetPreset);
+    void matchingLast(AnimStep newStep, Preset * currentTargetPreset);
+    //void guidedMove(AnimStep newStep);
+    //void guidedHit(AnimStep newStep);
     
     void flashResult(TrainingTestResult r);
-    
+    void doGuides(bool showGuides, Preset * currentTargetPreset);
+    void doIcons(bool showIcons, Preset * currentTargetPreset);
+    void doHand(bool showControllableHand, bool showAnimatedHand = false, float animTime = 0, vector<int> newTargetValues = vector<int>());
     ofColor interactableColor;
     ofColor nonInteractableColor;
     int downCounter;
--- a/TrainingMessageOrganiser.mm	Wed Nov 26 14:04:05 2014 +0000
+++ b/TrainingMessageOrganiser.mm	Wed Nov 26 18:18:20 2014 +0000
@@ -127,6 +127,7 @@
     middlePanel->setText("FINISHED BLOCK!");
     middlePanel->show();
     bottomPanel->show();
+    seqNumPanel->hide();
     eventLogger.saveSessionToFile();
 }
 
@@ -148,14 +149,14 @@
 //-----------------------------------------------------------------------------
 void TrainingMessageOrganiser::onNextTickAnim(int tickNumber){
     static AnimStep oldStep;
-    static vector<int> lastPosition;
+    static vector<int> lastPosition = zeros<int>(TOTAL_NUM_PARAMS);
     
-    cout << "TICK " << tickNumber << endl;
+    //cout << "TICK " << tickNumber << endl;
     downCounter = 4 - tickNumber % 4;
     
     updateCountdown(downCounter);
     // only first beat in bar is active one (at the moment)
-    // TODO send next target values again and again
+    //  send next target values 1 step before them play
     if ( tickNumber % 4  != 0) {
         if (tickNumber % 4  == 3){
             targetSynth.sendAllParams();
@@ -176,7 +177,6 @@
             
             previousTargetPreset =  expPresetManager.getPresetAtIndex(oldStep.presetIndex);
         }
-        previousTargetPreset =  expPresetManager.getPresetAtIndex(oldStep.presetIndex);
         
         eventLogger.logEvent(FINISH_POS, curCandidateSettings);
         TrainingTestResult result =  doResults(oldStep,
@@ -201,32 +201,44 @@
     }
     
     candidateSynth.setMetroTime(newStep.getTimeBetweenTicks());
+    Preset * currentTargetPreset;
+    if(newStep.presetIndex == -1){
+        currentTargetPreset =  expPresetManager.getNeutralPreset();
+    }else{
+        
+        currentTargetPreset =  expPresetManager.getPresetAtIndex(newStep.presetIndex);
+        if (currentTargetPreset == NULL){
+            displayInstructions("No stored preset!\n please restart and choose EXP");
+            candidateSynth.stopMetronome();
+            return;
+        }
+    }
     
     switch (newStep.type){
         case AnimStep::PREVIEW_NEUTRAL_COUNT :
-            previewNeutralCount(newStep);
+            previewNeutralCount(newStep,currentTargetPreset);
             break;
         case AnimStep::PREVIEW_MOVE :
-            previewMove(newStep);
+            previewMove(newStep,currentTargetPreset);
             break;
-        case AnimStep::PREVIEW_HIT :
-            previewHit( newStep);
+        case AnimStep::PREVIEW_LAST :
+            previewLast( newStep,currentTargetPreset);
             break;
         case AnimStep::MATCHING_NEUTRAL_COUNT :
-            matchingNeutralCount( newStep);
+            //matchingNeutralCount( newStep,currentTargetPreset);
             break;
         case AnimStep::MATCHING_MOVE :
-            matchingMove( newStep);
+            matchingMove( newStep,currentTargetPreset);
             break;
-        case AnimStep::MATCHING_HIT :
-            matchingHit( newStep);
+        case AnimStep::MATCHING_LAST :
+            matchingLast( newStep,currentTargetPreset);
             break;
         case AnimStep::GUIDED_MOVE :
-            guidedMove( newStep);
+            //guidedMove( newStep);
             break;
             
         case AnimStep::GUIDED_HIT :
-            guidedHit( newStep);
+            //guidedHit( newStep);
             break;
         default:
             break;
@@ -241,12 +253,10 @@
     
 }
 //-----------------------------------------------------------------------------
-void TrainingMessageOrganiser::previewNeutralCount(AnimStep newStep){
+void TrainingMessageOrganiser::previewNeutralCount(AnimStep newStep, Preset * currentTargetPreset){
     okToGetMidi = false;
 
     middlePanel->hide();
-    
-    Preset * currentTargetPreset;
 
     // your 'hand' is hidden
     controlPanel->showValueIndicators(false);
@@ -255,9 +265,10 @@
     // guide is set to neutral values
     currentTargetPreset = expPresetManager.getNeutralPreset();
     vector<int> newTargetValues = currentTargetPreset->getValues();
+    controlPanel->setValues(newTargetValues);
     presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), false);
     presetIconPanel->show();
-    controlPanel->setValues(newTargetValues);
+
     controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage());
     controlPanel->setActive(false);
     
@@ -269,254 +280,183 @@
     oldTargetValues = newTargetValues;
 }
 //-----------------------------------------------------------------------------
-void TrainingMessageOrganiser::previewMove(AnimStep newStep){
-    //controlPanel->setValues(oldTargetValues);
-    okToGetMidi = false;
-    targetSynth.trigger(); // PLAYS LAST TARGET (but it doesn't?)
-    Preset * currentTargetPreset;
-    if(newStep.presetIndex == -1){
-        currentTargetPreset =  expPresetManager.getNeutralPreset();
-    }else{
-        
-        currentTargetPreset =  expPresetManager.getPresetAtIndex(newStep.presetIndex);
-        if (currentTargetPreset == NULL){
-            displayInstructions("No stored preset!\n please restart and choose EXP");
-            candidateSynth.stopMetronome();
-            return;
-        }
-    }
+void TrainingMessageOrganiser::previewMove(AnimStep newStep, Preset * currentTargetPreset){
+
+    targetSynth.trigger(); // PLAYS LAST TARGET
+
+
     vector<int> newTargetValues = currentTargetPreset->getValues();
 
     targetSynth.setAllParamsWithoutSend(newTargetValues);
     
-    // show icon and guides
-    if (newStep.showsGuides){ // always show neutral one
-        
-        // show where we're going
-        controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage());
-        
-        // show how to get there
-        controlPanel->animateToNewValues(newTargetValues, newStep.getTimeBetweenTicks()*4);
-        controlPanel->showValueIndicators(true); // for animation
-        controlPanel->setActive(false);
-    }else{
-        // We're in PERFORM mode
-        if (newStep.presetIndex == -1){
-            // last step of preview , can show neutral to give idea of when things happen
-            // also allow interaction so that neutral can be prepared
-            controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage());
-            // TODO set value to neutral too
-            controlPanel->showValueIndicators(true);
-            okToGetMidi = true;
-            controlPanel->setActive(true);
-        }else{
-            // empty box
-            controlPanel->showHint(false);
-            controlPanel->showValueIndicators(false);
-            controlPanel->setActive(false);
-        }
-    }
+    doGuides(newStep.showsGuides, currentTargetPreset);
+
+    doHand(false, newStep.showsGuides, newStep.getTimeBetweenTicks()*4, newTargetValues);
     
-    if (newStep.showsIcons){
-        presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), false);
-        presetIconPanel->show();
-    }else{
-        presetIconPanel->hide();
-    }
+    doIcons(newStep.showsIcons, currentTargetPreset);
+
+
     controlPanel->show();
-    
-    
-    
 
-    stringstream instruct;
-    instruct << "PREVIEW" << endl;;
-    instruct << newStep.whichInSequence+1 << endl;
-    displayInstructions(instruct.str());
-    showSeqNum(newStep.whichInSequence+1);
+    displayInstructions("PREVIEW");
+    showSeqNum(newStep.whichInSequence);
     oldTargetValues = newTargetValues;
 }
+
+
 //-----------------------------------------------------------------------------
 // lest setep of preview seq - plays moves back to neutral pos?
-void TrainingMessageOrganiser::previewHit(AnimStep newStep){
-    Preset * currentTargetPreset;
-    okToGetMidi = false;
-    currentTargetPreset =  expPresetManager.getPresetAtIndex(newStep.presetIndex);
-    vector<int> newTargetValues = currentTargetPreset->getValues();
+void TrainingMessageOrganiser::previewLast(AnimStep newStep, Preset * currentTargetPreset){
+    targetSynth.trigger();
+
+    // wrong?
+    targetSynth.setAllParamsWithoutSend(currentTargetPreset->getValues());
     
-    targetSynth.setAllParams(newTargetValues);
+    // your hand shows, we dont bother animating back to neutral!?
+    doHand(true);
+
+    doIcons(newStep.showsIcons,currentTargetPreset);
     
-    // your hand shows!?
-    controlPanel->showValueIndicators(true);
-    okToGetMidi = true;
-    //
-    presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), false);
-    presetIconPanel->show();
-    
-    controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage());
+    doGuides(newStep.showsGuides, currentTargetPreset);
 
-    
-    targetSynth.trigger();
-    
-    displayInstructions("Preview HIT");
+    showSeqNum(newStep.whichInSequence);
+    displayInstructions("Preview FINISHED");
 }
 
 //-----------------------------------------------------------------------------
-void TrainingMessageOrganiser::guidedMove(AnimStep newStep){
-    targetSynth.trigger(); // plays LAST target (?)
-    triggerCandidateSound();
-    middlePanel->hide();
-    
-    Preset * currentTargetPreset;
-    if(newStep.presetIndex == -1){
-        currentTargetPreset =  expPresetManager.getNeutralPreset();
-    }else{
-        
-        currentTargetPreset =  expPresetManager.getPresetAtIndex(newStep.presetIndex);
-    }
-
-    vector<int> newTargetValues = currentTargetPreset->getValues();
-  
-    targetSynth.setAllParamsWithoutSend(newTargetValues);
-    
-    
-    controlPanel->setActive(true);
-    // show icon and guide markers
-    presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), false);
-    presetIconPanel->show();
-    
-    controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage());
-    
-    
-    // show your hand and allow movement
-    controlPanel->showValueIndicators(true);
-    okToGetMidi = true;
-    
-    stringstream instruct;
-    instruct << "GUIDED MOVE" << endl;;
-    instruct << newStep.whichInSequence+1 << endl;
-    displayInstructions(instruct.str());
-    
-    showSeqNum(newStep.whichInSequence+1);
-
-    oldTargetValues = newTargetValues;
-}
-
-//======================================================================
-void TrainingMessageOrganiser::guidedHit(AnimStep newStep){
-    Preset * currentTargetPreset;
-    currentTargetPreset =  expPresetManager.getPresetAtIndex(newStep.presetIndex);
-    vector<int> newTargetValues = currentTargetPreset->getValues();
-    eventLogger.logEvent(NEW_TARGET, newTargetValues);
-    sendSynthValuesAgain();
-    
-    // show your hand and allow movement (so you can set off to next target??)
-    
-    controlPanel->showValueIndicators(true);
-    okToGetMidi = true;
-    
-    targetSynth.setAllParamsWithoutSend(newTargetValues);
-    triggerCandidateSound();
-    targetSynth.trigger();
-    displayInstructions("GUIDED HIT");
-    vector<int> startPosition = expPresetManager.getNeutralPreset()->getValues();
-    
-    oldTargetValues = newTargetValues;
-}
+//void TrainingMessageOrganiser::guidedMove(AnimStep newStep){
+//    targetSynth.trigger(); // plays LAST target (?)
+//    triggerCandidateSound();
+//    middlePanel->hide();
+//    
+//    Preset * currentTargetPreset;
+//    if(newStep.presetIndex == -1){
+//        currentTargetPreset =  expPresetManager.getNeutralPreset();
+//    }else{
+//        
+//        currentTargetPreset =  expPresetManager.getPresetAtIndex(newStep.presetIndex);
+//    }
+//
+//    vector<int> newTargetValues = currentTargetPreset->getValues();
+//  
+//    targetSynth.setAllParamsWithoutSend(newTargetValues);
+//    
+//    
+//    controlPanel->setActive(true);
+//    // show icon and guide markers
+//    presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), false);
+//    presetIconPanel->show();
+//    
+//    controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage());
+//    
+//    
+//    // show your hand and allow movement
+//    controlPanel->showValueIndicators(true);
+//    okToGetMidi = true;
+//    
+//    stringstream instruct;
+//    instruct << "GUIDED MOVE" << endl;;
+//    instruct << newStep.whichInSequence+1 << endl;
+//    displayInstructions(instruct.str());
+//    
+//    showSeqNum(newStep.whichInSequence+1);
+//
+//    oldTargetValues = newTargetValues;
+//}
+//
+////======================================================================
+//void TrainingMessageOrganiser::guidedHit(AnimStep newStep){
+//    Preset * currentTargetPreset;
+//    currentTargetPreset =  expPresetManager.getPresetAtIndex(newStep.presetIndex);
+//    vector<int> newTargetValues = currentTargetPreset->getValues();
+//    eventLogger.logEvent(NEW_TARGET, newTargetValues);
+//    sendSynthValuesAgain();
+//    
+//    // show your hand and allow movement (so you can set off to next target??)
+//    
+//    controlPanel->showValueIndicators(true);
+//    okToGetMidi = true;
+//    
+//    targetSynth.setAllParamsWithoutSend(newTargetValues);
+//    triggerCandidateSound();
+//    targetSynth.trigger();
+//    displayInstructions("GUIDED HIT");
+//    vector<int> startPosition = expPresetManager.getNeutralPreset()->getValues();
+//    
+//    oldTargetValues = newTargetValues;
+//}
 //-----------------------------------------------------------------------------
 
 //-----------------------------------------------------------------------------
-void TrainingMessageOrganiser::matchingNeutralCount(AnimStep newStep){
-    Preset * currentTargetPreset = expPresetManager.getNeutralPreset();
-    vector<int> newTargetValues = currentTargetPreset->getValues();
-    // if showing guides show all the targets as transparent ghosts
-    if (newStep.showsGuides){
-        controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage());
-
-    }else{
-        controlPanel->showHint(false);
-    }
-    
-    // show your hand and allow movement
-    controlPanel->showValueIndicators(true);
-    okToGetMidi = true;
-    
-        displayInstructions("Match Count");
-    seqNumPanel->hide();
-    oldTargetValues = newTargetValues;
-}
+//void TrainingMessageOrganiser::matchingNeutralCount(AnimStep newStep, Preset * currentTargetPreset){
+//    Preset * currentTargetPreset = expPresetManager.getNeutralPreset();
+//    vector<int> newTargetValues = currentTargetPreset->getValues();
+//    // if showing guides show all the targets as transparent ghosts
+//    if (newStep.showsGuides){
+//        controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage());
+//
+//    }else{
+//        controlPanel->showHint(false);
+//    }
+//    
+//    // show your hand and allow movement
+//    controlPanel->showValueIndicators(true);
+//    okToGetMidi = true;
+//    
+//        displayInstructions("Match Count");
+//    seqNumPanel->hide();
+//    oldTargetValues = newTargetValues;
+//}
 //-----------------------------------------------------------------------------
-void TrainingMessageOrganiser::matchingMove(AnimStep newStep){
+void TrainingMessageOrganiser::matchingMove(AnimStep newStep, Preset * currentTargetPreset){
 
     
     middlePanel->hide();
-    
-    Preset * currentTargetPreset;
-    if(newStep.presetIndex == -1){
-        currentTargetPreset =  expPresetManager.getNeutralPreset();
-    }else{
-        
-        currentTargetPreset =  expPresetManager.getPresetAtIndex(newStep.presetIndex);
-    }
 
     vector<int> newTargetValues = currentTargetPreset->getValues();
     eventLogger.logEvent(NEW_TARGET, newTargetValues);
-    targetSynth.setAllParams(newTargetValues);
+    targetSynth.setAllParamsWithoutSend(newTargetValues);
 
     // if showing guides show the hint hand
+    doGuides(newStep.showsGuides, currentTargetPreset);
     
-    if (newStep.showsGuides){
-        controlPanel->setHintNoShow(newTargetValues, currentTargetPreset->getImage());
-        controlPanel->showHint(true);
-    }else{
-        //
-        controlPanel->showHint(false);
-    }
-    if (newStep.showsIcons){
-        presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), false);
-        presetIconPanel->show();
-    }else{
-        presetIconPanel->hide();
-    }
-    // show your hand and allow movement
-    controlPanel->showValueIndicators(true);
-    okToGetMidi = true;
+    doIcons(newStep.showsIcons, currentTargetPreset);
     
-    stringstream instruct;
-    instruct << "MATCHING" << endl;;
-    instruct << newStep.whichInSequence+1 << endl;
-    displayInstructions(instruct.str());
-    showSeqNum(newStep.whichInSequence+1);
+    doHand(true);
+
+    
+    displayInstructions("MATCH IT");
+    showSeqNum(newStep.whichInSequence);
     // trigger where we're at at the moment
     triggerCandidateSound();
 
+
     oldTargetValues = newTargetValues;
 
 }
 //-----------------------------------------------------------------------------
-void TrainingMessageOrganiser::matchingHit(AnimStep newStep){
-    Preset * currentTargetPreset;
-    currentTargetPreset =  expPresetManager.getPresetAtIndex(newStep.presetIndex);
+void TrainingMessageOrganiser::matchingLast(AnimStep newStep, Preset * currentTargetPreset){
+    // why is this different from match it?
+    
     vector<int> newTargetValues = currentTargetPreset->getValues();
     eventLogger.logEvent(NEW_TARGET, newTargetValues);
-    sendSynthValuesAgain();
+    targetSynth.setAllParamsWithoutSend(newTargetValues);
     
-    // show your hand and allow movement (so you can set off to next target??)
-    //box6D->showIndicator(true);
-    stringstream instruct;
-    instruct << "MATCHING FINISHED" << endl;;
-    instruct << newStep.whichInSequence+1 << endl;
-    displayInstructions(instruct.str());
-    showSeqNum(newStep.whichInSequence+1);
+    doGuides(newStep.showsGuides, currentTargetPreset);
     
-    vector<int> startPosition = expPresetManager.getNeutralPreset()->getValues();
-    controlPanel->setHintNoShow(newTargetValues, currentTargetPreset->getImage());
+    doIcons(newStep.showsIcons, currentTargetPreset);
     
+    doHand(true);
+    
+    displayInstructions("MATCHING FINISHED");
+    showSeqNum(newStep.whichInSequence);
+
     triggerCandidateSound();
     oldTargetValues = newTargetValues;
 }
 //-----------------------------------------------------------------------------
 
-TrainingTestResult TrainingMessageOrganiser::doResults(AnimStep newStep,
+TrainingTestResult TrainingMessageOrganiser::doResults(AnimStep step,
                                                        Preset * targetPreset,
                                                        vector<int> startingPosition,
                                                        vector<int> currentPosition){
@@ -526,7 +466,8 @@
     trainingScoreManager.getScoreForAnswer(targetPreset->getValues(),
                                            startingPosition,
                                            currentPosition,
-                                           newStep.getTimeBetweenTicks());
+                                           step.getTimeBetweenTicks(),
+                                           step.difficulty, step.whichInSequence, step.presetIndex);
     
     sequenceController.saveResultForCurrentStep(result);
     instructionPanel->setColor(result.colorBand);
@@ -546,3 +487,50 @@
 
     
 }
+
+
+//------------------------------------------------------------------------------------
+void TrainingMessageOrganiser::doIcons(bool showIcons, Preset * currentTargetPreset){
+    
+    if (showIcons){
+        presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), false);
+        presetIconPanel->show();
+    }else{
+        presetIconPanel->hide();
+    }
+}
+//------------------------------------------------------------------------------------
+void TrainingMessageOrganiser::doGuides(bool showGuides, Preset * currentTargetPreset){
+    
+    // show icon and guides
+    if (showGuides){ // always show neutral one
+        
+        // show where we're going
+        controlPanel->setAndShowHint(currentTargetPreset->getValues(), currentTargetPreset->getImage());
+        
+        
+    }else{
+        controlPanel->showHint(false);
+    }
+    
+}
+//-----------------------------------------------------------------------------
+void TrainingMessageOrganiser::doHand(bool showControllableHand, bool showAnimatedHand, float animTime, vector<int> newTargetValues)
+{
+    // show how to get there
+    if (showAnimatedHand){
+        controlPanel->animateToNewValues(newTargetValues, animTime);
+        controlPanel->showValueIndicators(true); // for animation
+        controlPanel->setActive(false);
+        
+    }else if(showControllableHand){
+        controlPanel->showValueIndicators(true); // for animation
+        controlPanel->setActive(true); // allow user control
+        okToGetMidi = true; // allow midi input to thing
+        
+    }else{
+        controlPanel->showValueIndicators(false); // hand/ slider bars invisible
+        controlPanel->setActive(false); // cant control it
+    }
+    
+}
--- a/TrainingScoreManager.h	Wed Nov 26 14:04:05 2014 +0000
+++ b/TrainingScoreManager.h	Wed Nov 26 18:18:20 2014 +0000
@@ -11,7 +11,6 @@
 
 #include <iostream>
 #include "ofMain.h"
-//#include "SequenceController.h"
 #include "algorithms.h"
 #include "globalVariables.h"
 #include "eventLogger.h"
@@ -27,15 +26,24 @@
     ofColor colorBand;
     string displayText;
     float bits;
+    int difficultyLevel;
 };
 
 class TrainingScoreManager{
     
     // equiv of score bit of testController
 public:
+    TrainingScoreManager(){
+        totalScored = 0;
+    }
     
-    
-    TrainingTestResult getScoreForAnswer(vector<int> targetParams, vector<int> startPosition, vector<int> answer, int timeAllowed) {
+    TrainingTestResult getScoreForAnswer(vector<int> targetParams,
+                                         vector<int> startPosition,
+                                         vector<int> answer,
+                                         int timeAllowed,
+                                         int difficulty,
+                                         int whichInSequence,
+                                         int presetIndex) {
         TrainingTestResult result;
         stringstream msg;
         int score = 0;
@@ -44,48 +52,45 @@
         //for_each(targetParams.begin(),targetParams.end(),printThing<int>());
         float initDist = euclideanDistance(startPosition, answer);
         float dist = euclideanDistance(targetParams, answer);
-        
         float TP = calculateThroughput(TOTAL_NUM_PARAMS, dist, initDist, timeAllowed/1000.);
         
         auto dimComp = sqrt(TOTAL_NUM_PARAMS);
         int band = -1;
         if (dist < TARGET_SCORE_CC_BAND*dimComp){
-            score = 50;
+     
             band = 1;
             
             msg << "DOUBLE BULLSEYE!" << endl;
             
             
         }else if (dist < TARGET_SCORE_CC_BAND*2*dimComp){
-            
-            score = 25;
+       
             band = 2;
             
             msg << "SINGLE BULLSEYE!" << endl;
             
         }else if (dist < TARGET_SCORE_CC_BAND*3*dimComp){
-            
-            score = 15;
+       
             band = 3;
             msg << "CLOSE..." << endl;
             
         }else if (dist < TARGET_SCORE_CC_BAND*4*dimComp){
-            score = 5;
+           
             band = 4;
             msg << "OK...ISH" << endl;
             
         }else if (dist < TARGET_SCORE_CC_BAND*6*dimComp){ // 30
-            score = 2;
+           
             band = 5;
             msg << "MEDIOCRE" << endl;
             
         }else if (dist < TARGET_SCORE_CC_BAND*9*dimComp){ // 45
-            score = 1;
+           
             band = 6;
             msg << "POOR..." << endl;
             
         }else{
-            score = 0;
+           
             band = 7;
             msg << "MISSED COMPLETELY!" << endl;
             
@@ -103,29 +108,36 @@
         result.timeAllowed = timeAllowed;
         result.score = round(TP*10);
         result.displayText = msg.str();
+        result.difficultyLevel = difficulty;
+    
         
         ofColor c;
         if(result.targetBandHit == 1){
-            // yellow red blue
-            c = ofColor(255,255,0,255);
+            
+            c = ofColor(255,255,0,255);     // yellow 1
         }else if(result.targetBandHit == 2){
-            c = ofColor(255,0,0,255);
+            c = ofColor(255,0,0,255);       // red 2
         }else if(result.targetBandHit == 3){
-            c = ofColor(45,45,255,255);
+            c = ofColor(45,45,255,255);     // blue 3
         }else if(result.targetBandHit == 4){
-            c = ofColor(0,255,0,255);
+            c = ofColor(0,255,0,255);       // green 4
         }else{
-            c = ofColor(150,235,200,255);
+            c = ofColor(0,0,0,255);         // black worst
         }
         result.colorBand = c;
 
         totalScored += score;
         
         vector<int> details;
-        details.push_back(result.realDistanceToTarget);
+        
+        details.push_back(result.realDistanceToTarget*1000);
         details.push_back(result.targetBandHit);
         details.push_back(result.timeAllowed);
         details.push_back(result.score); // 10 x throughput
+        details.push_back(difficulty);
+        details.push_back(whichInSequence);
+        details.push_back(initDist*1000);
+        details.push_back(presetIndex);
         
         eventLogger.logEvent(TRAINING_RESULT, details);
         details.clear();
@@ -142,7 +154,8 @@
     
     
     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 14:04:05 2014 +0000
+++ b/UI code/6Dbox.h	Wed Nov 26 18:18:20 2014 +0000
@@ -87,7 +87,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 setTexture(ofImage* img);
+    void setHandTexture(ofImage* img);
     
     void setValue(int index, int value);
     void setValueAndScale(int index, int value);
@@ -127,11 +127,13 @@
     ofVec3f hintrotAnimIncr;
     
     ofMesh handMesh;
-    ofImage* defaultHandTextureRef;
+    ofImage* handTextureRef;
     ofImage defaultImage;
     ofImage hintImage;
     ofImage* hintImageRef;
     ofImage wallGrid;
+    ofImage animImage;
+    ofImage* animImageRef;
     ofMesh guideHandMesh;
     
     float hw, hh, hl, scale;
--- a/UI code/6Dbox.mm	Wed Nov 26 14:04:05 2014 +0000
+++ b/UI code/6Dbox.mm	Wed Nov 26 18:18:20 2014 +0000
@@ -37,7 +37,7 @@
     hl = 1.0;
     scale = 40; 
     
-    string fname = ofFilePath::getAbsolutePath(ofToDataPath("buttron.jpg"));
+    string fname = ofFilePath::getAbsolutePath(ofToDataPath("buttron.png"));
     defaultImage.loadImage(fname);
     
     fname = ofFilePath::getAbsolutePath(ofToDataPath("white.jpeg"));
@@ -46,7 +46,10 @@
     fname = ofFilePath::getAbsolutePath(ofToDataPath("wallGrid.jpg"));
     wallGrid.loadImage(fname);
     
-    setTexture(&defaultImage);
+    fname = ofFilePath::getAbsolutePath(ofToDataPath("neurons.jpg"));
+    animImage.loadImage(fname);
+    
+    setHandTexture(&defaultImage);
     setHintTexture(&hintImage);
     setUpHandMesh();
     
@@ -221,8 +224,8 @@
 }
 
 
-void Leap6DBox::setTexture(ofImage* img){
-    defaultHandTextureRef = img;
+void Leap6DBox::setHandTexture(ofImage* img){
+    handTextureRef = img;
     
     
 }
@@ -328,9 +331,9 @@
 
     }else{
         if (showScoreForFrames){
-            draw6DOFIndicatorBlob(x, y, z, c, rollVal, pitchVal, yawVal, defaultHandTextureRef, true);
+            draw6DOFIndicatorBlob(x, y, z, c, rollVal, pitchVal, yawVal, handTextureRef, true);
         }else{
-            draw6DOFIndicatorBlob(x, y, z, c, rollVal, pitchVal, yawVal, defaultHandTextureRef);
+            draw6DOFIndicatorBlob(x, y, z, c, rollVal, pitchVal, yawVal, handTextureRef);
         }
     }
 }
@@ -352,6 +355,7 @@
     ofSetColor(255,255,255);
     // render
     if (!showResultColor){
+        //cout << atexImg << endl;
         (*atexImg).bind();
     }else{
         ofSetColor(hintColor);
@@ -371,10 +375,10 @@
     return rot;
 }
 void Leap6DBox::animateHintToNewValues(vector<int> targetValues, float timeToTake , ofImage* newTexture){
-    
+    // NO
     Node targ;
     targ.setFromCC(targetValues);
-    
+    handTextureRef = animImageRef;
     animateHintToNewValues(targ, timeToTake);
 }
 
@@ -382,7 +386,7 @@
     
     Node targ;
     targ.setFromCC(targetValues);
-    
+    handTextureRef = animImageRef;
     animateToNewValues(targ, timeToTake);
 }
 //--------------------------------------------------------------------