FastLED 3.10.8
Loading...
Searching...
No Matches
fl::audio::detector::Transient Class Reference

Detailed Description

Transient - Detects sharp attack transients in audio.

Transients are rapid increases in energy that indicate the start of a sound, such as drum hits, plucked strings, or any percussive element. This detector uses spectral flux and energy envelope analysis to identify attack events.

Definition at line 21 of file transient.h.

#include <transient.h>

+ Inheritance diagram for fl::audio::detector::Transient:
+ Collaboration diagram for fl::audio::detector::Transient:

Public Types

using TransientCallback = void(*)()
 
using TransientStrengthCallback = void(*)(float strength)
 

Public Member Functions

 Transient () FL_NO_EXCEPT
 
 Transient () FL_NO_EXCEPT
 
 ~Transient () FL_NO_EXCEPT
 
 ~Transient () FL_NO_EXCEPT override
 
void fireCallbacks () FL_NO_EXCEPT override
 
float getAttackTime () const
 
float getAttackTime () const FL_NO_EXCEPT
 
const char * getName () const FL_NO_EXCEPT override
 
float getStrength () const
 
float getStrength () const FL_NO_EXCEPT
 
bool isTransient () const FL_NO_EXCEPT
 
bool isTransientDetected () const
 
bool needsFFT () const FL_NO_EXCEPT override
 
void reset ()
 
void reset () FL_NO_EXCEPT override
 
void setMinInterval (u32 intervalMs) FL_NO_EXCEPT
 
void setSensitivity (float sensitivity)
 
void setSensitivity (float sensitivity) FL_NO_EXCEPT
 
void setThreshold (float threshold)
 
void setThreshold (float threshold) FL_NO_EXCEPT
 
void update (shared_ptr< Context > context)
 
void update (shared_ptr< Context > context) FL_NO_EXCEPT override
 
- Public Member Functions inherited from fl::audio::Detector
virtual ~Detector () FL_NO_EXCEPT=default
 
virtual bool needsFFTHistory () const FL_NO_EXCEPT
 
virtual void setSampleRate (int) FL_NO_EXCEPT
 

Public Attributes

function_list< void(float strength)> onAttack
 
TransientStrengthCallback onAttack = nullptr
 
function_list< void()> onTransient
 
TransientCallback onTransient = nullptr
 
function_list< void(float strength)> onTransientWithStrength
 
TransientStrengthCallback onTransientWithStrength = nullptr
 

Private Member Functions

float calculateEnergyFlux (float currentEnergy)
 
float calculateEnergyFlux (float currentEnergy) FL_NO_EXCEPT
 
float calculateHighFreqEnergy (const fft::Bins &fft)
 
float calculateHighFreqEnergy (const fft::Bins &fft) FL_NO_EXCEPT
 
bool detectTransient (float flux, u32 timestamp)
 
bool detectTransient (float flux, u32 timestamp) FL_NO_EXCEPT
 
void updateAttackTime (float flux)
 
void updateAttackTime (float flux) FL_NO_EXCEPT
 

Private Attributes

float mAttackTime
 
float mCurrentEnergy
 
deque< float > mEnergyHistory
 
fl::vector< float > mEnergyHistory
 
HampelFilter< float, 7 > mEnergyOutlierFilter {2.5f}
 
u32 mLastTransientTime
 
u32 mMinIntervalMs
 
float mPreviousEnergy
 
vector< float > mPreviousHighFreq
 
fl::vector< float > mPreviousHighFreq
 
shared_ptr< const fft::Bins > mRetainedFFT
 
float mSensitivity
 
float mStrength
 
float mThreshold
 
bool mTransientDetected
 

Static Private Attributes

static constexpr size ENERGY_HISTORY_SIZE = 5
 
static constexpr size_t ENERGY_HISTORY_SIZE = 32
 

The documentation for this class was generated from the following files: