Skip to content

Commit 1198c87

Browse files
committed
GoertzelStream: cleanup
1 parent 7cfec1a commit 1198c87

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

src/AudioTools/CoreAudio/GoerzelStream.h

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ class GoertzelDetector {
141141
*/
142142
bool isDetected(float threshold) const { return magnitude > threshold; }
143143

144+
/**
145+
* @brief Check if the detected magnitude is above the configured threshold
146+
* @return True if magnitude is above configured threshold
147+
*/
148+
bool isDetected() const { return isDetected(config.threshold); }
149+
144150
/**
145151
* @brief Reset the detector state
146152
*/
@@ -167,7 +173,7 @@ class GoertzelDetector {
167173
*/
168174
const GoertzelConfig& getConfig() const { return config; }
169175

170-
private:
176+
protected:
171177
GoertzelConfig config;
172178
float coeff = 0.0f;
173179

@@ -182,17 +188,31 @@ class GoertzelDetector {
182188
};
183189

184190
/**
185-
* @brief AudioStream implementation that processes audio data through Goertzel
186-
* algorithm. This class acts as a passthrough filter that can detect specific
187-
* frequencies in the audio stream.
191+
* @brief AudioStream-based multi-frequency Goertzel detector for real-time audio analysis.
192+
*
193+
* GoertzelStream enables efficient detection of one or more target frequencies in a continuous audio stream.
194+
* It acts as a transparent filter: audio data flows through unchanged, while the class analyzes the signal for specified tones.
195+
*
196+
* Key Features:
197+
* - Detects multiple frequencies simultaneously (DTMF, tone detection, etc.)
198+
* - Supports runtime addition of frequencies via addFrequency()
199+
* - Works with various sample formats: 8/16/24/32-bit (see below)
200+
* - Channel-aware: can analyze a specific channel in multi-channel audio
201+
* - Callback system: notifies user when a frequency is detected above threshold
202+
* - Non-intrusive: does not modify or block audio data
203+
* - Configurable detection parameters (block size, threshold, volume, etc.)
188204
*
189-
* Use the addFrequency method to add multiple frequencies for detection. ,
205+
* Usage:
206+
* 1. Configure the stream with GoertzelConfig or AudioInfo (sample rate, channels, etc.)
207+
* 2. Add one or more target frequencies using addFrequency()
208+
* 3. Optionally set a detection callback with setFrequencyDetectionCallback()
209+
* 4. Use write() or readBytes() to process audio data; detection runs automatically
190210
*
191-
* Supports multiple sample formats:
192-
* - 8-bit: unsigned samples (0-255), converted to signed (-128 to 127)
193-
* - 16-bit: signed samples (-32768 to 32767)
194-
* - 24-bit: signed samples stored as 4 bytes, little-endian
195-
* - 32-bit: signed samples (-2147483648 to 2147483647)
211+
* Supported sample formats:
212+
* - 8-bit: unsigned (0-255), internally converted to signed (-128 to 127)
213+
* - 16-bit: signed (-32768 to 32767)
214+
* - 24-bit: signed, packed format
215+
* - 32-bit: signed (-2^31 to 2^31-1)
196216
*
197217
*
198218
* @ingroup dsp

0 commit comments

Comments
 (0)