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

◆ update()

void fl::audio::detector::DynamicsAnalyzer::update ( shared_ptr< Context > context)
overridevirtual

Implements fl::audio::Detector.

Definition at line 33 of file dynamics_analyzer.cpp.hpp.

33 {
34 mCurrentRMS = context->getRMS();
35 u32 timestamp = context->getTimestamp();
36
37 // Update peak with decay
39
40 // Add to history
41 if (mRMSHistory.size() < mHistorySize) {
42 mRMSHistory.push_back(mCurrentRMS);
44 } else {
47 }
48
49 // Calculate average RMS from history
50 float sum = 0.0f;
51 for (fl::size i = 0; i < mRMSHistory.size(); i++) {
52 sum += mRMSHistory[i];
53 }
54 mAverageRMS = (mRMSHistory.size() > 0) ? sum / mRMSHistory.size() : 0.0f;
55
56 // Track minimum RMS (with slow rise to handle changing environments)
57 if (mCurrentRMS < mMinRMS) {
59 } else {
60 mMinRMS += (mCurrentRMS - mMinRMS) * 0.001f; // Very slow rise
61 }
62
63 // Calculate dynamic trend
64 float newTrend = calculateTrend();
65
66 // Smooth the trend
67 mTrend = mSmoothingFactor * mTrend + (1.0f - mSmoothingFactor) * newTrend;
68
69 // Determine crescendo/diminuendo state
72
75
76 // Update compression ratio
78
79 mLastUpdateTime = timestamp;
80}

References DynamicsAnalyzer(), calculateTrend(), mAverageRMS, mCurrentRMS, mHistoryIndex, mHistorySize, mIsCrescendo, mIsDiminuendo, mLastUpdateTime, mMinRMS, mPrevIsCrescendo, mPrevIsDiminuendo, mRMSHistory, mSmoothingFactor, mTrend, mTrendThreshold, update(), updateCompression(), and updatePeak().

Referenced by ~DynamicsAnalyzer(), and update().

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