394 {
395
396
397
398
399 bool profileLearned = false;
402 profileLearned = true;
403 break;
404 }
405 }
406
407 if (!profileLearned) {
408 return 0.5f;
409 }
410
411
413
414 float dotProduct = 0.0f;
415 float profileMag = 0.0f;
416 float currentMag = 0.0f;
417
418 for (size i = 0; i < compareSize; i++) {
421 currentMag +=
fft.raw()[i] *
fft.raw()[i];
422 }
423
424
425 const float epsilon = 1e-6f;
426 float denominator =
fl::sqrt(profileMag * currentMag);
427
428 if (denominator < epsilon) {
429 return 0.5f;
430 }
431
432 float correlation = dotProduct / denominator;
433
434
435 return fl::clamp(correlation, 0.0f, 1.0f);
436}
vector< float > mBackbeatSpectralProfile
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type sqrt(T x) FL_NOEXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NOEXCEPT