annotate testApp.h @ 44:a1e75b94c505

Snap to eval points. Double tap to go to preset (doesn't quite work yet). Coloured locks. Changed Question 2. Fixed some leaks.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Mon, 22 Apr 2013 18:32:34 +0100
parents b91a1859829a
children c2fffc8ea84d
rev   line source
rt300@0 1 #pragma once
rt300@0 2
rt300@0 3 #include "ofMain.h"
rt300@0 4 #include "ofxiPhone.h"
rt300@0 5 #include "ofxiPhoneExtras.h"
rt300@32 6 #include "ofxiPhoneExternalDisplay.h"
rt300@0 7 #include "ofxOsc.h"
rt300@39 8 #include "ofxMidi.h"
rt300@39 9
rt300@0 10 #include "grid.h"
rt300@0 11 #include "2dvector.h"
rt300@0 12 #include "ofxUI.h"
rt300@0 13 #include "eventLogger.h"
rt300@2 14 #include "AppCore.h"
rt300@1 15
rt300@3 16 #include "presetManager.h"
rt300@3 17 #include "eventLogger.h"
rt300@3 18 #include "ofxPd.h"
rt300@3 19 #include "frequencer.h"
rt300@3 20
rt300@8 21 #include "json.h"
rt300@8 22
rt300@16 23 #import "QuestionnaireViewController.h"
rt300@24 24 #import "BottomTabViewController.h"
rt300@24 25 #import "IntroViewController.h"
rt300@27 26 #import "HelpViewController.h"
rt300@24 27 #import "TopButtonViewController.h"
rt300@25 28 #import "SliderViewController.h"
rt300@25 29 #import "usernameAlertViewController.h"
rt300@29 30 #import "TimedSessionController.h"
rt300@29 31 #define OSC_HOST "169.254.1.1"
rt300@29 32 #define OSC_PORT 12345
rt300@8 33
rt300@39 34 #define SLIDER_GUI_WIDTH 256
rt300@38 35 #define SLIDER_HEIGHT 256
rt300@38 36 #define NUM_PARAMS 10
rt300@38 37
rt300@29 38 typedef enum {SLIDERS,ZOOMER,BOTH,INTRO,QUESTIONNAIRE, HELP}interfaceType;
rt300@24 39
rt300@39 40 class testApp : public ofxiPhoneApp , public ofxiPhoneExternalDisplay, public ofxMidiListener, public ofxMidiConnectionListener {
rt300@0 41
rt300@3 42
rt300@3 43 public:
rt300@39 44 bool sendMIDIAndOSC;
rt300@39 45 int midiChannel;
rt300@39 46 int midiOffset;
rt300@0 47
rt300@24 48 interfaceType whichInterfaceShowing;
rt300@24 49 BottomTabViewController *bottomTabViewController;
rt300@25 50 UsernameAlertViewController *usernameAlertViewController;
rt300@26 51 HelpViewController *helpViewController;
rt300@27 52 QuestionnaireViewController * questionnaireViewController;
rt300@27 53 IntroViewController * introViewController;
rt300@27 54 TopButtonViewController * topButtonViewController;
rt300@27 55 SliderViewController * sliderViewController;
rt300@29 56 TimedSessionController * tsc;
rt300@0 57 int prevTouchX;
rt300@0 58 int prevTouchY;
rt300@0 59 double prevDist;
rt300@16 60 bool paused;
rt300@0 61 // not many so dont bother with vectors/arrays?
rt300@0 62 TwoVector touch0;
rt300@0 63 TwoVector touch1;
rt300@0 64 TwoVector prevTouch0;
rt300@0 65 TwoVector prevTouch1;
rt300@5 66
rt300@0 67 bool xLocked, yLocked;
rt300@6 68 unsigned int lastMoveTime;
rt300@0 69
rt300@0 70 TwoVector moveVel; // velocity at which we were moving the grid
rt300@0 71
rt300@0 72 vector <ofxUISlider *> sliders;
rt300@0 73
rt300@0 74 double slowFactor;
rt300@0 75 double zoomVel; // do the same
rt300@0 76 double prevZoom, prevZoom2;
rt300@5 77 TwoVector move, prevMove, prevMove2;
rt300@0 78
rt300@0 79 vector<int> sliderVals;
rt300@3 80 vector<int> freqIndexes;
rt300@36 81 vector<vector <int> > sequences;
rt300@36 82 int currentSequence;
rt300@0 83
rt300@0 84 int numActiveTouches;
rt300@27 85 bool preventingMovePostScroll;
rt300@38 86 void setInterp(int state);
rt300@27 87
rt300@0 88 //
rt300@0 89
rt300@16 90 void setup();
rt300@16 91 void update();
rt300@16 92 void draw();
rt300@16 93 void exit();
rt300@16 94
rt300@42 95 void initialiseVariables();
rt300@42 96 void initialiseGUIs();
rt300@42 97 void initialiseMIDI();
rt300@42 98
rt300@42 99
rt300@16 100 float getWidth();
rt300@16 101 float getHeight();
rt300@16 102
rt300@16 103 void touchDown(ofTouchEventArgs &touch);
rt300@16 104 void touchMoved(ofTouchEventArgs &touch);
rt300@16 105 void touchUp(ofTouchEventArgs &touch);
rt300@16 106 void touchDoubleTap(ofTouchEventArgs &touch);
rt300@16 107 void touchCancelled(ofTouchEventArgs &touch);
rt300@0 108
rt300@1 109 void handleScroll();
rt300@1 110 void handleZoom();
rt300@1 111
rt300@0 112 vector<float> vectorFilter(vector<float> newVec);
rt300@16 113
rt300@16 114 void lostFocus();
rt300@16 115 void gotFocus();
rt300@16 116 void gotMemoryWarning();
rt300@16 117 void deviceOrientationChanged(int newOrientation);
rt300@16 118
rt300@44 119 bool tapFlag;
rt300@16 120 ofxOscSender sender;
rt300@0 121 void sendOSCParams();
rt300@0 122
rt300@27 123 void setupNewUser();
rt300@27 124
rt300@24 125 void lockSynthPressed(bool locked);
rt300@24 126 void lockSequencerPressed(bool locked);
rt300@24 127
rt300@16 128 void showQuestionnaire();
rt300@28 129 void questionnaireHidden(vector<int> answers, const char* userComments);
rt300@24 130 void showIntro();
rt300@24 131 void introHidden(bool OK);
rt300@24 132 void interfaceSelected(int which);
rt300@39 133 void freeUseMode();
rt300@39 134
rt300@24 135 void seqStartStop(bool go);
rt300@27 136 void showHelp();
rt300@27 137 void helpHidden();
rt300@42 138 void startTimedSession();
rt300@33 139 // shortcut function for testing
rt300@33 140 void justStart();
rt300@36 141 void loadSequences();
rt300@36 142 void nextSequence();
rt300@24 143
rt300@24 144 void setupBottomGui();
rt300@24 145 void bottomGuiEvent();
rt300@24 146 void setupTopGui();
rt300@24 147 void topGuiEvent();
rt300@16 148
rt300@0 149 // stardard GUI - knbs and sliders - hides zoomer
rt300@24 150 void sliderGUIEvent(ofxUIEventArgs &e);
rt300@24 151 void setupSliderGui();
rt300@24 152 ofxUICanvas *sliderGUI;
rt300@24 153
rt300@22 154 void sliderMoved(int which, float value);
rt300@22 155 void setAllGUISliders(vector<int> vals);
rt300@25 156 void randomise();
rt300@0 157
rt300@0 158 // zoom gui - the swap view button and save preset button
rt300@0 159 void zoomGUIEvent(ofxUIEventArgs &e);
rt300@0 160 void setupZoomGui();
rt300@0 161
rt300@22 162
rt300@3 163 void sendParametersToPD();
rt300@3 164 void sendOscShape(int ctrlin);
rt300@3 165 void sendFiltShape(int ctrlin);
rt300@3 166 void sendFiltType(int ctrlin);
rt300@3 167 void sendFiltFreq(int ctrlin);
rt300@3 168 void sendEnvShape(int ctrlin);
rt300@43 169 void sendAmpEnvShape(int ctrlin);
rt300@43 170 void sendFiltEnvShape(int ctrlin);
rt300@3 171 void sendModFreq(int ctrlin);
rt300@39 172 void sendMidiParams();
rt300@39 173 void sendMidiParam(int which);
rt300@0 174 ofxUICanvas *zoomGUI;
rt300@0 175
rt300@2 176 // audio callbacks
rt300@2 177 void audioReceived(float * input, int bufferSize, int nChannels);
rt300@2 178 void audioRequested(float * output, int bufferSize, int nChannels);
rt300@2 179
rt300@2 180 AppCore core;
rt300@2 181
rt300@39 182 // message
rt300@39 183 void addMessage(string msg);
rt300@39 184
rt300@39 185 // midi message callback
rt300@39 186 void newMidiMessage(ofxMidiMessage& msg);
rt300@39 187
rt300@39 188 // midi device (dis)connection event callbacks
rt300@39 189 void midiInputAdded(string name, bool isNetwork);
rt300@39 190 void midiInputRemoved(string name, bool isNetwork);
rt300@39 191
rt300@39 192 void midiOutputAdded(string nam, bool isNetwork);
rt300@39 193 void midiOutputRemoved(string name, bool isNetwork);
rt300@39 194
rt300@39 195 vector<ofxMidiIn*> inputs;
rt300@39 196 vector<ofxMidiOut*> outputs;
rt300@39 197
rt300@39 198 deque<string> messages;
rt300@39 199 int maxMessages;
rt300@39 200
rt300@39 201 int note, ctl;
rt300@39 202 vector<unsigned char> bytes;
rt300@39 203
rt300@0 204 };
rt300@0 205
rt300@22 206 // should be off split into
rt300@22 207 // GUI controller
rt300@22 208 // parameter converter
rt300@22 209 //