Raspberry Pi Zero + Audio Amp Shim: Slow Audio Output

Hello y’all. I’m working on converting an old rotary phone into a simple audio player. For this I got an RPi Zero WH (32bit, not a Zero 2), with the RPi OS Lite and the Pimoroni Audio Amp Shim. The Audio Amp is able to drive the receivers old mono speaker perfectly, though I noticed that the audio is playing slow. At first I thought that it’s a CPU issue, because I was playing an MP3 and that decoding was burning too many cycles, but the CPU was <20%.

To debug I created 3 audio files with sox, each playing a sine at 1000 Hz at 32k, 44.1k and 48k and then I used an audio analyzer on my iPhone to measure if I’m getting also the 1000 Hz. On my MacBook I confirmed that indeed these 3 files play at 1000 Hz. On the RPi they all played at 667 Hz, so this explains at least the slowness I’m hearing when playing an MP3.

The ensure nothing is messing with the RPi, I did double check that 1) I had no PulseAudio; 2) no ALSA config files (i.e. I deleted ~/.asoundrc, and /etc/asound.conf never existed) and then played directly with aplay -D hw:0,0 1k_48.wav.

As this was basically the end of my knowledge, I then turned to Google, LLMs and whatnot to help me further, but no matter what hunch I tried (i.e. switching the dtoverlay to use basic i2s-dac, or the Google DAC or whatever, trying some ALSA config magic), it always did show the same slowdown (or sometimes even played the files at 500 Hz).

The only “solution” (i.e. workaround) that I did find is to just play stuff faster, like e.g. ffplay -nodisp -autoexit -af “asetrate=66150,aresample=44100” risingsun.mp3, but that isn’t how it’s supposed to be and for this I’d need the sample rate beforehand.

According to LLMs the issue seems to a miss match between BCLK:LRCLK ratio / framing, and that the Pi Zero’s I²S master clock running at a different speed. But to be frank, while I understand roughly the concept the subsystems and required low-level audio processing is out of my league.

But: I’d love to fix it and have audio playing right.

Did anyone run into something similar, what could be the root cause, because I have the feeling that it’s a stupid mistake somewhere.

Any help or input much appreciated, thank you.

Configuration

When running aplay -l I can see the snd_hifiberry, so looking OK. As stated earlier, I ensured that there’s no PulseAudio, and no ALSA configuration files at all.

# /boot/firmware/config.txt

# [...] commented out earlier `audio=on` stuff, otherwise default
# add the following at the very very end:
[all]
# 2025-10-17: use hifiberry for Audio
dtoverlay=hifiberry-dac
gpio=25=op,dh
dtparam=audio=off
cat /proc/cpuinfo

Hardware : BCM2835
Revision : 9000c1
Serial : 00000000f32abb88
Model : Raspberry Pi Zero W Rev 1.1
cat /etc/os-release

VERSION_CODENAME=trixie
DEBIAN_VERSION_FULL=13.1
pinctrl get 18,19,21,25

18: a0 -- | hi // GPIO18 = PCM_CLK
19: a0 -- | hi // GPIO19 = PCM_FS
21: a0 -- | lo // GPIO21 = PCM_DOUT
25: op -- -- | hi // GPIO25 = output

When playing a 48k WAV, the pcm clock speed reports ~1’536’000 Hz:

grep -E ' pcm ' /sys/kernel/debug/clk/clk_summary

          pcm 1 1 0 1536000 0 0 50000 Y 20203000.i2s no_connection_id

I think I was able to solve it for now, based on some linked articles about other DACs, like Issue: PhatDac on Pi Zero with pigpio and moode 6.3 - #14 by alphanumeric (I can’t add more than two links, so…)

For anyone running into this, it was pigpiod interfering, I added -t 0 as described in pigpio library , not yet sure if this is really the best solution and if this leads to other challenges with GPIOs, but at least: audio plays perfect that way.

1 Like