220 {
221
222
223
224
225
226
228
229
230 float meanAccent = 1.0f;
232 float sum = 0.0f;
235 }
236 meanAccent = sum /
static_cast<float>(
mBeatAccents.size());
237 }
238
239
240
241 float accentConfidence = meanAccent > 0.0f
243 : fl::
clamp(accent * 0.5f, 0.3f, 0.7f);
244
246 return true;
247 }
248
249
253 : 500.0f;
254 float expectedMeasureDuration = beatInterval *
static_cast<float>(
mBeatsPerMeasure);
255
256
257 float timingError =
fl::abs(
static_cast<float>(timeSinceDownbeat) - expectedMeasureDuration);
258 float maxTimingError = beatInterval * 0.4f;
259 bool nearMeasureBoundary = (timingError < maxTimingError);
260
261
262 float meanAccent = 1.0f;
264 float sum = 0.0f;
267 }
268 meanAccent = sum /
static_cast<float>(
mBeatAccents.size());
269 }
270
272
273
275
276
277 float timingConfidence = 1.0f - (timingError / (beatInterval * 2.0f));
278 timingConfidence =
fl::clamp(timingConfidence, 0.0f, 1.0f);
279
280 float accentConfidence = meanAccent > 0.0f
282 : 0.5f;
283
284
285
286 float accentWeight = atBeatCounterBoundary ? 0.7f : 0.5f;
287 float timingWeight = atBeatCounterBoundary ? 0.3f : 0.5f;
288 mConfidence = (timingConfidence * timingWeight) + (accentConfidence * accentWeight);
289
290
291
294 }
295
296
298
299 if (atBeatCounterBoundary) {
300
302 } else if (nearMeasureBoundary && strongAccent) {
303
306
308 }
309
311}
bool isDownbeat() const
Returns true if downbeat was detected this frame.
deque< float > mBeatAccents
float mConfidenceThreshold
shared_ptr< Beat > mBeatDetector
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type abs(T x) FL_NOEXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NOEXCEPT