| 102 | } |
| 103 | |
| 104 | void Beat::updateAdaptiveThreshold() { |
| 105 | // O(1) running average via MovingAverage filter |
| 106 | float mean = mFluxAvg.update(mSpectralFlux); |
| 107 | mAdaptiveThreshold = mean * mThreshold * mSensitivity; |
| 108 | } |
| 109 | |
| 110 | bool Beat::detectBeat(u32 timestamp) { |
| 111 | // Use adaptive threshold with an absolute floor. The floor handles |