24 if (frequencyBins.size() < 16) {
51 if (
mConfig.enableCrossBandCorrelation) {
78 mStats.bassEnergy = bassEnergy;
79 mStats.midEnergy = midEnergy;
80 mStats.trebleEnergy = trebleEnergy;
114 return bandCount >= 2;
139 mStats.multiBandBeats = 0;
142 mStats.trebleEnergy = 0.0f;
148 if (cooldownCounter > 0) {
154 if (previousEnergy <= 0.0001f) {
159 float energyIncrease = currentEnergy - previousEnergy;
162 if (energyIncrease <= 0.0f) {
167 float relativeIncrease = energyIncrease / previousEnergy;
170 if (relativeIncrease > threshold) {
172 cooldownCounter =
mConfig.beatCooldownFrames;
183 sum += frequencyBins[i];
192 sum += frequencyBins[i];
201 sum += frequencyBins[i];
float getBassEnergy() const FL_NO_EXCEPT
Get current bass energy (0.0-1.0)
float mPreviousTrebleEnergy
float mBassEnergy
Current band energies.
void detectBeats(span< const float > frequencyBins) FL_NO_EXCEPT
Detect beats in all frequency bands.
static constexpr size MID_BIN_START
bool isTrebleBeat() const FL_NO_EXCEPT
Check if a treble beat was detected in the last frame.
u32 mCurrentFrame
Current frame counter.
float getMidEnergy() const FL_NO_EXCEPT
Get current mid energy (0.0-1.0)
bool isMultiBandBeat() const FL_NO_EXCEPT
Check if multiple bands triggered simultaneously (strong beat)
MultiBandBeatDetectorConfig mConfig
MultiBandBeat() FL_NO_EXCEPT
void reset() FL_NO_EXCEPT
Reset internal state (clear history, reset cooldowns)
bool mBassBeat
Beat detection flags for current frame.
static constexpr size TREBLE_BIN_END
float getTrebleEnergy() const FL_NO_EXCEPT
Get current treble energy (0.0-1.0)
static constexpr size TREBLE_BIN_START
u32 mBassCooldown
Beat cooldown counters (prevent double-triggering)
static constexpr size BASS_BIN_END
void configure(const MultiBandBeatDetectorConfig &config) FL_NO_EXCEPT
Configure the multi-band beat detector.
float calculateMidEnergy(span< const float > frequencyBins) const FL_NO_EXCEPT
Calculate energy for mid band (bins 6-7)
~MultiBandBeat() FL_NO_EXCEPT
bool detectBandBeat(float currentEnergy, float previousEnergy, float threshold, u32 &cooldownCounter) FL_NO_EXCEPT
Detect beat in a specific frequency band.
float mPreviousBassEnergy
Previous band energies (for energy increase calculation)
bool isMidBeat() const FL_NO_EXCEPT
Check if a mid beat was detected in the last frame.
static constexpr size MID_BIN_END
float calculateBassEnergy(span< const float > frequencyBins) const FL_NO_EXCEPT
Calculate energy for bass band (bins 0-1)
float calculateTrebleEnergy(span< const float > frequencyBins) const FL_NO_EXCEPT
Calculate energy for treble band (bins 14-15)
static constexpr size BASS_BIN_START
Frequency bin indices for each band.
bool isBassBeat() const FL_NO_EXCEPT
Check if a bass beat was detected in the last frame.
Configuration for multi-band beat detection.
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Base definition for an LED controller.