changeset 23:055e0c43afe5

Leap MIDI works for 6 sliders, in exp and train modes.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Mon, 27 Oct 2014 15:52:04 +0000
parents 8124f46eda65
children b339acf124df
files ExpMessageOrganiser.h ExpMessageOrganiser.mm MessageOrganiser.h PDSynthWrapper.h SequenceController.h SequenceController.mm TrainingMessageOrganiser.h TrainingMessageOrganiser.mm UI code/3DboxGL.h UI code/6Dbox.h UI code/6Dbox.mm testApp.mm
diffstat 12 files changed, 128 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/ExpMessageOrganiser.h	Thu Oct 23 18:15:46 2014 +0100
+++ b/ExpMessageOrganiser.h	Mon Oct 27 15:52:04 2014 +0000
@@ -26,9 +26,11 @@
     void showCurrentSlot();
     void loadPreset(string pname);
     void buttonPressCallback(int mappingID, int value);
+    void midiFromLeap(int ctl_num, int ctl_val);
 private:
     void loadDefaultSound();
     int numParamsToUse;
+    
 };
 
 
--- a/ExpMessageOrganiser.mm	Thu Oct 23 18:15:46 2014 +0100
+++ b/ExpMessageOrganiser.mm	Mon Oct 27 15:52:04 2014 +0000
@@ -21,6 +21,7 @@
     showCurrentSlot();
     instructionPanel->setLabel("Find a sound\n that expresses:");
     instructionPanel->show();
+    okToGetMidi = true;
 }
 
 
@@ -111,4 +112,25 @@
         return;
     }
     
-}
\ No newline at end of file
+}
+
+void ExpMessageOrganiser::midiFromLeap(int ctl_num, int ctl_val){
+
+
+    if (!okToGetMidi){
+        return;
+    }
+    vector<int> mids = candidateSynth.getAllMappingIDs();
+    if (ctl_num >= mids.size() || ctl_num < 0) return;
+    
+    candidateSynth.paramChangeCallback(mids[ctl_num], ctl_val);
+    
+    setUIToParam(ctl_num, ctl_val);
+    
+    vector<int> evtData;
+    evtData.push_back(mids[ctl_num]); // or just index?
+    evtData.push_back(ctl_val);
+    
+    eventLogger.logEvent(CANDIDATE_PARAM_ADJUSTED, evtData);
+    
+}
--- a/MessageOrganiser.h	Thu Oct 23 18:15:46 2014 +0100
+++ b/MessageOrganiser.h	Mon Oct 27 15:52:04 2014 +0000
@@ -103,6 +103,7 @@
     void setSlidersToDefault();
     void showTargetAsHints();
     bool onlyChangeCandidateOnTrigger;
+    bool okToGetMidi;
 
 };
 
--- a/PDSynthWrapper.h	Thu Oct 23 18:15:46 2014 +0100
+++ b/PDSynthWrapper.h	Mon Oct 27 15:52:04 2014 +0000
@@ -141,7 +141,16 @@
         }
         return result;
     }
