Analog input and output on ESP32 #1800
-
Hi, For example like the following code: void record_end(){ BR |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
No you can't use the DAC and ADC at the same time! |
Beta Was this translation helpful? Give feedback.
-
I have the impression that there is some strange bug in the Espressif code. I tried to circumvent it, and made sure that there are no errors any more. Could you retry if it is working now. The following test sketch is running now w/o giving any errors: #include "AudioTools.h"
AnalogAudioStream analog;
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
for (int j = 0; j < 5; j++) {
Serial.println("Recording...");
assert(analog.begin(adc.defaultConfig(RX_MODE)));
delay(1000);
Serial.println("end...");
analog.end();
Serial.println("Playing...");
assert(adc.begin(analog.defaultConfig(TX_MODE)));
delay(1000);
Serial.println("end...");
analog.end();
}
}
void loop() {
}
|
Beta Was this translation helpful? Give feedback.
-
@pschatzmann It seems like this approach is corrupting void begin(int channels, int bitsPerSample, bool isDynamic = false) {
if ((this->channels != channels) || (this->bits_per_sample != bitsPerSample)) {
this->channels = channels;
this->bits_per_sample = bitsPerSample;
if (p_converter != nullptr) delete p_converter;
switch (bits_per_sample) {
case 8:
p_converter = new ConverterAutoCenterT<int8_t>(channels, isDynamic);
break;
case 16:
p_converter = new ConverterAutoCenterT<int16_t>(channels, isDynamic);
break;
case 24:
p_converter = new ConverterAutoCenterT<int24_t>(channels, isDynamic);
break;
case 32:
p_converter = new ConverterAutoCenterT<int32_t>(channels, isDynamic);
break;
}
}
} This prevents unnecessary deletions and reallocation if nothing changes. |
Beta Was this translation helpful? Give feedback.
No you can't use the DAC and ADC at the same time!
You can use them in sequence but since audio requires a lot of space you need to store it on a SD drive or eventually PSRAM which will be filled quite quickly