I'm using a Raspberry Pi 4 with an Adafruit I2S Stereo speaker bonnet. I've run their setup script and rebooted many times.
I can play sample
mp3 files just fine. They
usually sound great. (I've had some distortions in some cases, but not always).
I can also use
espeak without any noticeable problems.
I've also downloaded some sample
wav files that seem to work file.
The problem arises with some
wav files that I created in Garage Band. When I try to play these, I get some normal audio, but then also a lot of scratchy audio to go with it. Changing the volume with
alsamixer changes the distortions but does not monotonically scale the output volume as expected indicating some other type of conflict. Playing the possibly bad files on Windows or MacOS works fine.
Sample wav files at various bitrates (including the bitrate of the problematic files) work fine.
I've tried reducing the amplitude of the problematic wave files with
sox -v 0.1 but that maintains the distortion.
Any thoughts on what to try would be greatly appreciated.
Some of my problems were caused by pigpio using the PCM timer for GPIO operations. Switching to use PWM timer fixed that problem.
I still have problems playing the files but now the scratchiness is showing up on the files on Windows. I'm wondering if some aggressive CR/LF conversion tried to happen which broke the binary wav file.