fredfs
Posts: 58
Joined: Sun Jun 07, 2015 12:22 am

Re: Analogue audio redux

Tue May 28, 2019 11:41 pm

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.

pik33
Posts: 183
Joined: Thu Sep 10, 2015 4:26 pm

Re: Analogue audio redux

Thu Jul 11, 2019 7:24 am

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.

https://github.com/pik33/SimpleAudio

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?

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2159
Joined: Thu Jul 11, 2013 2:37 pm

Re: Analogue audio redux

Thu Jul 11, 2019 5:50 pm

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.
Rockets are loud.
https://astro-pi.org

pik33
Posts: 183
Joined: Thu Sep 10, 2015 4:26 pm

Re: Analogue audio redux

Thu Jul 11, 2019 8:26 pm

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?)

Return to “Advanced users”