view 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
line wrap: on
line source
#pragma once

#include "ofMain.h"
#include "ofxiPhone.h"
#include "ofxiPhoneExtras.h"
#include "ofxiPhoneExternalDisplay.h"
#include "ofxOsc.h"
#include "ofxMidi.h"

#include "grid.h"
#include "2dvector.h"
#include "eventLogger.h"
#include "AppCore.h"

#include "presetManager.h"
#include "eventLogger.h"
#include "ofxPd.h"
#include "frequencer.h"

#include "json.h"

#import "QuestionnaireViewController.h"
#import "BottomTabViewController.h"
#import "IntroViewController.h"
#import "HelpViewController.h"
#import "TopButtonViewController.h"
#import "SliderViewController.h"
#import "usernameAlertViewController.h"
#import "TimedSessionController.h"

#define OSC_HOST "169.254.1.1"
#define OSC_PORT 12345

#define SLIDER_GUI_WIDTH 256
#define SLIDER_HEIGHT 256
#define NUM_PARAMS 10



class testApp : public ofxiPhoneApp , public ofxiPhoneExternalDisplay, public ofxMidiListener, public ofxMidiConnectionListener {

	
public:
    typedef enum {SLIDERS,ZOOMER,BOTH,INTRO,QUESTIONNAIRE, HELP}interfaceType;
    bool sendMIDIAndOSC;
    int midiChannel;
    int midiOffset;
    bool animatingGrid;
    bool allowAnimation;
    interfaceType whichInterfaceShowing;
    interfaceType previousInterface;
    BottomTabViewController *bottomTabViewController;
    UsernameAlertViewController *usernameAlertViewController;
    HelpViewController *helpViewController;
    QuestionnaireViewController * questionnaireViewController;
    IntroViewController * introViewController;
    TopButtonViewController * topButtonViewController;
    SliderViewController * sliderViewController;
    TimedSessionController * tsc;
    int prevTouchX;
    int prevTouchY;
    double prevDist;
    bool paused;
    // not many so dont bother with vectors/arrays?
    TwoVector touch0;
    TwoVector touch1;
    TwoVector prevTouch0;
    TwoVector prevTouch1;

    bool xLocked, yLocked;
    unsigned int lastMoveTime;
    
    TwoVector moveVel; // velocity at which we were moving the grid
    
    double slowFactor;
    double zoomVel; // do the same
     double prevZoom, prevZoom2;
     TwoVector move, prevMove, prevMove2;
    
    vector<int> sliderVals;
    vector<int> freqIndexes;
    vector<vector <int> > sequences;
    int currentSequence;
    
    int numActiveTouches;
    bool preventingMovePostScroll;
    void setInterp(int state);

    //
    
    void setup();
    void update();
    void draw();
    void exit();
    
    void initialiseVariables();
    void initialiseGUIs();
    void initialiseMIDI();

    float getWidth();
    float getHeight();
    
    void touchDown(ofTouchEventArgs &touch);
    void touchMoved(ofTouchEventArgs &touch);
    void touchUp(ofTouchEventArgs &touch);
    void touchDoubleTap(ofTouchEventArgs &touch);
    void touchCancelled(ofTouchEventArgs &touch);
    
    void handleScroll();
    void handleZoom();
    
    vector<float> vectorFilter(vector<float> newVec);
    
    void lostFocus();
    void gotFocus();
    void gotMemoryWarning();
    void deviceOrientationChanged(int newOrientation);
    
    bool tapFlag;
    ofxOscSender sender;
    void sendOSCParams();
    
    void setupNewUser();
    
    void lockSynthPressed(bool locked);
    void lockSequencerPressed(bool locked);
    
    void showQuestionnaire();
    void questionnaireHidden(vector<int> answers,  const char* userComments);
    void showIntro();
    void introHidden(bool OK);
    void interfaceSelected(int which);
    void freeUseMode();
    
    void seqStartStop(bool go);
    void showHelp();
    void helpHidden();
    void startTimedSession();
    // shortcut function for testing
    void justStart();
    void loadSequences();
    int nextSequence();
    
    void setupBottomGui();
    void bottomGuiEvent();
    void setupTopGui();
    void topGuiEvent();
    
    // stardard GUI - knbs and sliders - hides zoomer

    
    void sliderMoved(int which, float value);
    void setAllGUISliders(vector<int> vals);
    void randomise();
    
    // zoom gui - the swap view button and save preset button

    

    void sendParametersToPD();
    void sendOscShape(int ctrlin);
    void sendFiltShape(int ctrlin);
    void sendFiltType(int ctrlin);
    void sendFiltFreq(int ctrlin);
    void sendEnvShape(int ctrlin);
    void sendResonance(int ctrlin);
    void sendAmpEnvShape(int ctrlin);
    void sendFiltEnvShape(int ctrlin);
    void sendModFreq(int ctrlin);
    void sendFMAmt(int ctrlin);
    void sendDistortion(int ctrlin);
    void sendRevAmt(int ctrlin);
    void sendFiltEnvModAmt(int ctrlin);
    
    void sendMidiParams();
    void sendMidiParam(int which);
    
    // audio callbacks
	void audioReceived(float * input, int bufferSize, int nChannels);
	void audioRequested(float * output, int bufferSize, int nChannels);
    
    AppCore core;
    
    // message
    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 sendFiltTypeOld(int ctrlin);
    
};

// should be off split into
// GUI controller
// parameter converter
//