ESP32 DAC producing popping noise on the speaker

thassan
Posts: 5
Joined: Mon Nov 21, 2022 9:19 am

ESP32 DAC producing popping noise on the speaker

Postby thassan » Thu Dec 08, 2022 12:14 pm

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.

username
Posts: 528
Joined: Thu May 03, 2018 1:18 pm

Re: ESP32 DAC producing popping noise on the speaker

Postby username » Mon Dec 12, 2022 4:52 am

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 ?

bobolink
Posts: 98
Joined: Mon Feb 26, 2018 4:17 pm

Re: ESP32 DAC producing popping noise on the speaker

Postby bobolink » Mon Dec 12, 2022 12:05 pm

Are you keeping the phase continuous between frequency changes? The human ear is very sensitive to phase discontinuity :)

Craige Hales
Posts: 94
Joined: Tue Sep 07, 2021 12:07 pm

Re: ESP32 DAC producing popping noise on the speaker

Postby Craige Hales » Mon Dec 12, 2022 4:52 pm

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 3156 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 3156 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.
Craige

Who is online

Users browsing this forum: Bing [Bot] and 274 guests