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