Mercurial > hg > midi-score-follower
comparison src/BayesianArrayStructure.cpp @ 19:2e17f0fdeaef
offline method is now working, linked via pointer in BayesianStructure. Progresses using the time played so could be used for sequential offfline analysis
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Tue, 22 Nov 2011 13:30:02 +0000 |
parents | c7107e5c8f03 |
children | 11e3119ce6b4 |
comparison
equal
deleted
inserted
replaced
18:c7107e5c8f03 | 19:2e17f0fdeaef |
---|---|
129 posterior.array[i] = prior.array[i]; | 129 posterior.array[i] = prior.array[i]; |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 void BayesianArrayStructure::setStartPlaying(){ | 133 void BayesianArrayStructure::setStartPlaying(){ |
134 lastEventTime = 0;//ofGetElapsedTimeMillis(); | 134 |
135 lastEventTime = 0; | |
135 bestEstimate = 0; | 136 bestEstimate = 0; |
136 lastBestEstimateUpdateTime = lastEventTime; | 137 lastBestEstimateUpdateTime = 0; |
137 //bug somewhere here that prevented offline | 138 if (*realTimeMode) |
138 //ofGetElapsedTimeMillis();//lastEventTime;// | 139 lastBestEstimateUpdateTime = ofGetElapsedTimeMillis(); |
140 //cannot just be zero - offline bug | |
139 printf("start playing - best estimate %f\n", lastBestEstimateUpdateTime); | 141 printf("start playing - best estimate %f\n", lastBestEstimateUpdateTime); |
142 | |
140 resetArrays(); | 143 resetArrays(); |
141 } | 144 } |
142 | 145 |
143 void BayesianArrayStructure::resetArrays(){ | 146 void BayesianArrayStructure::resetArrays(){ |
144 //called when we start playing | 147 //called when we start playing |
158 // posterior.addToIndex(0, 1); | 161 // posterior.addToIndex(0, 1); |
159 likelihood.addConstant(1); | 162 likelihood.addConstant(1); |
160 | 163 |
161 updateCounter = 0; | 164 updateCounter = 0; |
162 | 165 |
163 bestEstimate = 0; | 166 |
164 lastBestEstimateUpdateTime = ofGetElapsedTimeMillis(); | |
165 //cannot just be zero - offline bug | |
166 | |
167 printf("bayes reset arrays - best estimate %f\n", lastBestEstimateUpdateTime); | 167 printf("bayes reset arrays - best estimate %f\n", lastBestEstimateUpdateTime); |
168 | 168 |
169 setSpeedPrior(speedPriorValue); | 169 setSpeedPrior(speedPriorValue); |
170 } | 170 } |
171 | |
171 | 172 |
172 void BayesianArrayStructure::zeroArrays(){ | 173 void BayesianArrayStructure::zeroArrays(){ |
173 prior.zero(); | 174 prior.zero(); |
174 likelihood.zero(); | 175 likelihood.zero(); |
175 posterior.zero(); | 176 posterior.zero(); |
197 | 198 |
198 double timeDiff = timeDifference; | 199 double timeDiff = timeDifference; |
199 | 200 |
200 //Using timedifferencfe here will make it go wrong. Is time since beginning of playing | 201 //Using timedifferencfe here will make it go wrong. Is time since beginning of playing |
201 | 202 |
202 //if (*realTimeMode) | 203 if (*realTimeMode) |
203 timeDiff = ofGetElapsedTimeMillis() - lastBestEstimateUpdateTime; | 204 timeDiff = ofGetElapsedTimeMillis() - lastBestEstimateUpdateTime; |
204 | 205 |
205 double speedEstimate; | 206 double speedEstimate; |
206 if (usingIntegratedTempoEstimate) | 207 if (usingIntegratedTempoEstimate) |
207 speedEstimate = relativeSpeedPosterior.getIntegratedEstimate(); | 208 speedEstimate = relativeSpeedPosterior.getIntegratedEstimate(); |