|
arduino-audio-tools
|
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>
Public Member Functions | |
| GoertzelDetector ()=default | |
| bool | begin (const GoertzelConfig &config) |
| Initialize the Goertzel detector with configuration. | |
| int | getBlockSize () const |
| Get the block size. | |
| const GoertzelConfig & | getConfig () const |
| Get the current configuration. | |
| float | getMagnitude () const |
| Get the magnitude of the detected frequency. | |
| float | getMagnitudeSquared () const |
| Get the squared magnitude (more efficient if you don't need the actual magnitude) | |
| void * | getReference () |
| float | getTargetFrequency () const |
| Get the target frequency. | |
| bool | isDetected () const |
| Check if the detected magnitude is above the configured threshold. | |
| bool | isDetected (float threshold) const |
| Check if the detected magnitude is above a threshold. | |
| bool | processSample (float sample) |
| Process a single sample. | |
| void | reset () |
| Reset the detector state. | |
| void | setReference (void *ref) |
Protected Attributes | |
| float | coeff = 0.0f |
| GoertzelConfig | config |
| float | magnitude = 0.0f |
| float | magnitude_squared = 0.0f |
| void * | reference = nullptr |
| float | s1 = 0.0f |
| float | s2 = 0.0f |
| int | sample_count = 0 |
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.
|
default |
|
inline |
Initialize the Goertzel detector with configuration.
| config | GoertzelConfig containing all parameters |
|
inline |
Get the block size.
|
inline |
Get the current configuration.
|
inline |
Get the magnitude of the detected frequency.
|
inline |
Get the squared magnitude (more efficient if you don't need the actual magnitude)
|
inline |
|
inline |
Get the target frequency.
|
inline |
Check if the detected magnitude is above the configured threshold.
Check if the detected magnitude is above a threshold.
| threshold | Threshold value |
Process a single sample.
| sample | Input sample (normalized float in range [-1.0, 1.0]) |
|
inline |
Reset the detector state.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |