ril3y
Posts: 6
Joined: Tue Oct 27, 2020 6:58 pm

Analog audio stops working randomly

Tue Oct 27, 2020 7:03 pm

I have a rpi 4 that is setup and plays sounds out of the headphone jack just fine. However, after a bit of time (random?) If I try to play again all I get is static or a hiss. So sound works just not for long.

Application, I am writing a python script that starts a thread and plays a sound file. The first time it seems to work fine. (always) but subsequent plays will fail randomly then never work again without a reboot. Anyone have any ideas about this? Its a Halloween prop and I am really hoping to get it working reliably soon!

ril3y

ril3y
Posts: 6
Joined: Tue Oct 27, 2020 6:58 pm

Re: Analog audio stops working randomly

Wed Oct 28, 2020 2:12 am

FYI to all. Dumb.. It turns out I am using the neopixel library and then trying to use analog audio. Cannot do this.. Ugh!

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3595
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Analog audio stops working randomly

Wed Oct 28, 2020 8:45 am

That's a bit surprising - I've not used the neopixel library, but the BCM2711 in the Pi 4 (unlike previous Pi SoCs) has an extra PWM block that drives the analogue audio out, leaving the old block free to do other PWMy things.

Where would I find this library?

ril3y
Posts: 6
Joined: Tue Oct 27, 2020 6:58 pm

Re: Analog audio stops working randomly

Wed Oct 28, 2020 1:18 pm

https://learn.adafruit.com/neopixels-on ... thon-usage

Using those libs.

But yah for sure, the second I light up the strip audio is dead until reboot.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3595
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Analog audio stops working randomly

Wed Oct 28, 2020 2:44 pm

The userspace driver in the rpi_ws281x library changes the PWM clock from 107MHz to 24KHz. There's not much the firmware can do about that.

ril3y
Posts: 6
Joined: Tue Oct 27, 2020 6:58 pm

Re: Analog audio stops working randomly

Wed Oct 28, 2020 3:21 pm

I got a USB sound card working as a workaround. My Halloween project is alive!

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

Re: Analog audio stops working randomly

Thu Oct 29, 2020 5:18 pm

PhilE wrote:
Wed Oct 28, 2020 2:44 pm
The userspace driver in the rpi_ws281x library changes the PWM clock from 107MHz to 24KHz. There's not much the firmware can do about that.
There shouldn't be a need to clobber the PWM frequency on Pi 4 at all - ws2812 bashers typically use the PWM peripheral in serialiser mode which means you can avoid messing with the clock by stretching out the bit-times to match.
Rockets are loud.
https://astro-pi.org

Return to “Troubleshooting”