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

◆ calculateConfidence()

float fl::audio::detector::MoodAnalyzer::calculateConfidence ( float valence,
float arousal )
private

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

204 {
205 // Confidence based on distance from neutral (center)
206 // Further from neutral = higher confidence
207
208 float distanceFromNeutral = fl::sqrt(valence * valence + arousal * arousal);
209
210 // For valence: range is -1 to 1, so max distance from 0 is 1
211 // For arousal: range is 0 to 1, so max distance from 0.5 is 0.5
212 // Combined max distance is approximately sqrt(1^2 + 0.5^2) = 1.118
213 float normalizedDistance = distanceFromNeutral / 1.118f;
214
215 // Clamp to valid range
216 return fl::max(0.0f, fl::min(1.0f, normalizedDistance));
217}
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
constexpr enable_if< is_fixed_point< T >::value, T >::type sqrt(T x) FL_NOEXCEPT

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

Referenced by update().

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