I am currently working on a project that includes a SD Card, an amplifier, a speaker and an Arduino Mega. I am using the TMRCPM library to play music, but something strange happens. Every time when I restart the Arduino and play a WAV file, I hear a very loud popping sound before the file starts. Then when I play the next one there is no pop. When I restart the Arduino the first file has a pop. It doesn't matter which file I play first. It is always only at the first file. Can anybody help me to fix this? I think it is a setting in the TMRPCM Library.
Regular audio is AC (it goes positive & negative). The Arduino can't put-out negative voltages so the output should be biased at 2.5V. Then the audio signal goes positive an negative relative to that bias. When the bias suddenly kicks-in, you'll get a pop. The same thing often happens when you power-on (ore power-off) an amplifier with a single-positive power supply. (A series capacitor can filter-out the bias to give you a signal that truly goes positive & negative, but you'll still get a pop when the bias is switched-on.)
You might be able to "slowly" ramp-up the output (over 1/10th of a second or more) but you'll have to increase the PWM frequency first so you don't hear the PWM.
Thank you doe your reaction but do you know how I can program the slowly ramp up etc. in combination with the tmrcpm library. I am not that experienced in programming