andrew@0: #ifndef _TEST_APP andrew@0: #define _TEST_APP andrew@0: andrew@0: andrew@0: andrew@0: #include "ofMain.h" andrew@0: #include "ofxOsc.h" andrew@0: //#include "bayesianArray.h" andrew@0: //#include "beatTempo.h" andrew@0: #include "BayesDrumTracker.h" andrew@0: andrew@0: // listen on port 12345 andrew@0: #define PORT 12345 andrew@0: #define NUM_MSG_STRINGS 45 andrew@0: #define HOST "localhost" andrew@0: #define ARRAY_SIZE 240//need to replace this with const int in drumtracker andrew@0: andrew@0: #define NUMBER_OF_SCREENS 8 andrew@0: andrew@0: class testApp : public ofBaseApp{ andrew@0: andrew@0: public: andrew@0: andrew@0: void setup(); andrew@0: void update(); andrew@0: void draw(); andrew@0: void drawBayesianDistribution(); andrew@0: void drawTempoData(); andrew@0: void drawTempoDistribution(); andrew@0: void drawRestrictedTempoDistribution(int tmpMin, int tmpMax); andrew@0: andrew@0: void drawBeatMap(); andrew@0: void drawNormalisedLikelihood(); andrew@0: void drawBeatProbabilityDistribution(); andrew@0: void drawPosterior(); andrew@0: void printBayesianData(); andrew@0: void drawGreyscaleBayesianDistribution(); andrew@0: void drawGreyscaleTempoDistribution(double tempoInterval); andrew@0: void drawTempoInfo(); andrew@0: andrew@0: void resetParameters(); andrew@0: void takePictureOfScreen(); andrew@0: andrew@0: void crossUpdateArrays(float timeInterval); andrew@0: void updateTempoProcess(double cpuTime, string onsetType); andrew@0: andrew@0: void sendMaxTempo(); andrew@0: void sendMaxPhase(); andrew@0: double convertToBPM(double interval); andrew@0: bool filterBeatTime(double newBeatTime); andrew@0: andrew@0: // float beatIndexToMsec(int index); andrew@0: // float tempoIndexToMsec(int index); andrew@0: andrew@0: void keyPressed(int key); andrew@0: void keyReleased(int key); andrew@0: void mouseMoved(int x, int y ); andrew@0: void mouseDragged(int x, int y, int button); andrew@0: void mousePressed(int x, int y, int button); andrew@0: void mouseReleased(int x, int y, int button); andrew@0: void windowResized(int w, int h); andrew@0: andrew@0: void setGaussianLikelihood(float mean, float StdDev); andrew@0: void setGaussianPrior(float mean, float StdDev); andrew@0: void calculatePosterior(); andrew@0: void renormalisePosterior(); andrew@0: float getMaximum(float *ptr, int length); andrew@0: void renormaliseArray(float *ptr, int length); andrew@0: void updateOSCmessages(); andrew@0: void resetPrior(); andrew@0: void decayPosterior(); andrew@0: void translateDistribution(int translationIndex); andrew@0: void setBeatDistribution(int beatPosition); andrew@0: void calculateTempoUpdate(double tempoInterval); andrew@0: bool updateTempoIfWithinRange(double timeInterval); andrew@0: andrew@0: float* getMaximumEstimate(float *ptr, int length); andrew@0: void drawTempoDataPoints(const int& tmpMin, const int& tmpMax, const float& tmpStepSize); andrew@0: int xcoordinateFromTempoDataPoint(float f); andrew@0: int xcoordinateFromRestrictedTempoDataPoint(float f, const int& tmpMin, const int& tmpMax); andrew@0: andrew@0: float arrayToMsecScaleFactor;// = (tempoMaximum - tempoMinimum)/ ARRAY_SIZE;//turns array into ms andrew@0: andrew@0: andrew@0: andrew@0: int tempoWindowMinimum, tempoWindowMaximum, tempoWindowWidth; andrew@0: andrew@0: ofTrueTypeFont font; andrew@0: andrew@0: ofxOscReceiver receiver; andrew@0: string msg_string, debugString, kickString; andrew@0: andrew@0: bool bSmooth; andrew@0: // float kickError, snareError; andrew@0: // float testArray[5]; andrew@0: andrew@0: // float prior [ARRAY_SIZE]; andrew@0: // float posterior [ARRAY_SIZE]; andrew@0: // float likelihood [ARRAY_SIZE]; andrew@0: // float likelihoodMean, likelihoodStdDev, likelihoodNoise, stepSize; andrew@0: // float maximumEstimate; andrew@0: // float maximumTest, posteriorDecayRate, maximumIndex; andrew@0: // float eighthNoteProportion; andrew@0: andrew@0: float stepSize; andrew@0: int screenWidth, screenHeight; andrew@0: andrew@0: bool printInterval, paused; andrew@0: bool drawData, hidePriorMode; andrew@0: andrew@0: andrew@0: /* andrew@0: bayesianArray beatDistribution; andrew@0: andrew@0: double tempoMinimum, tempoMaximum; andrew@0: double tempoInterval; andrew@0: beatTempo beatTimes; andrew@0: */ andrew@0: //double tempoInterval; andrew@0: float mouseBPM; andrew@0: // int correctBeatBy; andrew@0: // string tempoUpdateStrings[16]; andrew@0: // string tempoDataString; andrew@0: andrew@0: private: andrew@0: andrew@0: // ofxOscSender sender; andrew@0: andrew@0: //float noiseFactor, stdDevFactor; andrew@0: // int minTmpDebug, maxTmpDebug; andrew@0: andrew@0: // float correctionFactor; andrew@0: andrew@0: andrew@0: andrew@0: // string onsetType; andrew@0: // string timeString; andrew@0: // double cpuBeatTime; andrew@0: andrew@0: // double cpuClockTime; andrew@0: int screenToDraw; andrew@0: // double posteriorMaximum; andrew@0: // bool adaptiveStandardDeviationMode; andrew@0: andrew@0: bool bSnapshot; andrew@0: int snapCounter; andrew@0: ofImage img; andrew@0: andrew@0: // double tempoStdDev; andrew@0: // bool accompanimentStarted; andrew@0: // bool setDistributionOnStartTempo; andrew@0: // int integerMultipleOfTatum; andrew@0: andrew@0: BayesDrumTracker drumTracker; andrew@0: andrew@0: }; andrew@0: andrew@0: #endif andrew@0: