view 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
line wrap: on
line source
// oF 084
// V 1.3sonic

#ifndef _TEST_APP
#define _TEST_APP

#include "ofMain.h"


#include "ofxiOS.h"
#include "ofxiOSExtras.h"

#include "2dvector.h"
#include "lump.h"
#include "spring.h"
#include <iostream>
#include "mesh.h"
#include "dsptools.h"

#include "ofxUI.h"
#include "ofxOsc.h"
#include "ofxMidi.h"
#include "globalForces.h"
#include "globalUI.h"

#include "json.h"
#import "PresetAlertViewController.h"
#define SAMPLE_RATE 44100
// listen on port 12345
#define INPORT 12345
#define OUTPORT 54321
#define HOST "192.168.1.3"
#define NUM_MSG_STRINGS 20

// defining this compiles it for ios otherwise osx
#define IPAD



class testApp : public ofxiOSApp, public ofxMidiListener, public ofxMidiConnectionListener {
	
public:
    int timesOpened;
	bool audioOn;
	bool drawingOn;
    bool controlsShowing;
	int presetSaveNumber;
	bool paused;
    //bool inscribeScanPathMode;
    bool OscOK;
    // crappy pseudo mutex
	bool audioAccessFlag;
    bool meshConstructionFlag;
    
	Mesh *theMesh;
    
    DSPTools mydspTools;
	
	double timeStep;
    
    double pitch;
    double phasorIncr;
    


    int numTouches;

	void setup();
	void update();
	void draw();
    void exit();
    
    void loadLogXML();
    void saveLogXML();

	void touchDown(ofTouchEventArgs &touch);
	void touchMoved(ofTouchEventArgs &touch);
	void touchUp(ofTouchEventArgs &touch);
	void touchDoubleTap(ofTouchEventArgs &touch);
    void addTouch();
    void removeTouch();
    
    void UIcallBack(int buttID);
    void showControls();
    void hideControls();
   
	void keyPressed  (int key);
	void keyReleased(int key);
	void mouseMoved(int x, int y );
	void mouseDragged(int x, int y, int button);
	void mousePressed(int x, int y, int button);
	void mouseReleased(int x, int y, int button);

    void restartAudioStream();
	void audioRequested 	(float * input, int bufferSize, int nChannels);
    void audioReceived(float * input, int bufferSize, int nChannels);
    //void deviceOrientationChanged(int newOrientation);
    void handleMessages();
    void drawMessages();
    
    void setupMesh();
    void regenerateMesh(string meshType, int dim1 = 3, int dim2 = 3);
    void deleteMesh();

    Json::Value convertToJsonForSaving();
    void savePreset(const string name);
    void constructPresetFromJson(Json::Value& presetJson);
    void  loadPreset();
    Json::Value loadPresetFile();
    
    ofxOscReceiver	receiver;
    ofxOscSender sender;
    ofTrueTypeFont		font;
  
    int				current_msg_string;
    string		msg_strings[NUM_MSG_STRINGS];
    float			timers[NUM_MSG_STRINGS];
    
    int				mouseX, mouseY;
    string			mouseButtonState;
    
    ofxiPhoneKeyboard * keyboard;
    
    // ofxUI stuff
    
    ofxUICanvas *guiL;
    ofxUICanvas *guiR;
    ofxUICanvas *guiSH;
    void guiLEvent(ofxUIEventArgs &e);
    void guiREvent(ofxUIEventArgs &e);
    void guiSHEvent(ofxUIEventArgs &e);
    void setupGui();
    void drawSidePanels();
    
    ofxUILabel *counter;
    
    void showPresetNameDialog();
    
    //---------------------------------
    // MIDI STUFF
    // message
    void initialiseMidi();
    int midiChannel; // what channel are we recieving on?
    
    void addMessage(string msg);
	
	// midi message callback
	void newMidiMessage(ofxMidiMessage& msg);
	
	// midi device (dis)connection event callbacks
	void midiInputAdded(string name, bool isNetwork);
	void midiInputRemoved(string name, bool isNetwork);
	
	void midiOutputAdded(string nam, bool isNetwork);
	void midiOutputRemoved(string name, bool isNetwork);
    
	vector<ofxMidiIn*> inputs;
	vector<ofxMidiOut*> outputs;
    
	deque<string> messages;
	int maxMessages;
	
	int note, ctl;
	vector<unsigned char> bytes;
    
    void deviceOrientationChanged(int newOrientation);
    
};	



#endif