Mercurial > hg > tweakathon2ios
changeset 16:2da0350a4aa2
expMessageOrganiser and express/explore view setup.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Tue, 21 Oct 2014 18:06:44 +0100 |
parents | e439bf85b665 |
children | 2a7320a8cbed |
files | ExplorePresetManager.h MessageOrganiser.h PDSynthWrapper.h TrainingMessageOrganiser.h eventLogger.h globalVariables.h presetManager.h testApp.h testApp.mm |
diffstat | 9 files changed, 145 insertions(+), 91 deletions(-) [+] |
line wrap: on
line diff
--- a/ExplorePresetManager.h Tue Oct 21 16:52:56 2014 +0100 +++ b/ExplorePresetManager.h Tue Oct 21 18:06:44 2014 +0100 @@ -27,11 +27,11 @@ if (thePresets.size() != MAX_PRESETS){ - initPresets(); + initPresetSlots(); } } - void initPresets(){ + void initPresetSlots(){ presetSlotFilename = ofFilePath::getAbsolutePath(ofToDataPath("presetSlots.json")); @@ -84,20 +84,11 @@ } //---------------------------------------------------------------------------- - void presentNextPreset(){ + void presentNextPresetSlot(){ } - Preset* getPreset(int index){ - - if (index >= thePresets.size()){ - cout << "ERROR: index " << index << " exceeds number of presets " << thePresets.size() << endl; - return NULL; - }else{ - return thePresets[index]; - - } - }; + protected: int filledSlots; string presetSlotFilename;
--- a/MessageOrganiser.h Tue Oct 21 16:52:56 2014 +0100 +++ b/MessageOrganiser.h Tue Oct 21 18:06:44 2014 +0100 @@ -31,7 +31,7 @@ #include "CountdownText.h" #include "buttonPanel.h" #include "ExplorePresetManager.h" - +#include "IconPanel.h" // should be called TIMED TEST MESSAGE ORGANISER ? @@ -80,12 +80,40 @@ void setBottomPanel(ButtonPanel * ntb){ bottomPanel = ntb; }; + + + void setIconPanel(IconPanel * ip){ + presetIconPanel = ip; + } + void setInstructionPanel(TextPanel * ip){ + instructionPanel = ip; + instructionPanel->show(); + } + + + //----------------------------------------------------------------------------- + void hideMyPanels(){ + presetIconPanel->hide(); + instructionPanel->hide(); + bottomPanel->hide(); + panel->hide(); + } + void showMyPanels(){ + presetIconPanel->show(); + instructionPanel->show(); + bottomPanel->show(); + panel->show(); + } protected: PDSynthWrapper candidateSynth; PDSynthWrapper targetSynth; ButtonPanel* bottomPanel; // shows during test : play buttons and submit SliderPanel* panel; + + IconPanel* presetIconPanel; + TextPanel* instructionPanel; + map<int,UIElement*> currentMapping; // could get more sophisticated if not 1-1 ? @@ -156,6 +184,36 @@ control->setLabel(candidateSynth.getNameForMappingID(mappingID)); }; + //----------------------------------------------------------------------------- + + void mapSlidersToParams(vector<UIElement*> elems, vector<int> mids){ + + vector<UIElement*>::iterator elit; + vector<int> typeListLog; + int i = 0; + for(elit=elems.begin(); elit<elems.end();elit++){ + if ( (*elit)->getType() == SLIDER){ + if(i >= mids.size()){ + + cout << "ERROR ERROR: too many controls for mapping IDs: " << mids.size() << endl; + } + + ButtronSlider* theSlider = (ButtronSlider*)(*elit); + mapControlToParam((*elit), mids[i]); + theSlider->setValueAndScale(candidateSynth.getParamValueForID(mids[i])); + cout << "Hint Value " << targetSynth.getParamValueFromName(candidateSynth.getNameForMappingID(mids[i])) << endl; + theSlider->setHintValue(targetSynth.getParamValueFromName(candidateSynth.getNameForMappingID(mids[i]))); + i++; + typeListLog.push_back(int(SLIDER)); + + }else{ + cout << "ERROR ERROR: ui type not handled my mapping function !" << endl; + } + } + + eventLogger.logEvent(CONTROL_LIST,typeListLog); + }; + void mapXYToParams(ButtronXY* control, int mappingIDX, int mappingIDY){ UICallbackFunction callback;
--- a/PDSynthWrapper.h Tue Oct 21 16:52:56 2014 +0100 +++ b/PDSynthWrapper.h Tue Oct 21 18:06:44 2014 +0100 @@ -36,8 +36,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){ @@ -271,7 +271,6 @@ private: string synthPrefix; AppCore* core; - PresetManager presetManager; // TODO not here vector<SynthParam> timbreParams; // array of everything in synth };
--- a/TrainingMessageOrganiser.h Tue Oct 21 16:52:56 2014 +0100 +++ b/TrainingMessageOrganiser.h Tue Oct 21 18:06:44 2014 +0100 @@ -28,7 +28,7 @@ callback = boost::bind(&TrainingMessageOrganiser::onNextTick, this, _1); candidateSynth.registerForTicks(callback); - numParamsToUse = 3; + numParamsToUse = TOTAL_NUM_PARAMS; } @@ -62,14 +62,7 @@ }; - - void setIconPanel(IconPanel * ip){ - presetIconPanel = ip; - } - void setInstructionPanel(TextPanel * ip){ - instructionPanel = ip; - instructionPanel->show(); - } + //----------------------------------------------------------------------- void displayInstructions(Step s){ @@ -127,7 +120,7 @@ } if(newStep.presetIndex >= 0 && newStep.presetIndex <= 8){ - currentTargetPreset = expPresetManager.getPreset(newStep.presetIndex); + currentTargetPreset = expPresetManager.getPresetAtIndex(newStep.presetIndex); } if(newStep.showsTargetIcon){ @@ -174,7 +167,7 @@ } } - + //----------------------------------------------------------------------- protected: void showUserHowTheyDid(){ @@ -183,16 +176,7 @@ // score } - void loadPreset(string pname){ - - vector<int> values = expPresetManager.recallPreset(pname); - if (values.size()){ - candidateSynth.setAllParams(values); - setAllSlidersToValues(values); - }else{ - cout << "ERROR, no preset found" << endl; - } - } + //----------------------------------------------------------------------- @@ -207,34 +191,7 @@ } } //----------------------------------------------------------------------------- - - void mapSlidersToParams(vector<UIElement*> elems, vector<int> mids){ - - vector<UIElement*>::iterator elit; - vector<int> typeListLog; - int i = 0; - for(elit=elems.begin(); elit<elems.end();elit++){ - if ( (*elit)->getType() == SLIDER){ - if(i >= mids.size()){ - - cout << "ERROR ERROR: too many controls for mapping IDs: " << mids.size() << endl; - } - - ButtronSlider* theSlider = (ButtronSlider*)(*elit); - mapControlToParam((*elit), mids[i]); - theSlider->setValueAndScale(candidateSynth.getParamValueForID(mids[i])); - cout << "Hint Value " << targetSynth.getParamValueFromName(candidateSynth.getNameForMappingID(mids[i])) << endl; - theSlider->setHintValue(targetSynth.getParamValueFromName(candidateSynth.getNameForMappingID(mids[i]))); - i++; - typeListLog.push_back(int(SLIDER)); - - }else{ - cout << "ERROR ERROR: ui type not handled my mapping function !" << endl; - } - } - - eventLogger.logEvent(CONTROL_LIST,typeListLog); - }; + //----------------------------------------------------------------------------- void buttonPressCallback(int mappingID, int value){ @@ -251,22 +208,13 @@ candidateSynth.startMetronome(); return; } - if(mappingID == SAVE_PRESET_HIT){ - expPresetManager.savePreset("blah", candidateSynth.getAllParamValues()); - return; - } - if(mappingID == RECALL_PRESET_HIT){ - - loadPreset("blah"); - return; - } + } //----------------------------------------------------------------------------- SequenceController sequenceController; - bool sequencePreview; + Preset * currentTargetPreset; - IconPanel* presetIconPanel; - TextPanel* instructionPanel; + }; #endif /* defined(__riftathon__TrainingMessageOrganiser__) */
--- a/eventLogger.h Tue Oct 21 16:52:56 2014 +0100 +++ b/eventLogger.h Tue Oct 21 18:06:44 2014 +0100 @@ -67,7 +67,8 @@ EMPTY_EVENT, SPEED_CHANGED, // 22 ms between sounds SAVE_PRESET, // 23 save a preset - START_THE_TRAINING_TESTS, + START_THE_TRAINING_TESTS, // 24 start traning + START_THE_EXP_TESTS // 25 start explore/express };
--- a/globalVariables.h Tue Oct 21 16:52:56 2014 +0100 +++ b/globalVariables.h Tue Oct 21 18:06:44 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 Tue Oct 21 16:52:56 2014 +0100 +++ b/presetManager.h Tue Oct 21 18:06:44 2014 +0100 @@ -141,6 +141,17 @@ void exitAndSaveAll(); // save stuff to the json file void printAll(); void clearAll(); + + Preset* getPresetAtIndex(int index){ + + if (index >= thePresets.size()){ + cout << "ERROR: index " << index << " exceeds number of presets " << thePresets.size() << endl; + return NULL; + }else{ + return thePresets[index]; + + } + }; protected: string presetFileName; int nextID;
--- a/testApp.h Tue Oct 21 16:52:56 2014 +0100 +++ b/testApp.h Tue Oct 21 18:06:44 2014 +0100 @@ -30,6 +30,7 @@ #include "MessageOrganiser.h" #include "SearchMessageOrganiser.h" #include "TrainingMessageOrganiser.h" +#include "ExpMessageOrganiser.h" #include "timeController.h" #include <buttonPanel.h> #include "targetSymbol.h" @@ -81,7 +82,7 @@ SearchMessageOrganiser searchMessageOrganiser; TrainingMessageOrganiser trainingMessageOrganiser; - + ExpMessageOrganiser expMessageOrganiser; PDSynthWrapper targetSynth; PDSynthWrapper candidateSynth; @@ -119,6 +120,7 @@ void usernameEntered(); void startTheSearchTests(); void startTheTrainingTests(); + void startTheExpTests(); void showHelp(); void helpHidden(); void setupNewUser(); @@ -171,8 +173,7 @@ void rotateToLandscapeLeft(){}; void rotateToLandscapeRight(){}; void toggleAutoRotation(){}; - - ofImage image; + }; // should be off split into
--- a/testApp.mm Tue Oct 21 16:52:56 2014 +0100 +++ b/testApp.mm Tue Oct 21 18:06:44 2014 +0100 @@ -26,6 +26,8 @@ searchMessageOrganiser.init(targetSynth, candidateSynth); trainingMessageOrganiser.init(targetSynth,candidateSynth); + expMessageOrganiser.init(targetSynth,candidateSynth); + timeController.init(); initialiseGUIs(); initialiseMIDI(); @@ -60,7 +62,7 @@ ofSoundStreamSetup(2, 2, this, 44100, ofxPd::blockSize()*ticksPerBuffer, 3); if(true){ // force start - startTheTrainingTests(); + startTheExpTests(); }else{ if(eventLogger.questionnaireCompleted){ // then show play again dialog, and log the test number @@ -113,7 +115,32 @@ //-------------------------------------------------------------- // GUI for finding and saving presets to express concepts void testApp::setupExpressViewPanels(){ + ButtonPanel* bottomButtonPanel = new ButtonPanel(1,160+props->sliderPanelHeight,ofGetWidth(),250,*props); + Buttron * playCandidateButton = new Buttron(props->buttonWidth*1.4,680, *props); + playCandidateButton->setLabel("PLAY"); + expMessageOrganiser.mapButtonToAction(playCandidateButton, TRIGGER_CANDIDATE_ID); + bottomButtonPanel->addButton(playCandidateButton); + + Buttron * savePresetButton = new Buttron(props->buttonWidth*1.4,680, *props); + savePresetButton->setLabel("SAVE"); + expMessageOrganiser.mapButtonToAction(savePresetButton, SAVE_PRESET_HIT); + bottomButtonPanel->addButton(savePresetButton); + + expMessageOrganiser.setBottomPanel(bottomButtonPanel); + UIElements.push_back(bottomButtonPanel); + bottomButtonPanel->hide(); + + IconPanel* iconPanel = new IconPanel(420, 10, 150, 150, *props); + expMessageOrganiser.setIconPanel(iconPanel); + UIElements.push_back(iconPanel); + iconPanel->show(); + + TextPanel * instructionPanel = new TextPanel("Instrcution panel", 10, 50, 300,150,(*props)); + instructionPanel->setFontSize(LARGEFONT); + UIElements.push_back(instructionPanel); + expMessageOrganiser.setInstructionPanel(instructionPanel); + instructionPanel->show(); } //-------------------------------------------------------------- // gui for the main training stage @@ -123,7 +150,7 @@ // play and submit are now same thing Buttron * playCandidateButton = new Buttron(props->buttonWidth*1.4,680, *props); - playCandidateButton->setLabel("PLAY"); + playCandidateButton->setLabel("START"); trainingMessageOrganiser.mapButtonToAction(playCandidateButton, TRIGGER_CANDIDATE_ID); bottomButtonPanel->addButton(playCandidateButton); @@ -131,18 +158,17 @@ UIElements.push_back(bottomButtonPanel); bottomButtonPanel->hide(); + IconPanel* iconPanel = new IconPanel(420, 10, 150, 150, *props); + trainingMessageOrganiser.setIconPanel(iconPanel); + UIElements.push_back(iconPanel); + iconPanel->show(); + TextPanel * instructionPanel = new TextPanel("Instrcution panel", 10, 50, 300,150,(*props)); instructionPanel->setFontSize(LARGEFONT); UIElements.push_back(instructionPanel); trainingMessageOrganiser.setInstructionPanel(instructionPanel); instructionPanel->show(); - IconPanel* iconPanel = new IconPanel(420, 10, 150, 150, *props); - trainingMessageOrganiser.setIconPanel(iconPanel); - UIElements.push_back(iconPanel); - iconPanel->show(); - - } //-------------------------------------------------------------- // gui for the old style tweakathlon stage @@ -235,6 +261,7 @@ UIElements.push_back(controlPanel); searchMessageOrganiser.setControlPanel(controlPanel); trainingMessageOrganiser.setControlPanel(controlPanel); + expMessageOrganiser.setControlPanel(controlPanel); controlPanel->showBorder(true); } //-------------------------------------------------------------- @@ -247,6 +274,8 @@ setupSliderPanel(); setupTrainingViewPanels(); + + setupExpressViewPanels(); } //-------------------------------------------------------------------------- void testApp::initialiseMIDI(){ @@ -397,10 +426,25 @@ } //-------------------------------------------------------------- +void testApp::startTheExpTests(){ + eventLogger.logEvent(START_THE_EXP_TESTS); + whichInterfaceShowing = COUNT_DOWN; + // do countdown etc + + trainingMessageOrganiser.hideMyPanels(); + + expMessageOrganiser.setup(); + expMessageOrganiser.showMyPanels(); + // TODO how is testApp going to kknow whichInterfaceShowing ??? + +} +//-------------------------------------------------------------- void testApp::startTheSearchTests(){ eventLogger.logEvent(START_THE_SEARCH_TESTS); whichInterfaceShowing = COUNT_DOWN; // do countdown etc + + trainingMessageOrganiser.hideMyPanels(); searchMessageOrganiser.countdownToNewTest(); // TODO how is testApp going to kknow whichInterfaceShowing ??? @@ -409,6 +453,7 @@ eventLogger.logEvent(START_THE_TRAINING_TESTS); trainingMessageOrganiser.setupDefaultMapping(); + trainingMessageOrganiser.showMyPanels(); } //--------------------------------------------------------------