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