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

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)
 
float calculateHighFreqEnergy (const fft::Bins &fft)
 
float calculateHighFreqEnergy (const fft::Bins &fft)
 
bool detectTransient (float flux, u32 timestamp)
 
bool detectTransient (float flux, u32 timestamp)
 
void updateAttackTime (float flux)
 
void updateAttackTime (float flux)
 

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::BinsmRetainedFFT
 
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: