MCPcopy Create free account
hub / github.com/FastLED/FastLED / calculateConfidence

Method calculateConfidence

src/fl/audio/detector/mood_analyzer.cpp.hpp:204–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204float MoodAnalyzer::calculateConfidence(float valence, float arousal) {
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}
218
219bool MoodAnalyzer::shouldChangeMood(const Mood& newMood) {
220 // Check if mood category has changed

Callers

nothing calls this directly

Calls 2

sqrtFunction · 0.85
maxFunction · 0.85

Tested by

no test coverage detected