@@ -380,11 +380,7 @@ class GoertzelStream : public AudioStream {
380
380
GoertzelDetector& getDetector (int no) { return detectors[no]; }
381
381
382
382
/* *
383
- * @brief Add a frequency to the detection list (not used in single frequency
384
- * mode)
385
- *
386
- * This method allows adding multiple frequencies for detection. However,
387
- * in the current single-frequency mode, this list is not utilized.
383
+ * @brief Add a frequency to the detection list
388
384
*
389
385
* @param freq Frequency in Hz to add to the detection list
390
386
*/
@@ -445,8 +441,8 @@ class GoertzelStream : public AudioStream {
445
441
if (sample_no % channels == default_config.channel ) {
446
442
float normalized = clip (NumberConverter::toFloatT<T>(samples[i]) *
447
443
default_config.volume );
448
- for ( int j = 0 ; j < detectors. size (); j++) {
449
- GoertzelDetector& detector = detectors[j];
444
+ // process all frequencies
445
+ for ( auto & detector : detectors) {
450
446
if (detector.processSample (normalized)) {
451
447
checkDetection (detector);
452
448
}
@@ -490,6 +486,8 @@ class GoertzelStream : public AudioStream {
490
486
* @param data_len Length of data buffer in bytes
491
487
*/
492
488
void processSamples (const uint8_t * data, size_t data_len) {
489
+ // return if there is nothing to detect
490
+ if (detectors.empty ()) return ;
493
491
int channels = default_config.channels ;
494
492
495
493
switch (default_config.bits_per_sample ) {
0 commit comments