Page 4 of 4

Re: Analogue audio redux

Posted: Tue May 28, 2019 11:41 pm
by fredfs
On most recent firmware (archlinux-arm)
using audio_pwm_mode=2
makes MPD music sound slower, like some frequency rate error.
audio_pwm_mode=1, sound good.

Re: Analogue audio redux

Posted: Thu Jul 11, 2019 7:24 am
by pik33
Some time ago I wrote this driver for a RPi bare metal environment (Ultibo). It uses 2nd order noise shaping filter and ~960 kHz 8-bit samples. It can still be improved, but as it is now, it is clip free and doesn't create distorted sound even at 100% volume.

Maybe it can be used to improve the RPi audio jack sound quality.

Can someone tell the addresses of the hardware registers in RPi4 so maybe I can try it on this machine?

Re: Analogue audio redux

Posted: Thu Jul 11, 2019 5:50 pm
by jdb
From my reading of the assembler loop, you are "oversampling" by repeating the input sample used for the quantisation and noise shaping, correct?

This is suboptimal as zero-order-hold (what you're doing) does not significantly band-limit the input spectrum. Noise shaping only works effectively if the input signal is a fraction of the total input bandwidth. The firmware uses a much more sophisticated oversampling scheme to bandlimit the input signal - a length=512/x8 FIR filter followed by a length=4/x2 FIR filter for a very sharp cutoff and minimal stop-band leakage.

Re: Analogue audio redux

Posted: Thu Jul 11, 2019 8:26 pm
by pik33
Yes, the oversampling is simply repeating the sample. I don't need any fitering before oversampling (what for?), and yes, the filter after the oversampling is useful. I have done such filter (simple IIR one) today and I will try to add it and compare the results. The lack of this filter may be a reason I didn't get any good result trying to set the sampling frequency higher than 960 KHz. I have an idea is to use PWM in serializer mode outputting 2nd or 3rd order noiseshaper output at 1bit/7.2 MHz. Using the serializer mode will significantly lower the memory bandwidth needed.

As it is now, in my subjective opinion my driver (on RPi3) gives better sound quality than the original RPi4's driver: I use my RPi3 with my (far from finished) driver, player and GUI code as an audio player :) - everyday :)

The only problem is I had to overclock memory/core subsystem on RPi3 to get a click-free audio @ 960 kHz. There is possibility to lower the frequency to 640 kHz in the code - as I read here you used something about 700 kHz and I think it means fractional divisor on PLL - is it safe to use non-integer division rate for audio? (jitter?)