-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
For audio input to work for ESP32, please add the dma buffer to the private section and use i2s_channel_read.
i2s_read is legacy.
Here is the updated code for mic.h:
private:
int micGain = 32; // 0 - 64
int samples_read = 0;
static const int dmaBufferLength = 64; //AR - added
static const int16_t bufferLen = dmaBufferLength * 4;
uint16_t inputBuf[bufferLen];
int mBufIndex = 0;
#if IS_ESP8266()
System.println("Mic class not yet implemented for ESP8266");
void readMic() {
// TBC
}
#elif IS_ESP32()
inline
void readMic() {
size_t bytesIn = 0;
esp_err_t result = i2s_channel_read(rx_handle, inputBuf, bufferLen, &bytesIn, portMAX_DELAY); // AR - changed
if (result == ESP_OK && bytesIn > 0) {
samples_read = bytesIn / 2; // stereo 16 bit samples
}
}
#endif
I tested it and it works wonderfully.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels