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@10
|
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@10
|
62 static const int arraySize = 240;
|
andrew@10
|
63
|
andrew@10
|
64 float prior [arraySize];
|
andrew@10
|
65 float posterior [arraySize];
|
andrew@10
|
66 float likelihood [arraySize];
|
andrew@2
|
67 float likelihoodMean, likelihoodStdDev, likelihoodNoise, stepSize;
|
andrew@2
|
68 float maximumEstimate;
|
andrew@2
|
69 float maximumTest, posteriorDecayRate, maximumIndex;
|
andrew@2
|
70 float eighthNoteProportion;
|
andrew@2
|
71
|
andrew@2
|
72 bool paused;
|
andrew@2
|
73 double maxPhase, maxTempo;
|
andrew@2
|
74
|
andrew@10
|
75 float tmpArray[arraySize];
|
andrew@2
|
76
|
andrew@2
|
77 float correctionFactor;
|
andrew@2
|
78 float beatCorrection;
|
andrew@2
|
79 int correctBeatBy;
|
andrew@2
|
80
|
andrew@2
|
81 bayesianArray beatDistribution;
|
andrew@2
|
82 bayesianArray tempoDistribution;
|
andrew@2
|
83 double tempoMinimum, tempoMaximum;
|
andrew@2
|
84 double tempoInterval;
|
andrew@2
|
85 beatTempo beatTimes;
|
andrew@2
|
86
|
andrew@2
|
87 string onsetType;
|
andrew@2
|
88 string timeString;
|
andrew@2
|
89 //double cpuBeatTime;
|
andrew@2
|
90
|
andrew@2
|
91 ofxOscSender sender;
|
andrew@2
|
92
|
andrew@2
|
93 double posteriorMaximum;
|
andrew@2
|
94 bool adaptiveStandardDeviationMode;
|
andrew@2
|
95 double tempoStdDev;
|
andrew@2
|
96 bool accompanimentStarted;
|
andrew@2
|
97 bool setDistributionOnStartTempo;
|
andrew@2
|
98 int integerMultipleOfTatum;
|
andrew@2
|
99
|
andrew@2
|
100 double recentClickTime;
|
andrew@2
|
101
|
andrew@2
|
102 string kickString;//for info
|
andrew@2
|
103
|
andrew@2
|
104 float debugArray [4];
|
andrew@2
|
105 string tempoUpdateStrings[16];
|
andrew@2
|
106 string tempoDataString;
|
andrew@11
|
107
|
andrew@11
|
108 double generalLikelihoodToNoiseRatio;
|
andrew@2
|
109 };
|
andrew@2
|
110
|
andrew@2
|
111 #endif |