Mercurial > hg > midi-score-follower
comparison src/midiEventHolder.cpp @ 10:2ab6f4670cf5
added in the best estimate of error between the observed midi note and the aligned midi track.
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Mon, 17 Oct 2011 22:22:55 +0100 |
parents | 75dcd1308658 |
children | df9c838d0b8f |
comparison
equal
deleted
inserted
replaced
9:75dcd1308658 | 10:2ab6f4670cf5 |
---|---|
179 bayesStruct.setNewDistributionOffsets(max(0., bayesStruct.bestEstimate - (bayesStruct.prior.scalar*bayesStruct.prior.arraySize/2))); | 179 bayesStruct.setNewDistributionOffsets(max(0., bayesStruct.bestEstimate - (bayesStruct.prior.scalar*bayesStruct.prior.arraySize/2))); |
180 // bayesStruct.prior.offset = max(0.,newMAPestimateTime - (bayesStruct.prior.scalar*bayesStruct.prior.arraySize/2)); | 180 // bayesStruct.prior.offset = max(0.,newMAPestimateTime - (bayesStruct.prior.scalar*bayesStruct.prior.arraySize/2)); |
181 | 181 |
182 timeString += " \n : new offset " + ofToString(bayesStruct.prior.offset , 0); | 182 timeString += " \n : new offset " + ofToString(bayesStruct.prior.offset , 0); |
183 timeString += " \n best estimate "+ofToString(bayesStruct.bestEstimate, 1); | 183 timeString += " \n best estimate "+ofToString(bayesStruct.bestEstimate, 1); |
184 timeString += " error "+ofToString(minimumMatchError, 0); | |
184 timeString += " map "+ofToString(bayesStruct.relativeSpeedPosterior.integratedEstimate, 1); | 185 timeString += " map "+ofToString(bayesStruct.relativeSpeedPosterior.integratedEstimate, 1); |
185 timeString += " rel speed "+ofToString(bayesStruct.relativeSpeedPosterior.getIndexInRealTerms(bayesStruct.relativeSpeedPosterior.integratedEstimate), 1); | 186 timeString += " rel speed "+ofToString(bayesStruct.relativeSpeedPosterior.getIndexInRealTerms(bayesStruct.relativeSpeedPosterior.integratedEstimate), 1); |
186 | 187 |
187 | 188 |
188 //be able to draw the prior in correct location relative to the midi notes | 189 //be able to draw the prior in correct location relative to the midi notes |
257 | 258 |
258 int midiEventHolder::findMatch(const int& notePitch, const int& startTime, const int& endTime){ | 259 int midiEventHolder::findMatch(const int& notePitch, const int& startTime, const int& endTime){ |
259 | 260 |
260 matchesFound.clear(); | 261 matchesFound.clear(); |
261 int startIndex = 0; | 262 int startIndex = 0; |
262 | 263 |
263 if (recordedEventTimes.size() > 0){ | 264 if (recordedEventTimes.size() > 0){ |
264 | 265 |
265 //get to the right range of events to check in | 266 //get to the right range of events to check in |
266 while (startIndex < recordedEventTimes.size() && recordedEventTimes[startIndex] < startTime) | 267 while (startIndex < recordedEventTimes.size() && recordedEventTimes[startIndex] < startTime) |
267 startIndex++; | 268 startIndex++; |
268 | 269 |
269 } | 270 } |
270 | 271 |
271 IntVector v; | 272 IntVector v; |
272 DoubleVector d; | 273 DoubleVector d; |
274 double tmpError = 100000.;//v high error | |
273 | 275 |
274 double minimumConfidence = 0; | 276 double minimumConfidence = 0; |
275 while (startIndex < recordedEventTimes.size() && recordedEventTimes[startIndex] < endTime){ | 277 while (startIndex < recordedEventTimes.size() && recordedEventTimes[startIndex] < endTime){ |
276 if (recordedNoteOnMatrix[startIndex][1] == notePitch){ | 278 if (recordedNoteOnMatrix[startIndex][1] == notePitch){ |
277 | 279 |
285 d.push_back(eventConfidence); | 287 d.push_back(eventConfidence); |
286 | 288 |
287 double confidence = eventConfidence;//bayesStruct.posterior.getValueAtMillis(mouseX); | 289 double confidence = eventConfidence;//bayesStruct.posterior.getValueAtMillis(mouseX); |
288 // recordedEventTimes[startIndex]); | 290 // recordedEventTimes[startIndex]); |
289 matchString += "["+ofToString(startIndex)+"] = "+ofToString(confidence, 3)+" ."; | 291 matchString += "["+ofToString(startIndex)+"] = "+ofToString(confidence, 3)+" ."; |
292 | |
293 if (abs(recordedEventTimes[startIndex] - bayesStruct.bestEstimate) < tmpError){ | |
294 //record the error between expected and observed times | |
295 tmpError = abs(recordedEventTimes[startIndex] - bayesStruct.bestEstimate); | |
296 minimumMatchError = recordedEventTimes[startIndex] - bayesStruct.bestEstimate; | |
297 } | |
298 | |
290 } | 299 } |
291 startIndex++; | 300 startIndex++; |
292 } | 301 } |
293 | 302 |
294 | 303 |