arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Modules Pages
Public Member Functions | List of all members
GoertzelDetector Class Reference

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

void begin (const GoertzelConfig &config)
 Initialize the Goertzel detector with configuration.
 
int getBlockSize () const
 Get the block size.
 
const GoertzelConfiggetConfig () 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)
 
float getTargetFrequency () const
 Get the target frequency.
 
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.
 

Detailed Description

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

Member Function Documentation

◆ begin()

void begin ( const GoertzelConfig config)
inline

Initialize the Goertzel detector with configuration.

Parameters
configGoertzelConfig containing all parameters

◆ 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

◆ isDetected()

bool isDetected ( float  threshold) const
inline

Check if the detected magnitude is above a threshold.

Parameters
thresholdThreshold value
Returns
True if magnitude is above threshold

◆ processSample()

bool processSample ( float  sample)
inline

Process a single sample.

Parameters
sampleInput sample (normalized float in range [-1.0, 1.0])
Returns
True if block is complete and magnitude is available

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