30 for (
int i = 0; i < 32; i++) {
33 for (
int i = 0; i < 16; i++) {
42 FL_WARN(
"BuildupDetector::update: null context");
48 float rms = context->getRMS();
50 u32 timestamp = context->getTimestamp();
76 FL_DBG(
"BuildupDetector: Buildup started (intensity=" << intensity <<
")");
92 FL_DBG(
"BuildupDetector: Peak reached");
153 for (
int i = 0; i < 32; i++) {
156 for (
int i = 0; i < 16; i++) {
171 float currentSmoothed =
mEnergySG.value();
176 if (oldestValue < 1e-6f) {
180 float riseRate = (currentSmoothed - oldestValue) / oldestValue;
190 float currentSmoothed =
mTrebleSG.value();
194 if (oldestValue < 1e-6f) {
198 float riseRate = (currentSmoothed - oldestValue) / oldestValue;
209 float normalizedEnergyTrend = energyTrend / 2.0f;
210 float normalizedTrebleTrend = trebleTrend / 2.0f;
212 float intensity = normalizedEnergyTrend * 0.5f +
213 normalizedTrebleTrend * 0.3f +
214 normalizedEnergy * 0.2f;
251 if (energyTrend < -0.5f) {
280 return durationOk && (nearEnd || highIntensity || atMax);
303 int startBin =
static_cast<int>(
fft.raw().size() * 0.75f);
307 for (fl::size i = startBin; i <
fft.raw().size(); i++) {
308 energy +=
fft.raw()[i];
312 return (count > 0) ? energy /
static_cast<float>(count) : 0.0f;
float rms(fl::span< const int16_t > data)
SavitzkyGolayFilter< float, 7 > mEnergySG
void updateTrebleHistory(float treble) FL_NO_EXCEPT
float calculateBuildupIntensity(float energyTrend, float trebleTrend, float rms) const FL_NO_EXCEPT
float calculateEnergyTrend() const FL_NO_EXCEPT
void update(shared_ptr< Context > context) FL_NO_EXCEPT override
SavitzkyGolayFilter< float, 7 > mTrebleSG
void fireCallbacks() FL_NO_EXCEPT override
BuildupDetector() FL_NO_EXCEPT
bool mFireBuildupProgress
bool shouldEndBuildup() const FL_NO_EXCEPT
function_list< void()> onBuildupEnd
void updateEnergyHistory(float energy) FL_NO_EXCEPT
bool shouldPeak() const FL_NO_EXCEPT
bool shouldStartBuildup(float intensity) const FL_NO_EXCEPT
~BuildupDetector() FL_NO_EXCEPT override
float getTrebleEnergy(const fft::Bins &fft) const FL_NO_EXCEPT
function_list< void(float progress)> onBuildupProgress
float mIntensityThreshold
function_list< void(const Buildup &)> onBuildup
shared_ptr< const fft::Bins > mRetainedFFT
function_list< void()> onBuildupStart
float calculateTrebleTrend() const FL_NO_EXCEPT
void reset() FL_NO_EXCEPT override
function_list< void()> onBuildupPeak
float mEnergyRiseThreshold
Centralized logging categories for FastLED hardware interfaces and subsystems.
constexpr common_type_t< T, U > max(T a, U b) FL_NO_EXCEPT
u8 u8 fract8 blur_amount FL_NO_EXCEPT
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NO_EXCEPT
Base definition for an LED controller.