annotate newOFsrc/BayesDrumTracker.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 d880f7f29fbe
rev   line source
andrew@2 1 /*
andrew@2 2 * BayesDrumTracker.h
andrew@2 3 * bayesianTempoInitialiser5
andrew@2 4 *
andrew@2 5 * Created by Andrew on 14/07/2011.
andrew@2 6 * Copyright 2011 QMUL. All rights reserved.
andrew@2 7 *
andrew@2 8 */
andrew@2 9
andrew@2 10 #include "ofxOsc.h"
andrew@2 11 #include "bayesianArray.h"
andrew@2 12 #include "beatTempo.h"
andrew@2 13
andrew@2 14 class BayesDrumTracker{
andrew@2 15
andrew@2 16 #ifndef _BAYES_DRUM_TRACKER
andrew@2 17 #define _BAYES_DRUM_TRACKER
andrew@2 18 #define ARRAY_SIZE 240
andrew@2 19 //#define BAYES_ARRAY_SIZE 240
andrew@2 20
andrew@2 21 public:
andrew@2 22
andrew@2 23 BayesDrumTracker();
andrew@2 24 ~BayesDrumTracker();
andrew@2 25
andrew@2 26 void initialiseTracker();
andrew@2 27 void resetParameters();
andrew@2 28 void decayDistributions();//on update
andrew@2 29
andrew@2 30 void setBeatDistribution(int beatPosition);
andrew@2 31
andrew@2 32 void newKickError(const float& error, const double& cpuEventTime, const string& onsetTypeString);
andrew@2 33 void startTatum(const float& startTatum);
andrew@2 34 void setNewClickIndex(const int& clickIndex, const float& clickTime);
andrew@2 35 void sendMaxTempo();
andrew@2 36 void sendMaxPhase();
andrew@2 37 void newBeat(int& beatIndex);
andrew@2 38
andrew@2 39 void setUniformTempo();
andrew@2 40 void setUniformPhase();
andrew@2 41 void setBeatNow(const double& beatTime);
andrew@2 42 void doBeatCorrection(const float& beatCorrFloat);
andrew@2 43
andrew@2 44
andrew@2 45 bool filterBeatTime(double newBeatTime);
andrew@2 46 void crossUpdateArrays(float timeInterval);
andrew@2 47 bool updateTempoIfWithinRange(double timeInterval);
andrew@2 48 void calculateTempoUpdate(double tempoInterval);
andrew@2 49 void updateTempoProcess(const double& cpuTime, const string& onsetDescription);
andrew@2 50
andrew@2 51
andrew@2 52 float beatIndexToMsec(const int& index);
andrew@2 53 float tempoIndexToMsec(const int& index);
andrew@2 54
andrew@2 55
andrew@2 56 float kickError, snareError;
andrew@2 57 double cpuBeatTime;
andrew@2 58 float testArray[5];
andrew@2 59
andrew@2 60 double setBeatToNowTime;
andrew@2 61
andrew@2 62 float prior [ARRAY_SIZE];
andrew@2 63 float posterior [ARRAY_SIZE];
andrew@2 64 float likelihood [ARRAY_SIZE];
andrew@2 65 float likelihoodMean, likelihoodStdDev, likelihoodNoise, stepSize;
andrew@2 66 float maximumEstimate;
andrew@2 67 float maximumTest, posteriorDecayRate, maximumIndex;
andrew@2 68 float eighthNoteProportion;
andrew@2 69
andrew@2 70 bool paused;
andrew@2 71 double maxPhase, maxTempo;
andrew@2 72
andrew@2 73 float tmpArray[ARRAY_SIZE];
andrew@2 74
andrew@2 75 float correctionFactor;
andrew@2 76 float beatCorrection;
andrew@2 77 int correctBeatBy;
andrew@2 78
andrew@2 79 bayesianArray beatDistribution;
andrew@2 80 bayesianArray tempoDistribution;
andrew@2 81 double tempoMinimum, tempoMaximum;
andrew@2 82 double tempoInterval;
andrew@2 83 beatTempo beatTimes;
andrew@2 84
andrew@2 85 string onsetType;
andrew@2 86 string timeString;
andrew@2 87 //double cpuBeatTime;
andrew@2 88
andrew@2 89 ofxOscSender sender;
andrew@2 90
andrew@2 91 double posteriorMaximum;
andrew@2 92 bool adaptiveStandardDeviationMode;
andrew@2 93 double tempoStdDev;
andrew@2 94 bool accompanimentStarted;
andrew@2 95 bool setDistributionOnStartTempo;
andrew@2 96 int integerMultipleOfTatum;
andrew@2 97
andrew@2 98 double recentClickTime;
andrew@2 99
andrew@2 100 string kickString;//for info
andrew@2 101
andrew@2 102 float debugArray [4];
andrew@2 103 string tempoUpdateStrings[16];
andrew@2 104 string tempoDataString;
andrew@2 105 };
andrew@2 106
andrew@2 107 #endif