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

◆ update() [2/2]

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

Implements fl::audio::Detector.

Definition at line 27 of file transient.cpp.hpp.

27 {
28 mRetainedFFT = context->getFFT16();
29 const fft::Bins& fft = *mRetainedFFT;
30 u32 timestamp = context->getTimestamp();
31
32 // Calculate high-frequency energy (transients have strong high-freq components)
34
35 // Calculate energy flux (rate of change)
37
38 // Detect transient
39 mTransientDetected = detectTransient(flux, timestamp);
40
42 updateAttackTime(flux);
43 mLastTransientTime = timestamp;
44 }
45
46 // Update previous energy for next frame
48
49 // Filter energy through HampelFilter to reject outliers before history
50 float filteredEnergy = mEnergyOutlierFilter.update(mCurrentEnergy);
51
52 // Update energy history with outlier-rejected values
53 if (mEnergyHistory.size() >= ENERGY_HISTORY_SIZE) {
54 mEnergyHistory.pop_front();
55 }
56 mEnergyHistory.push_back(filteredEnergy);
57}
AudioAnalyzeFFT1024 fft
float calculateEnergyFlux(float currentEnergy)
bool detectTransient(float flux, u32 timestamp)
float calculateHighFreqEnergy(const fft::Bins &fft)
shared_ptr< const fft::Bins > mRetainedFFT
Definition transient.h:68
static constexpr size ENERGY_HISTORY_SIZE
Definition transient.h:63
deque< float > mEnergyHistory
Definition transient.h:62
HampelFilter< float, 7 > mEnergyOutlierFilter
Definition transient.h:66

References Transient(), calculateEnergyFlux(), calculateHighFreqEnergy(), detectTransient(), ENERGY_HISTORY_SIZE, mCurrentEnergy, mEnergyHistory, mEnergyOutlierFilter, mLastTransientTime, mPreviousEnergy, mRetainedFFT, mTransientDetected, update(), and updateAttackTime().

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

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