That is a first order bandpass filter, with a high frequency roll-off at about 20 kHz, which means it reduces the "buzz" by only 3 dB at 20 kHz.
As you have noticed, that isn't much reduction. A 3rd or 4th order filter with a significantly lower rolloff frequency would do a better job. There are plenty of design guides on the web.
In any case, PWM audio sampled at 22 kHz cannot reproduce audio signals with frequency > 11 kHz, and should not be expected to. It is fine for voice audio, limited to about 8 kHz.
The "buzz" might be something different, but a real DAC should work better.
The Raspberry Pi MIGHT run at a higher frequency.
Class-D amplifiers are "similar" to PWM but they usually run at hundreds of kHz (sometimes 1MHz) and the good ones have L-C filters.
I've read about amplifier chips getting hot and not putting any sound (or very weak sound) and I would NEVER feed into my home theater amplifier, or any high-power amp, or any amp that I cared about. Even when putting-out "silence" it's full-voltage PWM (before filtering)
Thank you !
I didn't know it was a bandpass.
In the case of "classic" bytebeat running at 8Khz, the maximum frequency rate is 4Khz, so I don't know if I should improve this filter.
@DVDdoug
Yeah, i'm thinking more and more about a DAC. I wonder if using a DAC is more CPU consuming than the hardware PWM of the pico.
Because I thinking more and more that this "buzz" is some audio artifact caused by too large consumption of CPU ressources.
Are they ways to know if the CPU is too slow for handling all the functionnalities ? (parsing of bytebeat formule, display, audio, buttons & potentiometers, MIDI, webusb ?)
I think you are already very close to the truth of the problem.
Background noise is often related to the design of the power supply.
So in our audio Bluetooth product manual, we always remind users to pay attention to power supply when designing in this way:
“Power supply requirements matter. lf audio is involved, a clean power supply affectsaudio noise. The dirtier the power, the more troublesome the audio processing. A phonecharger's 5V output is typically very clean and usually doesn't cause significantbackground noise. lf audio isn't used, a slightly less clean power supply is fine.”
I tried several things and I'm little disappointed...
The complete circuit provided by the rp2040 book is for a line level. For me it's not helpful, I would like to listen to the synth with headphones
Also tried a 2nd order filter with R=1k and C=10nF, works pretty great but the volume is too attenuated
I put a LM358 in follower configuration just for giving more power to the signal with a capacitor in serie just in front of the audio jack and I think it's better. The problem ? The LM358 is powered by the 3V3 or 5V of the pico and parasited by the other periphericals around (I think)
That is a very poor filter design. It is not a second order filter at all. It is just two RC filters one after the other. This is not a second order filter because the impedances interfere with each other. That op amp is not doing very much for you either.
Look up how to design active filters.
Noise from the PWM is mainly due to the impedance matching between the signal and the input to any amplifier.
The input impedance of the amplifier is normally high, and it needs to be low so it does not pick up noise. Make it low by putting a low resistor, like 2K2 across it’s imput.
The sound is a little better but I always have this unpleasant sound when the AOP is wired to the VSYS(5V) of the pico and the potentiometer full open
So I place a 2.2k in serie with the pot input and it help a little
After that I unplugged my SSD1309 screen and it improved a lot the background noise so maybe provide a clean supply to the AOP will help ?
I tried to add a voltage regulator (MCP1700 33) with two 1u cap for supply the AOP, but it doesn't seems to improve much (this time it doesn't get hot)
I decided to scope the PWM output directly (with screen plugged) and remark something, when I stop the dutycycle update with a button (works like a looper) if the pwm looks like this
PWM direct output
Note there are two parts to this, first is the way the way I apply the signal to the input, and second is the way I filter the power supply to the amplifier. Note the use of a small inductor in the filter.