|
FastLED 3.9.15
|
Pitch - Continuous pitch tracking using autocorrelation.
Detects the fundamental frequency (pitch) of audio signals using autocorrelation analysis on the time-domain PCM data. This detector provides continuous pitch tracking with configurable confidence thresholds, smoothing, and stability.
Key Features:
Performance:
#include <pitch.h>
Inheritance diagram for fl::audio::detector::Pitch:
Collaboration diagram for fl::audio::detector::Pitch:Public Types | |
| using | PitchCallback = void(*)(float pitch) |
| using | PitchConfidenceCallback = void(*)(float pitch, float confidence) |
| using | VoicedCallback = void(*)(u8 isVoiced) |
Public Member Functions | |
| Pitch () FL_NOEXCEPT | |
| Pitch () FL_NOEXCEPT | |
| ~Pitch () FL_NOEXCEPT | |
| ~Pitch () FL_NOEXCEPT override | |
| void | fireCallbacks () override |
| float | getConfidence () const |
| float | getConfidence () const |
| const char * | getName () const override |
| float | getPitch () const |
| float | getPitch () const |
| float | getSmoothedPitch () const |
| bool | isVoiced () const |
| bool | isVoiced () const |
| bool | needsFFT () const override |
| void | reset () |
| void | reset () override |
| void | setConfidenceThreshold (float threshold) |
| void | setConfidenceThreshold (float threshold) |
| void | setMaxFrequency (float hz) |
| void | setMaxFrequency (float hz) |
| void | setMinFrequency (float hz) |
| void | setMinFrequency (float hz) |
| void | setPitchChangeSensitivity (float sensitivity) |
| void | setPitchChangeSensitivity (float sensitivity) |
| void | setSampleRate (float rate) |
| void | setSmoothingFactor (float factor) |
| void | setSmoothingFactor (float) |
| 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 hz)> | onPitch |
| PitchCallback | onPitch = nullptr |
| function_list< void(float hz)> | onPitchChange |
| PitchCallback | onPitchChange = nullptr |
| function_list< void(float hz, float confidence)> | onPitchWithConfidence |
| PitchConfidenceCallback | onPitchWithConfidence = nullptr |
| function_list< void(u8 voiced)> | onVoiced |
| VoicedCallback | onVoiced = nullptr |
Private Member Functions | |
| float | calculateAutocorrelation (const i16 *pcm, size numSamples) |
| float | calculateAutocorrelation (const i16 *pcm, size numSamples) |
| float | calculateConfidence (const fl::vector< float > &autocorr, int peakLag) const |
| float | calculateConfidence (const vector< float > &autocorr, int peakLag) const |
| int | findBestPeakLag (const fl::vector< float > &autocorr) const |
| int | findBestPeakLag (const vector< float > &autocorr) const |
| int | frequencyToPeriod (float frequency) const |
| int | frequencyToPeriod (float frequency) const |
| float | periodToFrequency (int period) const |
| float | periodToFrequency (int period) const |
| bool | shouldReportPitchChange (float newPitch) const |
| bool | shouldReportPitchChange (float newPitch) const |
| void | updatePeriodRange () |
| void | updatePeriodRange () |
| void | updatePitchSmoothing (float newPitch) |
| void | updatePitchSmoothing (float newPitch) |
Private Attributes | |
| vector< float > | mAutocorrelation |
| fl::vector< float > | mAutocorrelation |
| float | mConfidence |
| float | mConfidenceThreshold |
| float | mCurrentPitch |
| bool | mFirePitch = false |
| bool | mFirePitchChange = false |
| bool | mIsVoiced |
| float | mLastDt = 0.023f |
| float | mMaxFrequency |
| int | mMaxPeriod |
| float | mMinFrequency |
| int | mMinPeriod |
| float | mPitchChangeSensitivity |
| OneEuroFilter< float > | mPitchSmoother {1.0f, 0.5f} |
| float | mPreviousPitch |
| bool | mPreviousVoiced |
| float | mSampleRate |
| float | mSmoothedPitch |
| float | mSmoothingFactor |
| bool | mVoicedStateChanged = false |