rt300@15: // oF 084 rt300@15: // V 1.3sonic rt300@0: rt300@0: #ifndef _TEST_APP rt300@0: #define _TEST_APP rt300@0: rt300@0: #include "ofMain.h" rt300@15: rt300@15: rt300@15: #include "ofxiOS.h" rt300@15: #include "ofxiOSExtras.h" rt300@0: rt300@0: #include "2dvector.h" rt300@0: #include "lump.h" rt300@0: #include "spring.h" rt300@0: #include rt300@0: #include "mesh.h" rt300@0: #include "dsptools.h" rt300@0: rt300@0: #include "ofxUI.h" rt300@0: #include "ofxOsc.h" rt300@10: #include "ofxMidi.h" rt300@0: #include "globalForces.h" rt300@0: #include "globalUI.h" rt300@0: rt300@8: #include "json.h" rt300@10: #import "PresetAlertViewController.h" rt300@0: #define SAMPLE_RATE 44100 rt300@0: // listen on port 12345 rt300@0: #define INPORT 12345 rt300@0: #define OUTPORT 54321 rt300@0: #define HOST "192.168.1.3" rt300@0: #define NUM_MSG_STRINGS 20 rt300@0: rt300@0: // defining this compiles it for ios otherwise osx rt300@0: #define IPAD rt300@0: rt300@0: rt300@0: rt300@15: class testApp : public ofxiOSApp, public ofxMidiListener, public ofxMidiConnectionListener { rt300@0: rt300@0: public: rt300@0: int timesOpened; rt300@0: bool audioOn; rt300@0: bool drawingOn; rt300@8: bool controlsShowing; rt300@10: int presetSaveNumber; rt300@0: bool paused; rt300@0: //bool inscribeScanPathMode; rt300@14: bool OscOK; rt300@1: // crappy pseudo mutex rt300@1: bool audioAccessFlag; rt300@1: bool meshConstructionFlag; rt300@1: rt300@0: Mesh *theMesh; rt300@0: rt300@0: DSPTools mydspTools; rt300@0: rt300@0: double timeStep; rt300@0: rt300@0: double pitch; rt300@0: double phasorIncr; rt300@0: rt300@0: rt300@0: rt300@0: int numTouches; rt300@0: rt300@0: void setup(); rt300@0: void update(); rt300@0: void draw(); rt300@0: void exit(); rt300@0: rt300@0: void loadLogXML(); rt300@0: void saveLogXML(); rt300@0: rt300@0: void touchDown(ofTouchEventArgs &touch); rt300@0: void touchMoved(ofTouchEventArgs &touch); rt300@0: void touchUp(ofTouchEventArgs &touch); rt300@0: void touchDoubleTap(ofTouchEventArgs &touch); rt300@0: void addTouch(); rt300@0: void removeTouch(); rt300@0: rt300@0: void UIcallBack(int buttID); rt300@15: void showControls(); rt300@15: void hideControls(); rt300@0: rt300@0: void keyPressed (int key); rt300@0: void keyReleased(int key); rt300@0: void mouseMoved(int x, int y ); rt300@0: void mouseDragged(int x, int y, int button); rt300@0: void mousePressed(int x, int y, int button); rt300@0: void mouseReleased(int x, int y, int button); rt300@0: rt300@0: void restartAudioStream(); rt300@0: void audioRequested (float * input, int bufferSize, int nChannels); rt300@0: void audioReceived(float * input, int bufferSize, int nChannels); rt300@8: //void deviceOrientationChanged(int newOrientation); rt300@0: void handleMessages(); rt300@0: void drawMessages(); rt300@0: rt300@0: void setupMesh(); rt300@0: void regenerateMesh(string meshType, int dim1 = 3, int dim2 = 3); rt300@0: void deleteMesh(); rt300@0: rt300@8: Json::Value convertToJsonForSaving(); rt300@12: void savePreset(const string name); rt300@9: void constructPresetFromJson(Json::Value& presetJson); rt300@9: void loadPreset(); rt300@9: Json::Value loadPresetFile(); rt300@8: rt300@0: ofxOscReceiver receiver; rt300@0: ofxOscSender sender; rt300@0: ofTrueTypeFont font; rt300@0: rt300@0: int current_msg_string; rt300@0: string msg_strings[NUM_MSG_STRINGS]; rt300@0: float timers[NUM_MSG_STRINGS]; rt300@0: rt300@0: int mouseX, mouseY; rt300@0: string mouseButtonState; rt300@0: rt300@0: ofxiPhoneKeyboard * keyboard; rt300@0: rt300@0: // ofxUI stuff rt300@0: rt300@0: ofxUICanvas *guiL; rt300@0: ofxUICanvas *guiR; rt300@8: ofxUICanvas *guiSH; rt300@0: void guiLEvent(ofxUIEventArgs &e); rt300@0: void guiREvent(ofxUIEventArgs &e); rt300@8: void guiSHEvent(ofxUIEventArgs &e); rt300@0: void setupGui(); rt300@0: void drawSidePanels(); rt300@0: rt300@0: ofxUILabel *counter; rt300@10: rt300@12: void showPresetNameDialog(); rt300@12: rt300@10: //--------------------------------- rt300@10: // MIDI STUFF rt300@10: // message rt300@12: void initialiseMidi(); rt300@10: int midiChannel; // what channel are we recieving on? rt300@10: rt300@10: void addMessage(string msg); rt300@10: rt300@10: // midi message callback rt300@10: void newMidiMessage(ofxMidiMessage& msg); rt300@10: rt300@10: // midi device (dis)connection event callbacks rt300@10: void midiInputAdded(string name, bool isNetwork); rt300@10: void midiInputRemoved(string name, bool isNetwork); rt300@10: rt300@10: void midiOutputAdded(string nam, bool isNetwork); rt300@10: void midiOutputRemoved(string name, bool isNetwork); rt300@10: rt300@10: vector inputs; rt300@10: vector outputs; rt300@10: rt300@10: deque messages; rt300@10: int maxMessages; rt300@10: rt300@10: int note, ctl; rt300@10: vector bytes; rt300@10: rt300@13: void deviceOrientationChanged(int newOrientation); rt300@13: rt300@0: }; rt300@0: rt300@0: rt300@0: rt300@0: #endif