diff newOFsrc/testApp.h @ 2:c49a8f33afab

adding new OF source
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Wed, 22 Feb 2012 22:16:48 +0000
parents
children 6565c7cb9c71
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/newOFsrc/testApp.h	Wed Feb 22 22:16:48 2012 +0000
@@ -0,0 +1,160 @@
+#ifndef _TEST_APP
+#define _TEST_APP
+
+
+
+#include "ofMain.h"
+#include "ofxOsc.h"
+//#include "bayesianArray.h"
+//#include "beatTempo.h"
+#include "BayesDrumTracker.h"
+
+// listen on port 12345
+#define PORT 12345
+#define NUM_MSG_STRINGS 45
+#define HOST "localhost"
+#define ARRAY_SIZE 240//need to replace this with const int in drumtracker
+
+#define NUMBER_OF_SCREENS 8
+
+class testApp : public ofBaseApp{
+	
+	public:
+		
+		void setup();
+		void update();
+		void draw();
+		void drawBayesianDistribution();
+		void drawTempoData();
+		void drawTempoDistribution();
+		void drawRestrictedTempoDistribution(int tmpMin, int tmpMax);
+	
+		void drawBeatMap();
+		void drawNormalisedLikelihood();
+		void drawBeatProbabilityDistribution();
+		void drawPosterior();
+		void printBayesianData();
+		void drawGreyscaleBayesianDistribution();
+	void drawGreyscaleTempoDistribution(double tempoInterval);
+		void drawTempoInfo();
+	
+		void resetParameters();
+		void takePictureOfScreen();
+	
+		void crossUpdateArrays(float timeInterval);
+		void updateTempoProcess(double cpuTime, string onsetType);
+		
+		void sendMaxTempo();
+		void sendMaxPhase();
+		double convertToBPM(double interval);
+		bool filterBeatTime(double newBeatTime);
+		
+//		float beatIndexToMsec(int index);
+//		float tempoIndexToMsec(int index);
+		
+		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 windowResized(int w, int h);
+	
+		void setGaussianLikelihood(float mean, float StdDev);	
+		void setGaussianPrior(float mean, float StdDev);	
+		void calculatePosterior();
+		void renormalisePosterior();
+		float getMaximum(float *ptr, int length);
+		void renormaliseArray(float *ptr, int length);
+		void updateOSCmessages();
+		void resetPrior();
+		void decayPosterior();
+		void translateDistribution(int translationIndex);
+		void setBeatDistribution(int beatPosition);
+		void calculateTempoUpdate(double tempoInterval);
+		bool updateTempoIfWithinRange(double timeInterval);
+		
+		float* getMaximumEstimate(float *ptr, int length);
+		void drawTempoDataPoints(const int& tmpMin, const int& tmpMax, const float& tmpStepSize);
+		int xcoordinateFromTempoDataPoint(float f);
+		int xcoordinateFromRestrictedTempoDataPoint(float f, const int& tmpMin, const int& tmpMax);
+	
+		float arrayToMsecScaleFactor;// = (tempoMaximum - tempoMinimum)/ ARRAY_SIZE;//turns array into ms
+	
+	
+	
+		int tempoWindowMinimum, tempoWindowMaximum, tempoWindowWidth;
+	
+		ofTrueTypeFont		font;
+		
+		ofxOscReceiver	receiver;
+		string msg_string, debugString, kickString;
+
+		bool	bSmooth;
+	//	float kickError, snareError;
+	//	float testArray[5];
+		
+	//	float prior [ARRAY_SIZE];
+	//	float posterior [ARRAY_SIZE];
+	//	float likelihood [ARRAY_SIZE];
+	//	float likelihoodMean, likelihoodStdDev, likelihoodNoise, stepSize;
+	//	float maximumEstimate;	
+	//	float maximumTest, posteriorDecayRate, maximumIndex;
+	//	float eighthNoteProportion;
+	
+		float stepSize;
+		int screenWidth, screenHeight;
+	
+		bool printInterval, paused;
+		bool drawData, hidePriorMode;
+
+	
+	/*
+		bayesianArray beatDistribution;
+		
+		double tempoMinimum, tempoMaximum;
+				double tempoInterval;
+		beatTempo	beatTimes;
+*/
+	//double tempoInterval;
+		float mouseBPM;
+//		int correctBeatBy;
+//		string tempoUpdateStrings[16];
+//		string tempoDataString;
+
+	double KLdiv;
+	private:
+
+	//	ofxOscSender sender;
+		
+		//float noiseFactor, stdDevFactor;
+	//	int minTmpDebug, maxTmpDebug;
+		
+	//	float correctionFactor;
+		
+	
+			
+//			string onsetType;
+//			string timeString;
+//			double cpuBeatTime;
+		
+//			double cpuClockTime;
+			int screenToDraw;
+//	double posteriorMaximum;
+//	bool adaptiveStandardDeviationMode;
+	
+	bool bSnapshot;
+	int snapCounter;
+	ofImage img;
+
+	//	double tempoStdDev;
+//	bool accompanimentStarted;
+//	bool setDistributionOnStartTempo;
+//	int integerMultipleOfTatum;
+	
+	BayesDrumTracker drumTracker;
+	
+};
+
+#endif
+