-    
+    vector<int> getAllMappingIDs(){
+        vector<int> result;
+        
+        for(int i = 0 ; i < timbreParams.size(); i++){
+                int mapid = timbreParams[i].getID();
+                result.push_back(mapid);
+
+        }
+        return result;
+    }
     
     const int getParamValueFromName(string name) const{
         
--- a/SequenceController.h	Thu Oct 23 18:15:46 2014 +0100
+++ b/SequenceController.h	Mon Oct 27 15:52:04 2014 +0000
@@ -16,7 +16,7 @@
 #define MAX_TARGETS_IN_SEQUENCE 5
 #define MIN_TEMPO   60
 #define MAX_TEMPO   120
-#define NUM_TEMPO_STEPS 8
+#define NUM_TEMPO_STEPS 16
 #define NUM_PRESETS 8
 
 
--- a/SequenceController.mm	Thu Oct 23 18:15:46 2014 +0100
+++ b/SequenceController.mm	Mon Oct 27 15:52:04 2014 +0000
@@ -101,7 +101,7 @@
     type = MATCHING_INTERACTION;
     showsTargetIcon = true;
     showsControlSettings = false;
-    showsControlGuides = false;
+    showsControlGuides = true;
     showsMatchResults = false;
     hidesSliders = false;
     isPreview = false;
--- a/TrainingMessageOrganiser.h	Thu Oct 23 18:15:46 2014 +0100
+++ b/TrainingMessageOrganiser.h	Mon Oct 27 15:52:04 2014 +0000
@@ -29,7 +29,7 @@
     void onNextTick(int tickNumber);
     
     void showMyPanels();
-    
+    void midiFromLeap(int ctl_num, int ctl_val);
     //-----------------------------------------------------------------------
 protected:
     void showUserHowTheyDid();
--- a/TrainingMessageOrganiser.mm	Thu Oct 23 18:15:46 2014 +0100
+++ b/TrainingMessageOrganiser.mm	Mon Oct 27 15:52:04 2014 +0000
@@ -117,6 +117,7 @@
         // do finished run stuff, show summary
         candidateSynth.stopMetronome();
         cout << "FINISHED BLOCK" << endl;
+        panel->hide();
         middlePanel->setColor(ofColor::white);
         middlePanel->setText("FINISHED BLOCK");
         return;
@@ -125,6 +126,7 @@
         // do finished run stuff, show summary
         candidateSynth.stopMetronome();
         cout << "FINISHED RUN" << endl;
+        panel->hide();
         middlePanel->setColor(ofColor::white);
         middlePanel->setText("FINISHED RUN");
         middlePanel->show();
@@ -174,8 +176,10 @@
     if(newStep.allowsCandidateControl){
         setCandidateAndSlidersToRandom();
         panel->setActive(true);
+        okToGetMidi = true;
     }else{
         panel->setActive(false);
+        okToGetMidi = false;
     }
     
     if(newStep.showsControlSettings){
@@ -239,7 +243,27 @@
 }
 
 //-----------------------------------------------------------------------------
-
+void TrainingMessageOrganiser::midiFromLeap(int ctl_num, int ctl_val){
+    
+    if (!okToGetMidi){
+        return;
+    }
+    vector<int> mids = candidateSynth.getAllMappingIDs();
+    if (ctl_num >= mids.size() || ctl_num < 0) return;
+    
+    paramChangeCallback(mids[ctl_num], ctl_val );
+    
+    //candidateSynth.paramChangeCallback(mids[ctl_num], ctl_val);
+    
+    setUIToParam(ctl_num, ctl_val);
+    
+    vector<int> evtData;
+    evtData.push_back(mids[ctl_num]); // or just index?
+    evtData.push_back(ctl_val);
+    
+    eventLogger.logEvent(CANDIDATE_PARAM_ADJUSTED, evtData);
+    
+}
 //-----------------------------------------------------------------------------
 
 void TrainingMessageOrganiser::buttonPressCallback(int mappingID, int value){
--- a/UI code/3DboxGL.h	Thu Oct 23 18:15:46 2014 +0100
+++ b/UI code/3DboxGL.h	Mon Oct 27 15:52:04 2014 +0000
@@ -102,13 +102,17 @@
         ofLine(ix,iy,iz,left,iy,iz);
 
         //blob
-        ofDrawIcoSphere(ix,iy,iz,12);
-        // line to front (a bit wierd?)
+        drawIndicatorBlob(ix,iy,iz,c);
+        // line to front (a bit wierde?)
         ofLine(ix,iy,iz,ix,iy,front);
         
 
         
     }
+    virtual void drawIndicatorBlob( float x, float y, float z, ofColor c){
+        ofSetColor(c);
+        ofDrawIcoSphere(x,y,z,12);
+    }
     ofColor calculateHintColor(){
 
         
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UI code/6Dbox.h	Mon Oct 27 15:52:04 2014 +0000
@@ -0,0 +1,28 @@
+//
+//  6Dbox.h
+//  riftathon
+//
+//  Created by Robert Tubb on 27/10/2014.
+//
+//
+
+#ifndef __riftathon___Dbox__
+#define __riftathon___Dbox__
+#include "3DboxGL.h"
+#include <iostream>
+
+class Leap6DBox : public Leap3DBoxGL {
+    
+public:
+    Leap6DBox(float ax,
+                float ay,
+                float awidth,
+                float aheight,
+                float azx,
+                float azy,
+                const UIProps& props);
+    
+};
+
+
+#endif /* defined(__riftathon___Dbox__) */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UI code/6Dbox.mm	Mon Oct 27 15:52:04 2014 +0000
@@ -0,0 +1,22 @@
+//
+//  6Dbox.mm
+//  riftathon
+//
+//  Created by Robert Tubb on 27/10/2014.
+//
+//
+
+#include "6Dbox.h"
+Leap6DBox::Leap6DBox(float ax,
+                         float ay,
+                         float awidth,
+                         float aheight,
+                         float azx,
+                         float azy,
+                         const UIProps& props) :
+Leap3DBoxGL(ax,ay,awidth, aheight, azx, azy, props)
+{
+
+    // set up hand mesh
+    
+}
\ No newline at end of file
--- a/testApp.mm	Thu Oct 23 18:15:46 2014 +0100
+++ b/testApp.mm	Mon Oct 27 15:52:04 2014 +0000
@@ -447,6 +447,8 @@
     expMessageOrganiser.showMyPanels();
     // TODO how is testApp going to kknow whichInterfaceShowing ???
     
+    currentStage = EXPRESS;
+    
 }
 //--------------------------------------------------------------
 void testApp::startTheSearchTests(){
@@ -457,14 +459,14 @@
     trainingMessageOrganiser.hideMyPanels();
     searchMessageOrganiser.countdownToNewTest();
     // TODO how is testApp going to kknow whichInterfaceShowing ???
-    
+    currentStage = SEARCH;
 }
 void testApp::startTheTrainingTests(){
     eventLogger.logEvent(START_THE_TRAINING_TESTS);
     
     trainingMessageOrganiser.setupDefaultMapping();
     trainingMessageOrganiser.showMyPanels();
-    
+    currentStage = TRAINING;
 }
 //--------------------------------------------------------------
 //--------------------------------------------------------------
@@ -725,7 +727,10 @@
         //cout << " ctrl : " << ctl_num << " : " << ctl_val << endl;
         if (currentStage == SEARCH)
             searchMessageOrganiser.midiFromLeap(ctl_num, ctl_val);
-        
+        if (currentStage == EXPRESS)
+            expMessageOrganiser.midiFromLeap(ctl_num, ctl_val);
+        if (currentStage == TRAINING)
+            trainingMessageOrganiser.midiFromLeap(ctl_num, ctl_val);
         
     }