Page 1 of 1

ESP32 DAC producing popping noise on the speaker

Posted: Thu Dec 08, 2022 12:14 pm
by thassan
On ESP32's DAC, I am producing cosine waves of frequencies between 20KHz - 30KHz over a period of 1000ms. After 1000ms, the wave generation is stopped. Furthermore, after every 50ms, the wave frequency is randomly changed between the specified range of 20KHz - 30KHz using a timer callback function.

I am using a modified version of DAC Cosine Wave Generator example [https://github.com/espressif/esp-idf/bl ... ple_main.c]

After every 50ms, whenever the program switches to a different frequency, I hear 'popping' noise on the speaker. So in a period of 1000ms, frequency switches about 20 times and hence that means a lot of popping. I am using a 3W Audio Amplifier (PAM8403) and 150W speaker (also tried a 0.5W speaker). The popping noise is negligible at low frequencies (e.g. 1-3 KHz)

Following is a sample of the audio generated (range : 20-30KHz): (use headphones)
https://drive.google.com/file/d/1bJ9Bz_ ... sp=sharing

And following is a sample with low frequencies (range : 2-3KHz): (use headphones)
https://drive.google.com/file/d/1DPwqbH ... sp=sharing

I want to know about the cause of this popping noise on the speaker.

Re: ESP32 DAC producing popping noise on the speaker

Posted: Mon Dec 12, 2022 4:52 am
by username
I want to know about the cause of this popping noise on the speaker.
Use a scope to look at the signal.

When you stop your DAC leave the output at midrange. Odds are its going to gnd when off, so when it starts you get the pop.
Or it could be how you have the output coupled to the amp. Do you have a series cap to your amp ?

Re: ESP32 DAC producing popping noise on the speaker

Posted: Mon Dec 12, 2022 12:05 pm
by bobolink
Are you keeping the phase continuous between frequency changes? The human ear is very sensitive to phase discontinuity :)

Re: ESP32 DAC producing popping noise on the speaker

Posted: Mon Dec 12, 2022 4:52 pm
by Craige Hales
1) If you don't have a scope, use audacity to see the wave form in the audio file.
audacity.png
audacity.png (60.77 KiB) Viewed 3276 times
2) The high frequency file appears to be a codec that has a 48kHz sample rate. Your frequencies > 24kHz will create horrible artifacts called aliasing.
VLC.png
VLC.png (54.06 KiB) Viewed 3276 times
The low frequency file looks better. The mpeg compression also adds artifacts. You might want to use an uncompressed .wav file. There might be a standard for 96kHz sampling, which would get you to 48kHz frequencies. None of my consumer grade hardware would be able to do that.