| 246 | } |
| 247 | |
| 248 | void TempoAnalyzer::updateCurrentTempo() { |
| 249 | if (mHypotheses.empty()) { |
| 250 | mConfidence = 0.0f; |
| 251 | return; |
| 252 | } |
| 253 | |
| 254 | // Use the best hypothesis, filtered through median for outlier rejection |
| 255 | const TempoHypothesis& best = mHypotheses[0]; |
| 256 | mCurrentBPM = mBPMMedian.update(best.bpm); |
| 257 | mConfidence = calculateTempoConfidence(best); |
| 258 | |
| 259 | // Add to BPM history for stability analysis |
| 260 | mBPMHistory.push_back(mCurrentBPM); |
| 261 | if (mBPMHistory.size() > BPM_HISTORY_SIZE) { |
| 262 | mBPMHistory.pop_front(); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | void TempoAnalyzer::updateStability() { |
| 267 | if (mBPMHistory.size() < 5) { |