annotate testApp.h @ 49:178642d134a7 tip

xtra files
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Wed, 01 May 2013 17:34:33 +0100
parents 43958fd481aa
children
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@48 8 #include "ofxMidi.h"
rt300@39 9
rt300@0 10 #include "grid.h"
rt300@0 11 #include "2dvector.h"
rt300@0 12 #include "eventLogger.h"
rt300@2 13 #include "AppCore.h"
rt300@1 14
rt300@3 15 #include "presetManager.h"
rt300@3 16 #include "eventLogger.h"
rt300@3 17 #include "ofxPd.h"
rt300@3 18 #include "frequencer.h"
rt300@3 19
rt300@8 20 #include "json.h"
rt300@8 21
rt300@16 22 #import "QuestionnaireViewController.h"
rt300@24 23 #import "BottomTabViewController.h"
rt300@24 24 #import "IntroViewController.h"
rt300@27 25 #import "HelpViewController.h"
rt300@24 26 #import "TopButtonViewController.h"
rt300@25 27 #import "SliderViewController.h"
rt300@25 28 #import "usernameAlertViewController.h"
rt300@29 29 #import "TimedSessionController.h"
rt300@47 30
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@47 38
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@47 44 typedef enum {SLIDERS,ZOOMER,BOTH,INTRO,QUESTIONNAIRE, HELP}interfaceType;
rt300@39 45 bool sendMIDIAndOSC;
rt300@39 46 int midiChannel;
rt300@39 47 int midiOffset;
rt300@46 48 bool animatingGrid;
rt300@46 49 bool allowAnimation;
rt300@24 50 interfaceType whichInterfaceShowing;
rt300@46 51 interfaceType previousInterface;
rt300@24 52 BottomTabViewController *bottomTabViewController;
rt300@25 53 UsernameAlertViewController *usernameAlertViewController;
rt300@26 54 HelpViewController *helpViewController;
rt300@27 55 QuestionnaireViewController * questionnaireViewController;
rt300@27 56 IntroViewController * introViewController;
rt300@27 57 TopButtonViewController * topButtonViewController;
rt300@27 58 SliderViewController * sliderViewController;
rt300@29 59 TimedSessionController * tsc;
rt300@0 60 int prevTouchX;
rt300@0 61 int prevTouchY;
rt300@0 62 double prevDist;
rt300@16 63 bool paused;
rt300@0 64 // not many so dont bother with vectors/arrays?
rt300@0 65 TwoVector touch0;
rt300@0 66 TwoVector touch1;
rt300@0 67 TwoVector prevTouch0;
rt300@0 68 TwoVector prevTouch1;
rt300@5 69
rt300@0 70 bool xLocked, yLocked;
rt300@6 71 unsigned int lastMoveTime;
rt300@0 72
rt300@0 73 TwoVector moveVel; // velocity at which we were moving the grid
rt300@0 74
rt300@0 75 double slowFactor;
rt300@0 76 double zoomVel; // do the same
rt300@0 77 double prevZoom, prevZoom2;
rt300@5 78 TwoVector move, prevMove, prevMove2;
rt300@0 79
rt300@0 80 vector<int> sliderVals;
rt300@3 81 vector<int> freqIndexes;
rt300@36 82 vector<vector <int> > sequences;
rt300@36 83 int currentSequence;
rt300@0 84
rt300@0 85 int numActiveTouches;
rt300@27 86 bool preventingMovePostScroll;
rt300@38 87 void setInterp(int state);
rt300@27 88
rt300@0 89 //
rt300@0 90
rt300@16 91 void setup();
rt300@16 92 void update();
rt300@16 93 void draw();
rt300@16 94 void exit();
rt300@16 95
rt300@42 96 void initialiseVariables();
rt300@42 97 void initialiseGUIs();
rt300@42 98 void initialiseMIDI();
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@46 142 int 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@47 150
rt300@24 151
rt300@22 152 void sliderMoved(int which, float value);
rt300@22 153 void setAllGUISliders(vector<int> vals);
rt300@25 154 void randomise();
rt300@0 155
rt300@0 156 // zoom gui - the swap view button and save preset button
rt300@47 157
rt300@0 158
rt300@22 159
rt300@3 160 void sendParametersToPD();
rt300@3 161 void sendOscShape(int ctrlin);
rt300@3 162 void sendFiltShape(int ctrlin);
rt300@3 163 void sendFiltType(int ctrlin);
rt300@3 164 void sendFiltFreq(int ctrlin);
rt300@3 165 void sendEnvShape(int ctrlin);
rt300@45 166 void sendResonance(int ctrlin);
rt300@43 167 void sendAmpEnvShape(int ctrlin);
rt300@43 168 void sendFiltEnvShape(int ctrlin);
rt300@3 169 void sendModFreq(int ctrlin);
rt300@45 170 void sendFMAmt(int ctrlin);
rt300@45 171 void sendDistortion(int ctrlin);
rt300@45 172 void sendRevAmt(int ctrlin);
rt300@45 173 void sendFiltEnvModAmt(int ctrlin);
rt300@45 174
rt300@39 175 void sendMidiParams();
rt300@39 176 void sendMidiParam(int which);
rt300@0 177
rt300@2 178 // audio callbacks
rt300@2 179 void audioReceived(float * input, int bufferSize, int nChannels);
rt300@2 180 void audioRequested(float * output, int bufferSize, int nChannels);
rt300@2 181
rt300@2 182 AppCore core;
rt300@2 183
rt300@39 184 // message
rt300@39 185 void addMessage(string msg);
rt300@39 186
rt300@39 187 // midi message callback
rt300@39 188 void newMidiMessage(ofxMidiMessage& msg);
rt300@39 189
rt300@39 190 // midi device (dis)connection event callbacks
rt300@39 191 void midiInputAdded(string name, bool isNetwork);
rt300@39 192 void midiInputRemoved(string name, bool isNetwork);
rt300@39 193
rt300@39 194 void midiOutputAdded(string nam, bool isNetwork);
rt300@39 195 void midiOutputRemoved(string name, bool isNetwork);
rt300@39 196
rt300@39 197 vector<ofxMidiIn*> inputs;
rt300@39 198 vector<ofxMidiOut*> outputs;
rt300@39 199
rt300@39 200 deque<string> messages;
rt300@39 201 int maxMessages;
rt300@39 202
rt300@39 203 int note, ctl;
rt300@39 204 vector<unsigned char> bytes;
rt300@39 205
rt300@45 206 void sendFiltTypeOld(int ctrlin);
rt300@45 207
rt300@0 208 };
rt300@0 209
rt300@22 210 // should be off split into
rt300@22 211 // GUI controller
rt300@22 212 // parameter converter
rt300@22 213 //