Single-frequency Goertzel algorithm implementation for tone detection. The Goertzel algorithm is an efficient way to compute the magnitude of a specific frequency component in a signal. It's particularly useful for DTMF (touch-tone) detection and other single-frequency detection applications.
More...
#include <GoerzelStream.h>
Single-frequency Goertzel algorithm implementation for tone detection. The Goertzel algorithm is an efficient way to compute the magnitude of a specific frequency component in a signal. It's particularly useful for DTMF (touch-tone) detection and other single-frequency detection applications.
This implementation expects normalized float samples in the range [-1.0, 1.0]. For different sample formats, use GoertzelStream which handles format conversion.
- Author
- pschatzmann
- Copyright
- GPLv3
◆ GoertzelDetector()
◆ begin()
Initialize the Goertzel detector with configuration.
- Parameters
-
◆ getBlockSize()
| int getBlockSize |
( |
| ) |
const |
|
inline |
◆ getConfig()
Get the current configuration.
◆ getMagnitude()
| float getMagnitude |
( |
| ) |
const |
|
inline |
Get the magnitude of the detected frequency.
- Returns
- Magnitude value
◆ getMagnitudeSquared()
| float getMagnitudeSquared |
( |
| ) |
const |
|
inline |
Get the squared magnitude (more efficient if you don't need the actual magnitude)
- Returns
- Squared magnitude value
◆ getReference()
◆ getTargetFrequency()
| float getTargetFrequency |
( |
| ) |
const |
|
inline |
Get the target frequency.
◆ isDetected() [1/2]
| bool isDetected |
( |
| ) |
const |
|
inline |
Check if the detected magnitude is above the configured threshold.
- Returns
- True if magnitude is above configured threshold
◆ isDetected() [2/2]
| bool isDetected |
( |
float |
threshold | ) |
const |
|
inline |
Check if the detected magnitude is above a threshold.
- Parameters
-
- Returns
- True if magnitude is above threshold
◆ processSample()
| bool processSample |
( |
float |
sample | ) |
|
|
inline |
Process a single sample.
- Parameters
-
| sample | Input sample (normalized float in range [-1.0, 1.0]) |
- Returns
- True if block is complete and magnitude is available
◆ reset()
Reset the detector state.
◆ setReference()
| void setReference |
( |
void * |
ref | ) |
|
|
inline |
◆ coeff
◆ config
◆ magnitude
◆ magnitude_squared
| float magnitude_squared = 0.0f |
|
protected |
◆ reference
| void* reference = nullptr |
|
protected |
◆ s1
◆ s2
◆ sample_count
The documentation for this class was generated from the following file: