changeset 12:af71bf84660f

icon stuff. not working/tested.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Mon, 20 Oct 2014 14:12:23 +0100
parents 91c3fba6e5b9
children ab3e0e980c82
files AppCore.mm ExplorePresetManager.h PDSynthWrapper.h PresetView.h PresetView.mm SequenceController.h TrainingMessageOrganiser.h UI code/UIElement.h UI code/UIElement.mm globalVariables.h presetManager.h presetManager.mm testApp.mm
diffstat 13 files changed, 102 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/AppCore.mm	Mon Oct 20 11:23:55 2014 +0100
+++ b/AppCore.mm	Mon Oct 20 14:12:23 2014 +0100
@@ -172,8 +172,7 @@
 }
 
 void AppCore::receiveFloat(const std::string& dest, float value) {
-	cout << "OF: receiveFloat " << dest << ": " << value << endl;
-    
+
     if (dest == "onTickOF"){
         // call our on tick function
         clockTickSender(value);
--- a/ExplorePresetManager.h	Mon Oct 20 11:23:55 2014 +0100
+++ b/ExplorePresetManager.h	Mon Oct 20 14:12:23 2014 +0100
@@ -91,7 +91,7 @@
     Preset* getPreset(int index){
         
         if (index >= thePresets.size()){
-            cout << "ERROR: index exceeds number of presets" << endl;
+            cout << "ERROR: index " << index << " exceeds number of presets " << thePresets.size() << endl;
             return NULL;
         }else{
             return thePresets[index];
--- a/PDSynthWrapper.h	Mon Oct 20 11:23:55 2014 +0100
+++ b/PDSynthWrapper.h	Mon Oct 20 14:12:23 2014 +0100
@@ -37,8 +37,8 @@
         timbreParams.push_back(SynthParam(64,aCore,"FiltTyp",sp));
         timbreParams.push_back(SynthParam(64,aCore,"FiltFrq",sp));
         
-        timbreParams.push_back(SynthParam(64,aCore,"SPAM",sp));
-        timbreParams.push_back(SynthParam(64,aCore,"FILTH",sp));
+        //timbreParams.push_back(SynthParam(64,aCore,"SPAM",sp));
+        //timbreParams.push_back(SynthParam(64,aCore,"FILTH",sp));
         //timbreParams.push_back(SynthParam(64,aCore,"reson",sp));
         
         if (timbreParams.size() != TOTAL_NUM_PARAMS){
@@ -245,6 +245,12 @@
         core->pd.sendMessage("fromOF", "startMetro", toPD);
         
     }
+    void stopMetronome(){
+        // play the noise
+        List toPD;
+        core->pd.sendMessage("fromOF", "stopMetro", toPD);
+        
+    }
     void onTick(int tickNo){
         //
         
--- a/PresetView.h	Mon Oct 20 11:23:55 2014 +0100
+++ b/PresetView.h	Mon Oct 20 14:12:23 2014 +0100
@@ -8,23 +8,47 @@
 
 #ifndef __riftathon__PresetView__
 #define __riftathon__PresetView__
+#include "ofMain.h"
+#include <iostream>
+#include "UIProperties.h"
+#include "UIElement.h"
+#include "ofxiPhoneExtras.h"
+class PresetIconView{
+    
+public:
+    PresetIconView(string aName, string aImageFileName){
+        imageFileName = aImageFileName;
+        if (imageFileName != ""){
+            // these are NOT put in images/ directory for some reason...
+            string fname = ofFilePath::getAbsolutePath(ofToDataPath(imageFileName));
 
-#include <iostream>
+            ofFile f = ofFile(fname);
+            
+            
+            cout << fname << endl;
+            cout << f.exists() <<  endl;
+            
+            image.loadImage(fname);
+        }
+        
 
-#include "presetManager.h"
-#include "UIElement.h"
+        name = aName;
 
-class PresetIconView : public UIElement {
+        
+        
+    };
+
+    bool handleMyTouch(int x, int y, touchType ttype, int touchID){
+        return false;
+    }
+    ofImage* getImage(){
+        return &image;
+    }
+private:
     string imageFileName;
     
     ofImage image;
     string name;
-    
-    
-    
-    void draw();
-    
-    
 };
 
 #endif /* defined(__riftathon__PresetView__) */
--- a/PresetView.mm	Mon Oct 20 11:23:55 2014 +0100
+++ b/PresetView.mm	Mon Oct 20 14:12:23 2014 +0100
@@ -7,3 +7,5 @@
 //
 
 #include "PresetView.h"
+
+
--- a/SequenceController.h	Mon Oct 20 11:23:55 2014 +0100
+++ b/SequenceController.h	Mon Oct 20 14:12:23 2014 +0100
@@ -43,6 +43,8 @@
         
         // if end of sequence return something else so we can do something
         // if end of tempo ramp return something else
+        uint randomInt = rand() % 8;
+        return randomInt;
         
     };
 protected:
--- a/TrainingMessageOrganiser.h	Mon Oct 20 11:23:55 2014 +0100
+++ b/TrainingMessageOrganiser.h	Mon Oct 20 14:12:23 2014 +0100
@@ -14,6 +14,8 @@
 #include "MessageOrganiser.h"
 #include "SequenceController.h"
 #include "globalVariables.h"
+#include "IconPanel.h"
+
 extern ExplorePresetManager expPresetManager;
 
 class TrainingMessageOrganiser : public MessageOrganiser {
@@ -27,6 +29,8 @@
         TickListenerFunction callback;
         callback = boost::bind(&TrainingMessageOrganiser::onNextTick, this, _1);
         candidateSynth.registerForTicks(callback);
+        
+        sequencePreview = true;
     }
 
     void setupDefaultMapping(){
@@ -34,7 +38,7 @@
         
         controlPanelType cpt = REVISITABLE;
         vector<controllerType> elemList;
-        for(int i = 0; i < 8; i++){
+        for(int i = 0; i < TOTAL_NUM_PARAMS; i++){
             elemList.push_back(SLIDER);
         }
         
@@ -47,7 +51,7 @@
     
     vector<int> getMappingIDsFromSynths(){
         vector<int> index;
-        for(int i = 0; i < 8; i++){
+        for(int i = 0; i < TOTAL_NUM_PARAMS; i++){
             index.push_back(i);
         }
         vector<int> mids = candidateSynth.getMappingIDForIndices(index);
@@ -60,6 +64,9 @@
         
     };
     
+    void setIconPanel(IconPanel * ip){
+        presetIconPanel = ip;
+    }
     void onNextTick(int tickNumber){
         cout << "TICK " << tickNumber << endl;
         
@@ -71,6 +78,7 @@
             
             if (sequencePreview){
                 // show next target preset
+                presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage());
              
                 // show image
                 // show name
@@ -96,7 +104,9 @@
                 
                 // flash the interface?
             }else{
-                // else the user should be hitting the play button
+                // has this been done? yes. candidateSynth.setAllParams(ui stuff);
+                candidateSynth.trigger();
+                showUserHowTheyDid();
                 
             }
         }
@@ -104,7 +114,12 @@
 
    
 protected:
-
+    void showUserHowTheyDid(){
+        // colour flash
+        // distance ?
+        // score
+        
+    }
     void loadPreset(string pname){
         
         vector<int> values = expPresetManager.recallPreset(pname);
@@ -183,5 +198,6 @@
     TrainingTestController* trainingTestController;
     bool sequencePreview;
     Preset * currentTargetPreset;
+    IconPanel* presetIconPanel;
 };
 #endif /* defined(__riftathon__TrainingMessageOrganiser__) */
--- a/UI code/UIElement.h	Mon Oct 20 11:23:55 2014 +0100
+++ b/UI code/UIElement.h	Mon Oct 20 14:12:23 2014 +0100
@@ -27,6 +27,12 @@
     
     UIElement();
     virtual ~UIElement(){};
+    
+    UIElement(float ax,
+              float ay,
+              float awidth,
+              float aheight);
+    
     // recommended
     UIElement(float ax,
               float ay,
--- a/UI code/UIElement.mm	Mon Oct 20 11:23:55 2014 +0100
+++ b/UI code/UIElement.mm	Mon Oct 20 14:12:23 2014 +0100
@@ -7,6 +7,7 @@
 //
 
 #include "UIElement.h"
+
 //----------------------------------------------------------------------
 UIElement::UIElement(){
     //
@@ -14,6 +15,9 @@
     init();
 }
 //----------------------------------------------------------------------
+
+
+//----------------------------------------------------------------------
 UIElement::UIElement(float ax,
                      float ay,
                      float awidth,
--- a/globalVariables.h	Mon Oct 20 11:23:55 2014 +0100
+++ b/globalVariables.h	Mon Oct 20 14:12:23 2014 +0100
@@ -29,7 +29,7 @@
 #define ALTERNATION_SPEED 180 // ms that target / candidate sounds play
 // globles
 
-#define TOTAL_NUM_PARAMS 8
+#define TOTAL_NUM_PARAMS 6
 #define TARGET_SCORE_CC_BAND 6 // number of cc vals per target band in dartboard
 typedef enum {TOUCH_DOWN, TOUCH_MOVED, TOUCH_UP} touchType;
 typedef enum {INTRO,QUESTIONNAIRE, HELP, TEST_IN_PROGRESS, SCORE_AND_HINT, COUNT_DOWN, READY_FOR_NEXT} interfaceType;
--- a/presetManager.h	Mon Oct 20 11:23:55 2014 +0100
+++ b/presetManager.h	Mon Oct 20 14:12:23 2014 +0100
@@ -23,7 +23,7 @@
 #include "eventLogger.h"
 #include "json.h"
 #include <ctime>
-
+#include "PresetView.h"
 
 //---------------------------------------------------------------------------
 class Preset{
@@ -35,11 +35,15 @@
     unsigned long long       creationTime; // datetime that preset was created milliseconds
     string imageFileName;
     vector<int> CCValues; // the actual data
-    ofImage presetImage;
     bool isFilled;
-    
+    PresetIconView* iconView;
     // from save button press
-    Preset(vector<int> aCCValues, string aname, int aID, string un, unsigned int uid, string imageFile = ""){
+    Preset(vector<int> aCCValues,
+           string aname,
+           int aID,
+           string un,
+           unsigned int uid,
+           string imageFile = ""){
         CCValues = aCCValues;
         if (CCValues.size()){
             isFilled = true;
@@ -58,8 +62,8 @@
         
         //TODO color / texture?
         imageFileName = imageFile;
-        if (imageFile != ""){
-            presetImage.loadImage("Images/" + imageFile);
+        if (imageFileName != ""){
+            iconView = new PresetIconView(name, imageFileName);
         }
 
     };
@@ -85,12 +89,15 @@
         }
         
         if (imageFileName != ""){
-            presetImage.loadImage(imageFileName);
+            iconView = new PresetIconView(name, imageFileName);
         }
 
+
     }
-    
-    void draw();
+
+    ofImage* getImage(){
+        return iconView->getImage();
+    }
     Json::Value presetToJson();
  
     string displayTextDescription(){ // eg: for grid hover
--- a/presetManager.mm	Mon Oct 20 11:23:55 2014 +0100
+++ b/presetManager.mm	Mon Oct 20 14:12:23 2014 +0100
@@ -12,10 +12,7 @@
 
 extern EventLogger eventLogger;
 
-//---------------------------------------------------------------------------
-void Preset::draw(){
-    // probably just hint values on sliders
-};
+
 //---------------------------------------------------------------------------
 Json::Value Preset::presetToJson(){
     // create the string for this instance of Preset object
--- a/testApp.mm	Mon Oct 20 11:23:55 2014 +0100
+++ b/testApp.mm	Mon Oct 20 14:12:23 2014 +0100
@@ -137,6 +137,12 @@
     trainingMessageOrganiser.setBottomPanel(bottomButtonPanel);
     UIElements.push_back(bottomButtonPanel);
     bottomButtonPanel->hide();
+    
+    IconPanel* iconPanel = new IconPanel(200, 10, 200, 150, p);
+    trainingMessageOrganiser.setIconPanel(iconPanel);
+    UIElements.push_back(iconPanel);
+    iconPanel->show();
+    
 }
 //--------------------------------------------------------------
 // gui for the old style tweakathlon  stage