Andrew Davie wrote:Purely by chance, when manipulating the circuit design in "Eagle", I stumbled across some notes about the "SD" pin on the PAM8302A amplifier board. This is a "sound disable" pin, and the notes said that it was useful to fix the "pops" on the speaker when turning on/off. I can surmise that it handles the speaker position to remove the jarring pops automatically, so you can basically send the speaker anything at startup and not worry about where it might "be". That's great, as I don't have to do it in code. So I added the "SD" pin to my circuit diagram connections, going to pin 5 on the Arduino. I now need to write a few "enable SD" and "disable SD" type switching in the software at the appropriate places. Handy.
Well, I did this but the results are disappointing. Yes, the SD enable/disable works, but unfortunately the amp isn't 'intelligent'. The enable/disable is just an on-off and it had no effect whatsoever upon the jarring clicks and pops. So I reverted to a software solution. I have a flag that tells me when video is running or not. The interrupt that services the sound and audio runs all the time, no matter what - so this flag is necessary to prevent the interrupt from advancing the video/audio index pointer. That all works fine. What I do is store the audio value in a variable, so we always know what the audio (=speaker position) is. When the video is NOT running, then I slowly return the audio variable to the "zero" position - over a second or so. That is, a very small movement is made each interrupt such that the movement is inaudible. This solution seems to have almost totally removed the clicks and pops and now I can random-access via the slider to any point in the video and I don't have those annoying sounds. Yay.