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