view testApp.h @ 38:fea11c3d1d94

tweaking endlessly
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Thu, 04 Dec 2014 17:03:01 +0000
parents 75202498bee9
children 80112c9349c4
line wrap: on
line source
#pragma once

#include "ofMain.h"

//#include "ofxiPhone.h"
//#include "ofxiPhoneExtras.h"
// #include "ofxiPhoneExternalDisplay.h"

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

#include "ofxOsc.h"
#include "ofxMidi.h"
#include "2dvector.h"
#include "AppCore.h"
#include "eventLogger.h"
#include "ofxPd.h"
#include "json.h"
#import "QuestionnaireViewController.h"
#import "HelpViewController.h"
#import "UsernameAlertViewController.h"
#import "IntroViewController.h"
#include "sliderPanel.h"
#include "UIElement.h"
#include "UIElementContainer.h"
#include "buttron.h"
#include "ButtronSlider.h"
#include "buttronXY.h"
#include "UIGrid.h"
#include "MessageOrganiser.h"
#include "SearchMessageOrganiser.h"
#include "TrainingMessageOrganiser.h"
#include "ExpMessageOrganiser.h"
#include "timeController.h"
#include <buttonPanel.h>
#include "targetSymbol.h"
#include "3Dbox.h"
#include "6Dbox.h"
#include "TextPanel.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 ofxiOSApp , public ofxMidiListener, public ofxMidiConnectionListener {

	
public:

    testStages currentStage;
    
    ofTrueTypeFont verdBig;
    bool sendMIDIAndOSC;
    bool paused;
    
    int midiChannel;
    int midiOffset;
    double tx,ty;
    ofColor generalBackground;
    //
    void initialiseGUIs();
    void initialiseVariables();
    void initialiseMIDI();
    void setupUIElements();
    void setupExpressViewPanels();
    void setupTrainingViewPanels();
    void setupSearchViewPanels();
    void setupSliderPanel();
    void setup();
    void update();
    void draw();
    void drawUIElements();
    void exit();
    void backToMainMenu();
    HelpViewController *helpViewController;
    QuestionnaireViewController *questionnaireViewController;
    UsernameAlertViewController *usernameAlertViewController;
    IntroViewController * introViewController;
    
    SearchMessageOrganiser searchMessageOrganiser;
    TrainingMessageOrganiser trainingMessageOrganiser;
    ExpMessageOrganiser expMessageOrganiser;
    
    PDSynthWrapper targetSynth;
    PDSynthWrapper candidateSynth;

    //TimeController timeController;
    interfaceType whichInterfaceShowing, previousInterface;
    
    // various views
    vector<UIElement *> UIElements;
    vector<UIElement *> AnimatedUIElements;
    
    void touchToUIElements(int x, int y, touchType ttype, int tid);
    void touchDown(ofTouchEventArgs &touch);
    void touchMoved(ofTouchEventArgs &touch);
    void touchUp(ofTouchEventArgs &touch);
    void touchDoubleTap(ofTouchEventArgs &touch);
    void touchCancelled(ofTouchEventArgs &touch);
    double ofFixGetWidth();
    double ofFixGetHeight();
    ofTouchEventArgs transformTouchCoords(ofTouchEventArgs &point);
    ofLight light;
    UIProps* props;
    void lostFocus();
    void gotFocus();
    void gotMemoryWarning();
    void deviceOrientationChanged(int newOrientation);

//    ofxOscSender sender;
//    void sendOSCParams();

    void showQuestionnaire();
    void questionnaireHidden(vector<int> answers,  const char* userComments);

    void showIntro();
    void introHidden(int mode);
    void usernameEntered();
    void startTheSearchTests();
    void startTheTrainingTests();
    void startTheExpTests();
    void startThePerformanceTests();
    void showHelp();
    void helpHidden();
    void setupNewUser();
    void appModeChange(interfaceType mode);
    void interfaceSelected(int interfaceSelection);
    void sendParametersToPD();
    
    void sendMidiParams();
    void sendMidiParam(int which);
    
    // audio callbacks
    float *  wavetableNew;
    int bufSize;
    void drawWaveform();
    void drawScore();
	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);
    void mapButtonToAction(UIElement* control, int mappingID);
     void buttonPressCallback(int mappingID, int value);
    
	vector<ofxMidiIn*> inputs;
	vector<ofxMidiOut*> outputs;
    
	deque<string> messages;
	int maxMessages;
	
	int note, ctl;
	vector<unsigned char> bytes;
    
    // in the h file:
    ofTrueTypeFont myfont;

    void windowResized(int w, int h){};
    
    void rotateToPortrait(){};
    void rotateToPortraitUpSideDown(){};
    void rotateToLandscapeLeft(){};
    void rotateToLandscapeRight(){};
    void toggleAutoRotation(){};

    controlPanelType whichInterfaceAreWeUsing;
};

// should be off split into
// GUI controller
// parameter converter
// MIDI stuff(?)