annotate testApp.h @ 15:d5758530a039 tip

oF0.84 Retina, and iPhone support
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Tue, 12 May 2015 15:48:52 +0100
parents 4ba81a12b008
children
rev   line source
rt300@15 1 // oF 084
rt300@15 2 // V 1.3sonic
rt300@0 3
rt300@0 4 #ifndef _TEST_APP
rt300@0 5 #define _TEST_APP
rt300@0 6
rt300@0 7 #include "ofMain.h"
rt300@15 8
rt300@15 9
rt300@15 10 #include "ofxiOS.h"
rt300@15 11 #include "ofxiOSExtras.h"
rt300@0 12
rt300@0 13 #include "2dvector.h"
rt300@0 14 #include "lump.h"
rt300@0 15 #include "spring.h"
rt300@0 16 #include <iostream>
rt300@0 17 #include "mesh.h"
rt300@0 18 #include "dsptools.h"
rt300@0 19
rt300@0 20 #include "ofxUI.h"
rt300@0 21 #include "ofxOsc.h"
rt300@10 22 #include "ofxMidi.h"
rt300@0 23 #include "globalForces.h"
rt300@0 24 #include "globalUI.h"
rt300@0 25
rt300@8 26 #include "json.h"
rt300@10 27 #import "PresetAlertViewController.h"
rt300@0 28 #define SAMPLE_RATE 44100
rt300@0 29 // listen on port 12345
rt300@0 30 #define INPORT 12345
rt300@0 31 #define OUTPORT 54321
rt300@0 32 #define HOST "192.168.1.3"
rt300@0 33 #define NUM_MSG_STRINGS 20
rt300@0 34
rt300@0 35 // defining this compiles it for ios otherwise osx
rt300@0 36 #define IPAD
rt300@0 37
rt300@0 38
rt300@0 39
rt300@15 40 class testApp : public ofxiOSApp, public ofxMidiListener, public ofxMidiConnectionListener {
rt300@0 41
rt300@0 42 public:
rt300@0 43 int timesOpened;
rt300@0 44 bool audioOn;
rt300@0 45 bool drawingOn;
rt300@8 46 bool controlsShowing;
rt300@10 47 int presetSaveNumber;
rt300@0 48 bool paused;
rt300@0 49 //bool inscribeScanPathMode;
rt300@14 50 bool OscOK;
rt300@1 51 // crappy pseudo mutex
rt300@1 52 bool audioAccessFlag;
rt300@1 53 bool meshConstructionFlag;
rt300@1 54
rt300@0 55 Mesh *theMesh;
rt300@0 56
rt300@0 57 DSPTools mydspTools;
rt300@0 58
rt300@0 59 double timeStep;
rt300@0 60
rt300@0 61 double pitch;
rt300@0 62 double phasorIncr;
rt300@0 63
rt300@0 64
rt300@0 65
rt300@0 66 int numTouches;
rt300@0 67
rt300@0 68 void setup();
rt300@0 69 void update();
rt300@0 70 void draw();
rt300@0 71 void exit();
rt300@0 72
rt300@0 73 void loadLogXML();
rt300@0 74 void saveLogXML();
rt300@0 75
rt300@0 76 void touchDown(ofTouchEventArgs &touch);
rt300@0 77 void touchMoved(ofTouchEventArgs &touch);
rt300@0 78 void touchUp(ofTouchEventArgs &touch);
rt300@0 79 void touchDoubleTap(ofTouchEventArgs &touch);
rt300@0 80 void addTouch();
rt300@0 81 void removeTouch();
rt300@0 82
rt300@0 83 void UIcallBack(int buttID);
rt300@15 84 void showControls();
rt300@15 85 void hideControls();
rt300@0 86
rt300@0 87 void keyPressed (int key);
rt300@0 88 void keyReleased(int key);
rt300@0 89 void mouseMoved(int x, int y );
rt300@0 90 void mouseDragged(int x, int y, int button);
rt300@0 91 void mousePressed(int x, int y, int button);
rt300@0 92 void mouseReleased(int x, int y, int button);
rt300@0 93
rt300@0 94 void restartAudioStream();
rt300@0 95 void audioRequested (float * input, int bufferSize, int nChannels);
rt300@0 96 void audioReceived(float * input, int bufferSize, int nChannels);
rt300@8 97 //void deviceOrientationChanged(int newOrientation);
rt300@0 98 void handleMessages();
rt300@0 99 void drawMessages();
rt300@0 100
rt300@0 101 void setupMesh();
rt300@0 102 void regenerateMesh(string meshType, int dim1 = 3, int dim2 = 3);
rt300@0 103 void deleteMesh();
rt300@0 104
rt300@8 105 Json::Value convertToJsonForSaving();
rt300@12 106 void savePreset(const string name);
rt300@9 107 void constructPresetFromJson(Json::Value& presetJson);
rt300@9 108 void loadPreset();
rt300@9 109 Json::Value loadPresetFile();
rt300@8 110
rt300@0 111 ofxOscReceiver receiver;
rt300@0 112 ofxOscSender sender;
rt300@0 113 ofTrueTypeFont font;
rt300@0 114
rt300@0 115 int current_msg_string;
rt300@0 116 string msg_strings[NUM_MSG_STRINGS];
rt300@0 117 float timers[NUM_MSG_STRINGS];
rt300@0 118
rt300@0 119 int mouseX, mouseY;
rt300@0 120 string mouseButtonState;
rt300@0 121
rt300@0 122 ofxiPhoneKeyboard * keyboard;
rt300@0 123
rt300@0 124 // ofxUI stuff
rt300@0 125
rt300@0 126 ofxUICanvas *guiL;
rt300@0 127 ofxUICanvas *guiR;
rt300@8 128 ofxUICanvas *guiSH;
rt300@0 129 void guiLEvent(ofxUIEventArgs &e);
rt300@0 130 void guiREvent(ofxUIEventArgs &e);
rt300@8 131 void guiSHEvent(ofxUIEventArgs &e);
rt300@0 132 void setupGui();
rt300@0 133 void drawSidePanels();
rt300@0 134
rt300@0 135 ofxUILabel *counter;
rt300@10 136
rt300@12 137 void showPresetNameDialog();
rt300@12 138
rt300@10 139 //---------------------------------
rt300@10 140 // MIDI STUFF
rt300@10 141 // message
rt300@12 142 void initialiseMidi();
rt300@10 143 int midiChannel; // what channel are we recieving on?
rt300@10 144
rt300@10 145 void addMessage(string msg);
rt300@10 146
rt300@10 147 // midi message callback
rt300@10 148 void newMidiMessage(ofxMidiMessage& msg);
rt300@10 149
rt300@10 150 // midi device (dis)connection event callbacks
rt300@10 151 void midiInputAdded(string name, bool isNetwork);
rt300@10 152 void midiInputRemoved(string name, bool isNetwork);
rt300@10 153
rt300@10 154 void midiOutputAdded(string nam, bool isNetwork);
rt300@10 155 void midiOutputRemoved(string name, bool isNetwork);
rt300@10 156
rt300@10 157 vector<ofxMidiIn*> inputs;
rt300@10 158 vector<ofxMidiOut*> outputs;
rt300@10 159
rt300@10 160 deque<string> messages;
rt300@10 161 int maxMessages;
rt300@10 162
rt300@10 163 int note, ctl;
rt300@10 164 vector<unsigned char> bytes;
rt300@10 165
rt300@13 166 void deviceOrientationChanged(int newOrientation);
rt300@13 167
rt300@0 168 };
rt300@0 169
rt300@0 170
rt300@0 171
rt300@0 172 #endif