rt300@0: #pragma once rt300@0: rt300@0: #include "ofMain.h" rt300@0: #include "ofxiPhone.h" rt300@0: #include "ofxiPhoneExtras.h" rt300@32: #include "ofxiPhoneExternalDisplay.h" rt300@0: #include "ofxOsc.h" rt300@48: #include "ofxMidi.h" rt300@39: rt300@0: #include "grid.h" rt300@0: #include "2dvector.h" rt300@0: #include "eventLogger.h" rt300@2: #include "AppCore.h" rt300@1: rt300@3: #include "presetManager.h" rt300@3: #include "eventLogger.h" rt300@3: #include "ofxPd.h" rt300@3: #include "frequencer.h" rt300@3: rt300@8: #include "json.h" rt300@8: rt300@16: #import "QuestionnaireViewController.h" rt300@24: #import "BottomTabViewController.h" rt300@24: #import "IntroViewController.h" rt300@27: #import "HelpViewController.h" rt300@24: #import "TopButtonViewController.h" rt300@25: #import "SliderViewController.h" rt300@25: #import "usernameAlertViewController.h" rt300@29: #import "TimedSessionController.h" rt300@47: rt300@29: #define OSC_HOST "169.254.1.1" rt300@29: #define OSC_PORT 12345 rt300@8: rt300@39: #define SLIDER_GUI_WIDTH 256 rt300@38: #define SLIDER_HEIGHT 256 rt300@38: #define NUM_PARAMS 10 rt300@38: rt300@47: rt300@24: rt300@39: class testApp : public ofxiPhoneApp , public ofxiPhoneExternalDisplay, public ofxMidiListener, public ofxMidiConnectionListener { rt300@0: rt300@3: rt300@3: public: rt300@47: typedef enum {SLIDERS,ZOOMER,BOTH,INTRO,QUESTIONNAIRE, HELP}interfaceType; rt300@39: bool sendMIDIAndOSC; rt300@39: int midiChannel; rt300@39: int midiOffset; rt300@46: bool animatingGrid; rt300@46: bool allowAnimation; rt300@24: interfaceType whichInterfaceShowing; rt300@46: interfaceType previousInterface; rt300@24: BottomTabViewController *bottomTabViewController; rt300@25: UsernameAlertViewController *usernameAlertViewController; rt300@26: HelpViewController *helpViewController; rt300@27: QuestionnaireViewController * questionnaireViewController; rt300@27: IntroViewController * introViewController; rt300@27: TopButtonViewController * topButtonViewController; rt300@27: SliderViewController * sliderViewController; rt300@29: TimedSessionController * tsc; rt300@0: int prevTouchX; rt300@0: int prevTouchY; rt300@0: double prevDist; rt300@16: bool paused; rt300@0: // not many so dont bother with vectors/arrays? rt300@0: TwoVector touch0; rt300@0: TwoVector touch1; rt300@0: TwoVector prevTouch0; rt300@0: TwoVector prevTouch1; rt300@5: rt300@0: bool xLocked, yLocked; rt300@6: unsigned int lastMoveTime; rt300@0: rt300@0: TwoVector moveVel; // velocity at which we were moving the grid rt300@0: rt300@0: double slowFactor; rt300@0: double zoomVel; // do the same rt300@0: double prevZoom, prevZoom2; rt300@5: TwoVector move, prevMove, prevMove2; rt300@0: rt300@0: vector sliderVals; rt300@3: vector freqIndexes; rt300@36: vector > sequences; rt300@36: int currentSequence; rt300@0: rt300@0: int numActiveTouches; rt300@27: bool preventingMovePostScroll; rt300@38: void setInterp(int state); rt300@27: rt300@0: // rt300@0: rt300@16: void setup(); rt300@16: void update(); rt300@16: void draw(); rt300@16: void exit(); rt300@16: rt300@42: void initialiseVariables(); rt300@42: void initialiseGUIs(); rt300@42: void initialiseMIDI(); rt300@42: rt300@16: float getWidth(); rt300@16: float getHeight(); rt300@16: rt300@16: void touchDown(ofTouchEventArgs &touch); rt300@16: void touchMoved(ofTouchEventArgs &touch); rt300@16: void touchUp(ofTouchEventArgs &touch); rt300@16: void touchDoubleTap(ofTouchEventArgs &touch); rt300@16: void touchCancelled(ofTouchEventArgs &touch); rt300@0: rt300@1: void handleScroll(); rt300@1: void handleZoom(); rt300@1: rt300@0: vector vectorFilter(vector newVec); rt300@16: rt300@16: void lostFocus(); rt300@16: void gotFocus(); rt300@16: void gotMemoryWarning(); rt300@16: void deviceOrientationChanged(int newOrientation); rt300@16: rt300@44: bool tapFlag; rt300@16: ofxOscSender sender; rt300@0: void sendOSCParams(); rt300@0: rt300@27: void setupNewUser(); rt300@27: rt300@24: void lockSynthPressed(bool locked); rt300@24: void lockSequencerPressed(bool locked); rt300@24: rt300@16: void showQuestionnaire(); rt300@28: void questionnaireHidden(vector answers, const char* userComments); rt300@24: void showIntro(); rt300@24: void introHidden(bool OK); rt300@24: void interfaceSelected(int which); rt300@39: void freeUseMode(); rt300@39: rt300@24: void seqStartStop(bool go); rt300@27: void showHelp(); rt300@27: void helpHidden(); rt300@42: void startTimedSession(); rt300@33: // shortcut function for testing rt300@33: void justStart(); rt300@36: void loadSequences(); rt300@46: int nextSequence(); rt300@24: rt300@24: void setupBottomGui(); rt300@24: void bottomGuiEvent(); rt300@24: void setupTopGui(); rt300@24: void topGuiEvent(); rt300@16: rt300@0: // stardard GUI - knbs and sliders - hides zoomer rt300@47: rt300@24: rt300@22: void sliderMoved(int which, float value); rt300@22: void setAllGUISliders(vector vals); rt300@25: void randomise(); rt300@0: rt300@0: // zoom gui - the swap view button and save preset button rt300@47: rt300@0: rt300@22: rt300@3: void sendParametersToPD(); rt300@3: void sendOscShape(int ctrlin); rt300@3: void sendFiltShape(int ctrlin); rt300@3: void sendFiltType(int ctrlin); rt300@3: void sendFiltFreq(int ctrlin); rt300@3: void sendEnvShape(int ctrlin); rt300@45: void sendResonance(int ctrlin); rt300@43: void sendAmpEnvShape(int ctrlin); rt300@43: void sendFiltEnvShape(int ctrlin); rt300@3: void sendModFreq(int ctrlin); rt300@45: void sendFMAmt(int ctrlin); rt300@45: void sendDistortion(int ctrlin); rt300@45: void sendRevAmt(int ctrlin); rt300@45: void sendFiltEnvModAmt(int ctrlin); rt300@45: rt300@39: void sendMidiParams(); rt300@39: void sendMidiParam(int which); rt300@0: rt300@2: // audio callbacks rt300@2: void audioReceived(float * input, int bufferSize, int nChannels); rt300@2: void audioRequested(float * output, int bufferSize, int nChannels); rt300@2: rt300@2: AppCore core; rt300@2: rt300@39: // message rt300@39: void addMessage(string msg); rt300@39: rt300@39: // midi message callback rt300@39: void newMidiMessage(ofxMidiMessage& msg); rt300@39: rt300@39: // midi device (dis)connection event callbacks rt300@39: void midiInputAdded(string name, bool isNetwork); rt300@39: void midiInputRemoved(string name, bool isNetwork); rt300@39: rt300@39: void midiOutputAdded(string nam, bool isNetwork); rt300@39: void midiOutputRemoved(string name, bool isNetwork); rt300@39: rt300@39: vector inputs; rt300@39: vector outputs; rt300@39: rt300@39: deque messages; rt300@39: int maxMessages; rt300@39: rt300@39: int note, ctl; rt300@39: vector bytes; rt300@39: rt300@45: void sendFiltTypeOld(int ctrlin); rt300@45: rt300@0: }; rt300@0: rt300@22: // should be off split into rt300@22: // GUI controller rt300@22: // parameter converter rt300@22: //