andrew@0: /* andrew@0: * BayesDrumTracker.h andrew@0: * bayesianTempoInitialiser5 andrew@0: * andrew@0: * Created by Andrew on 14/07/2011. andrew@0: * Copyright 2011 QMUL. All rights reserved. andrew@0: * andrew@0: */ andrew@0: andrew@0: #include "ofxOsc.h" andrew@0: #include "bayesianArray.h" andrew@0: #include "beatTempo.h" andrew@0: andrew@0: class BayesDrumTracker{ andrew@0: andrew@0: #ifndef _BAYES_DRUM_TRACKER andrew@0: #define _BAYES_DRUM_TRACKER andrew@0: #define ARRAY_SIZE 240 andrew@0: //#define BAYES_ARRAY_SIZE 240 andrew@0: andrew@0: public: andrew@0: andrew@0: BayesDrumTracker(); andrew@0: ~BayesDrumTracker(); andrew@0: andrew@0: void initialiseTracker(); andrew@0: void resetParameters(); andrew@0: void decayDistributions();//on update andrew@0: andrew@0: void setBeatDistribution(int beatPosition); andrew@0: andrew@0: void newKickError(const float& error, const double& cpuEventTime, const string& onsetTypeString); andrew@0: void startTatum(const float& startTatum); andrew@0: void setNewClickIndex(const int& clickIndex, const float& clickTime); andrew@0: void sendMaxTempo(); andrew@0: void sendMaxPhase(); andrew@0: void newBeat(int& beatIndex); andrew@0: andrew@0: void setUniformTempo(); andrew@0: void setUniformPhase(); andrew@0: void setBeatNow(const double& beatTime); andrew@0: void doBeatCorrection(const float& beatCorrFloat); andrew@0: andrew@0: andrew@0: bool filterBeatTime(double newBeatTime); andrew@0: void crossUpdateArrays(float timeInterval); andrew@0: bool updateTempoIfWithinRange(double timeInterval); andrew@0: void calculateTempoUpdate(double tempoInterval); andrew@0: void updateTempoProcess(const double& cpuTime, const string& onsetDescription); andrew@0: andrew@0: andrew@0: float beatIndexToMsec(const int& index); andrew@0: float tempoIndexToMsec(const int& index); andrew@0: andrew@0: andrew@0: float kickError, snareError; andrew@0: double cpuBeatTime; andrew@0: float testArray[5]; andrew@0: andrew@0: double setBeatToNowTime; 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: bool paused; andrew@0: double maxPhase, maxTempo; andrew@0: andrew@0: float tmpArray[ARRAY_SIZE]; andrew@0: andrew@0: float correctionFactor; andrew@0: float beatCorrection; andrew@0: int correctBeatBy; andrew@0: andrew@0: bayesianArray beatDistribution; andrew@0: bayesianArray tempoDistribution; andrew@0: double tempoMinimum, tempoMaximum; andrew@0: double tempoInterval; andrew@0: beatTempo beatTimes; andrew@0: andrew@0: string onsetType; andrew@0: string timeString; andrew@0: //double cpuBeatTime; andrew@0: andrew@0: ofxOscSender sender; andrew@0: andrew@0: double posteriorMaximum; andrew@0: bool adaptiveStandardDeviationMode; andrew@0: double tempoStdDev; andrew@0: bool accompanimentStarted; andrew@0: bool setDistributionOnStartTempo; andrew@0: int integerMultipleOfTatum; andrew@0: andrew@0: double recentClickTime; andrew@0: andrew@0: string kickString;//for info andrew@0: andrew@0: float debugArray [4]; andrew@0: string tempoUpdateStrings[16]; andrew@0: string tempoDataString; andrew@0: }; andrew@0: andrew@0: #endif