Skip to content

Commit d85ef56

Browse files
committed
AR: handle stupid build flag SR_DMTYPE=-1
I don't know how the bad example "-D SR_DMTYPE=-1" made it into platformio_override.sample.ini 🫣 mic type -1 = 255 was never supported by AR, and lead to undefined behavior due to a missing "case" in setup(). Fixed. Its still a stupid build_flags option, but at least now its handled properly.
1 parent c8bda1a commit d85ef56

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

usermods/audioreactive/audio_reactive.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,14 +1225,20 @@ class AudioReactive : public Usermod {
12251225
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
12261226
// ADC over I2S is only possible on "classic" ESP32
12271227
case 0:
1228-
default:
12291228
DEBUGSR_PRINTLN(F("AR: Analog Microphone (left channel only)."));
12301229
audioSource = new I2SAdcSource(SAMPLE_RATE, BLOCK_SIZE);
12311230
delay(100);
12321231
useBandPassFilter = true; // PDM bandpass filter seems to help for bad quality analog
12331232
if (audioSource) audioSource->initialize(audioPin);
12341233
break;
12351234
#endif
1235+
1236+
case 255: // 255 = -1 = no audio source
1237+
// falls through to default
1238+
default:
1239+
if (audioSource) delete audioSource; audioSource = nullptr;
1240+
enabled = false;
1241+
break;
12361242
}
12371243
delay(250); // give microphone enough time to initialise
12381244

0 commit comments

Comments
 (0)