andrew@2
|
1 #ifndef _TEST_APP
|
andrew@2
|
2 #define _TEST_APP
|
andrew@2
|
3
|
andrew@2
|
4
|
andrew@2
|
5
|
andrew@2
|
6 #include "ofMain.h"
|
andrew@2
|
7 #include "ofxOsc.h"
|
andrew@2
|
8 //#include "bayesianArray.h"
|
andrew@2
|
9 //#include "beatTempo.h"
|
andrew@2
|
10 #include "BayesDrumTracker.h"
|
andrew@2
|
11
|
andrew@2
|
12 // listen on port 12345
|
andrew@2
|
13 #define PORT 12345
|
andrew@2
|
14 #define NUM_MSG_STRINGS 45
|
andrew@2
|
15 #define HOST "localhost"
|
andrew@2
|
16 #define ARRAY_SIZE 240//need to replace this with const int in drumtracker
|
andrew@2
|
17
|
andrew@2
|
18 #define NUMBER_OF_SCREENS 8
|
andrew@2
|
19
|
andrew@2
|
20 class testApp : public ofBaseApp{
|
andrew@2
|
21
|
andrew@2
|
22 public:
|
andrew@2
|
23
|
andrew@2
|
24 void setup();
|
andrew@2
|
25 void update();
|
andrew@2
|
26 void draw();
|
andrew@2
|
27 void drawBayesianDistribution();
|
andrew@2
|
28 void drawTempoData();
|
andrew@2
|
29 void drawTempoDistribution();
|
andrew@2
|
30 void drawRestrictedTempoDistribution(int tmpMin, int tmpMax);
|
andrew@2
|
31
|
andrew@2
|
32 void drawBeatMap();
|
andrew@2
|
33 void drawNormalisedLikelihood();
|
andrew@2
|
34 void drawBeatProbabilityDistribution();
|
andrew@2
|
35 void drawPosterior();
|
andrew@2
|
36 void printBayesianData();
|
andrew@2
|
37 void drawGreyscaleBayesianDistribution();
|
andrew@2
|
38 void drawGreyscaleTempoDistribution(double tempoInterval);
|
andrew@2
|
39 void drawTempoInfo();
|
andrew@2
|
40
|
andrew@2
|
41 void resetParameters();
|
andrew@2
|
42 void takePictureOfScreen();
|
andrew@2
|
43
|
andrew@2
|
44 void crossUpdateArrays(float timeInterval);
|
andrew@2
|
45 void updateTempoProcess(double cpuTime, string onsetType);
|
andrew@2
|
46
|
andrew@2
|
47 void sendMaxTempo();
|
andrew@2
|
48 void sendMaxPhase();
|
andrew@2
|
49 double convertToBPM(double interval);
|
andrew@2
|
50 bool filterBeatTime(double newBeatTime);
|
andrew@2
|
51
|
andrew@2
|
52 // float beatIndexToMsec(int index);
|
andrew@2
|
53 // float tempoIndexToMsec(int index);
|
andrew@2
|
54
|
andrew@2
|
55 void keyPressed(int key);
|
andrew@2
|
56 void keyReleased(int key);
|
andrew@2
|
57 void mouseMoved(int x, int y );
|
andrew@2
|
58 void mouseDragged(int x, int y, int button);
|
andrew@2
|
59 void mousePressed(int x, int y, int button);
|
andrew@2
|
60 void mouseReleased(int x, int y, int button);
|
andrew@2
|
61 void windowResized(int w, int h);
|
andrew@2
|
62
|
andrew@2
|
63 void setGaussianLikelihood(float mean, float StdDev);
|
andrew@2
|
64 void setGaussianPrior(float mean, float StdDev);
|
andrew@2
|
65 void calculatePosterior();
|
andrew@2
|
66 void renormalisePosterior();
|
andrew@2
|
67 float getMaximum(float *ptr, int length);
|
andrew@2
|
68 void renormaliseArray(float *ptr, int length);
|
andrew@2
|
69 void updateOSCmessages();
|
andrew@2
|
70 void resetPrior();
|
andrew@2
|
71 void decayPosterior();
|
andrew@2
|
72 void translateDistribution(int translationIndex);
|
andrew@2
|
73 void setBeatDistribution(int beatPosition);
|
andrew@2
|
74 void calculateTempoUpdate(double tempoInterval);
|
andrew@2
|
75 bool updateTempoIfWithinRange(double timeInterval);
|
andrew@2
|
76
|
andrew@2
|
77 float* getMaximumEstimate(float *ptr, int length);
|
andrew@2
|
78 void drawTempoDataPoints(const int& tmpMin, const int& tmpMax, const float& tmpStepSize);
|
andrew@2
|
79 int xcoordinateFromTempoDataPoint(float f);
|
andrew@2
|
80 int xcoordinateFromRestrictedTempoDataPoint(float f, const int& tmpMin, const int& tmpMax);
|
andrew@2
|
81
|
andrew@2
|
82 float arrayToMsecScaleFactor;// = (tempoMaximum - tempoMinimum)/ ARRAY_SIZE;//turns array into ms
|
andrew@2
|
83
|
andrew@2
|
84
|
andrew@2
|
85
|
andrew@2
|
86 int tempoWindowMinimum, tempoWindowMaximum, tempoWindowWidth;
|
andrew@2
|
87
|
andrew@2
|
88 ofTrueTypeFont font;
|
andrew@2
|
89
|
andrew@2
|
90 ofxOscReceiver receiver;
|
andrew@2
|
91 string msg_string, debugString, kickString;
|
andrew@2
|
92
|
andrew@2
|
93 bool bSmooth;
|
andrew@2
|
94 // float kickError, snareError;
|
andrew@2
|
95 // float testArray[5];
|
andrew@2
|
96
|
andrew@2
|
97 // float prior [ARRAY_SIZE];
|
andrew@2
|
98 // float posterior [ARRAY_SIZE];
|
andrew@2
|
99 // float likelihood [ARRAY_SIZE];
|
andrew@2
|
100 // float likelihoodMean, likelihoodStdDev, likelihoodNoise, stepSize;
|
andrew@2
|
101 // float maximumEstimate;
|
andrew@2
|
102 // float maximumTest, posteriorDecayRate, maximumIndex;
|
andrew@2
|
103 // float eighthNoteProportion;
|
andrew@2
|
104
|
andrew@2
|
105 float stepSize;
|
andrew@2
|
106 int screenWidth, screenHeight;
|
andrew@2
|
107
|
andrew@2
|
108 bool printInterval, paused;
|
andrew@2
|
109 bool drawData, hidePriorMode;
|
andrew@2
|
110
|
andrew@2
|
111
|
andrew@2
|
112 /*
|
andrew@2
|
113 bayesianArray beatDistribution;
|
andrew@2
|
114
|
andrew@2
|
115 double tempoMinimum, tempoMaximum;
|
andrew@2
|
116 double tempoInterval;
|
andrew@2
|
117 beatTempo beatTimes;
|
andrew@2
|
118 */
|
andrew@2
|
119 //double tempoInterval;
|
andrew@2
|
120 float mouseBPM;
|
andrew@2
|
121 // int correctBeatBy;
|
andrew@2
|
122 // string tempoUpdateStrings[16];
|
andrew@2
|
123 // string tempoDataString;
|
andrew@2
|
124
|
andrew@4
|
125 double KLdiv, entropy, recentError;
|
andrew@4
|
126 string drumType;
|
andrew@3
|
127 void drawKLdivAndEntropy();
|
andrew@2
|
128 private:
|
andrew@2
|
129
|
andrew@2
|
130 // ofxOscSender sender;
|
andrew@2
|
131
|
andrew@2
|
132 //float noiseFactor, stdDevFactor;
|
andrew@2
|
133 // int minTmpDebug, maxTmpDebug;
|
andrew@2
|
134
|
andrew@2
|
135 // float correctionFactor;
|
andrew@2
|
136
|
andrew@2
|
137
|
andrew@2
|
138
|
andrew@2
|
139 // string onsetType;
|
andrew@2
|
140 // string timeString;
|
andrew@2
|
141 // double cpuBeatTime;
|
andrew@2
|
142
|
andrew@2
|
143 // double cpuClockTime;
|
andrew@2
|
144 int screenToDraw;
|
andrew@2
|
145 // double posteriorMaximum;
|
andrew@2
|
146 // bool adaptiveStandardDeviationMode;
|
andrew@2
|
147
|
andrew@2
|
148 bool bSnapshot;
|
andrew@2
|
149 int snapCounter;
|
andrew@2
|
150 ofImage img;
|
andrew@2
|
151
|
andrew@2
|
152 // double tempoStdDev;
|
andrew@2
|
153 // bool accompanimentStarted;
|
andrew@2
|
154 // bool setDistributionOnStartTempo;
|
andrew@2
|
155 // int integerMultipleOfTatum;
|
andrew@2
|
156
|
andrew@2
|
157 BayesDrumTracker drumTracker;
|
andrew@2
|
158
|
andrew@2
|
159 };
|
andrew@2
|
160
|
andrew@2
|
161 #endif
|
andrew@2
|
162
|