FastLED 3.9.15
Loading...
Searching...
No Matches

◆ calculateArousal()

float fl::audio::detector::MoodAnalyzer::calculateArousal ( float rms,
float zcr,
float flux )
private

Definition at line 183 of file mood_analyzer.cpp.hpp.

183 {
184 // Arousal estimation based on energy and dynamics
185 // Higher energy and more change = higher arousal
186 // Lower energy and less change = lower arousal
187
188 // Normalize RMS (assuming typical range 0-1)
189 float normalizedRMS = fl::min(1.0f, rms);
190
191 // Normalize ZCR (assuming typical range 0-1)
192 float normalizedZCR = fl::min(1.0f, zcr);
193
194 // Normalize flux (assuming typical range 0-10)
195 float normalizedFlux = fl::min(1.0f, flux / 10.0f);
196
197 // Combine into arousal (0 to 1)
198 float arousal = normalizedRMS * 0.5f + normalizedZCR * 0.2f + normalizedFlux * 0.3f;
199
200 // Clamp to valid range
201 return fl::max(0.0f, fl::min(1.0f, arousal));
202}
float rms(fl::span< const int16_t > data)
Definition simple.h:104
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
Definition math.h:71
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Definition math.h:75

References fl::max(), fl::min(), and rms().

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: