@@ -380,11 +380,7 @@ class GoertzelStream : public AudioStream {
380380 GoertzelDetector& getDetector (int no) { return detectors[no]; }
381381
382382 /* *
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
388384 *
389385 * @param freq Frequency in Hz to add to the detection list
390386 */
@@ -445,8 +441,8 @@ class GoertzelStream : public AudioStream {
445441 if (sample_no % channels == default_config.channel ) {
446442 float normalized = clip (NumberConverter::toFloatT<T>(samples[i]) *
447443 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) {
450446 if (detector.processSample (normalized)) {
451447 checkDetection (detector);
452448 }
@@ -490,6 +486,8 @@ class GoertzelStream : public AudioStream {
490486 * @param data_len Length of data buffer in bytes
491487 */
492488 void processSamples (const uint8_t * data, size_t data_len) {
489+ // return if there is nothing to detect
490+ if (detectors.empty ()) return ;
493491 int channels = default_config.channels ;
494492
495493 switch (default_config.bits_per_sample ) {
0 commit comments