I've heard that the ESP32's ADC isn't "good" enough for audio purposes. It's a 12 bit SAR ADC with a sampling rate of 200 ksps which is much higher than most consumer products use (44.1 kHz). Does 200 ksps not correlate to a 200 kHz sampling rate. I couldn't find much in the datasheet when it came to calculation times. What am I missing?
I agree with Justme's answer that the DNL/INL is quite high, and also call your attention to this sentence:
By default, there are ±6% differences in measured results between chips.
This matters less for audio applications where the DC level can be normalised later, but for other applications it will definitely require calibration.
There is also a general concern for any ADC on the same chip as digital circuitry: power supply rejection ratio (PSRR). This is the ability to avoid conducting noise from the power supply into the analog results. Since no mention is made of using an external reference voltage, or separate analog power/ground, or a PSRR number, I suspect this is very bad.
What that is likely to mean that every power burst from the radio side gets conducted straight into the audio.
Ultimately the easiest thing to do is try it; if it's not up to your percieved quality standards, you'll want an external ADC with its own little linear regulator and separate area of the PCB. But the built-in ADC is probably adequate for phone-quality speech or music played through tinny cheap speakers.
Audio is about more than just sampling rate and bits. Other parameters are significant as well, such as linearity, monotonicity, noise, distortion, etc.
The ESP32 ADC has DNL of +/- 7 counts. It means that for any voltage measured, the result can be wrong by that amount. This already means the ADC may have missing codes and may not be monotonic.
The ADC measurements are also performed while there is a 100nF capacitor filtering a DC signal that is measured.
So while it could be used to sample audio, it would require a lot of analog signal conditioning to filter and buffer the signal into ESP32 with low enough impedance, and perhaps using oversampling and signal processing to get acceptable quality audio that cannot even reach 12 bits.
So it would be far simpler to just connect a simple audio ADC chip to the I2S bus and it would easily exceed CD quality in terms of bits, linearity, SNR and sampling rate.
Dynamic Range expressed as Effective Number of Bits (ENOB) is another way of expressing Signal to Noise Ratio (SNR):
ENOB: SNR = 6.02*N + 1.76 [dB]
So with resolution
We often use this in characterizing the noise floor of an ADC system, where N is the actual number of bits, and ENOB is the "effective" number of bits. A 16-bit system with 92dB SNR from various noise sources, is effectively comparable to a 15-bit system with noise only from quantization error. There are other noise sources besides quantization error, we just use ENOB to express effective number of bits because quantization error is the one noise source that we can never get rid of.
While dB is a general-purpose ratio unit, for audio applications it is related to the Sound Pressure Level or loudness of a sound. At 16-bit resolution, the ratio between the loudest expressible signal sound and the "noise level" of the inherent quantization noise, would be 98dB -- painfully loud. So 16-bits is enough resolution to capture good quality audio, at least in terms of dynamic range.
However, a 12-bit resolution ADC system has at best a signal-to-noise ratio of only 74dB, so while it would be able to capture sound at some level, the background hiss will be noticeable. For telephone it might be acceptable, but for music the background hiss would be objectionable.
Many calculations here already, so I won't go there and try for a different answer.
Whether the ESP32's ADC is good enough or not depends on what quality audio you want, and the quality of your playback chain.
I experimented a bit and sampled some music with the ADC peripheral on a SAMD21G, not using the full 12-bit and 350ksps but 12 bit, 32khz sampled down to 8 bit.
To my ear, cheap computer speakers playing back the 8-bit, 32kHz PCM sound about the same as when fed with CD-quality music, while the same 8-bit, 32kHz PCM won't do at all when played on the equipment I normally listen to.
If the ESP32's ADC is good enough for audio depends on what quality you want and the quality of the rest of the audio chain. The only way to find out is to try it.
If you have quantifiable expectations though, like "CD-quality", you can do the math (and then try it).
There might be another issue with the ESP32 as a systemic one:
aside from your ADC supplying samples, your CPU must be able to do something with these samples, before the next sample happens.
Often, that's no big issue, at least at audio-typical sampling rates: simply have a DMA controller copy the samples from ADC to a RAM buffer, and then regularly process whatever has amassed in that buffer with the CPU.
Now, what could happen in your use case is that there's Wifi-handling firmware that occasionally needs to grab the CPU core, and needs to do a couple calculations, so that the time window to process the buffer before it's full passes.
I don't know whether that's the case in the ESP32 architecture – other Wifi-integrating MCUs do in fact do a couple of things in CPU software that preempts whatever executes on the CPU occasionally.