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
float calculateEnergyTrend() const
float calculateTrebleTrend() const
SavitzkyGolayFilter< float, 7 > mTrebleSG
BuildupDetector() FL_NOEXCEPT
void updateEnergyHistory(float energy)
bool mFireBuildupProgress
function_list< void()> onBuildupEnd
function_list< void(float progress)> onBuildupProgress
float mIntensityThreshold
bool shouldEndBuildup() const
function_list< void(const Buildup &)> onBuildup
void update(shared_ptr< Context > context) override
~BuildupDetector() FL_NOEXCEPT override
shared_ptr< const fft::Bins > mRetainedFFT
function_list< void()> onBuildupStart
float getTrebleEnergy(const fft::Bins &fft) const
float calculateBuildupIntensity(float energyTrend, float trebleTrend, float rms) const
function_list< void()> onBuildupPeak
float mEnergyRiseThreshold
bool shouldStartBuildup(float intensity) const
void updateTrebleHistory(float treble)
void fireCallbacks() override
Centralized logging categories for FastLED hardware interfaces and subsystems.
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Base definition for an LED controller.