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
Re: Analog audio stops working randomly
FYI to all. Dumb.. It turns out I am using the neopixel library and then trying to use analog audio. Cannot do this.. Ugh!
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 3595
- Joined: Mon Sep 29, 2014 1:07 pm
- Location: Cambridge
Re: Analog audio stops working randomly
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?
Where would I find this library?
Re: Analog audio stops working randomly
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.
Using those libs.
But yah for sure, the second I light up the strip audio is dead until reboot.
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 3595
- Joined: Mon Sep 29, 2014 1:07 pm
- Location: Cambridge
Re: Analog audio stops working randomly
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.
Re: Analog audio stops working randomly
I got a USB sound card working as a workaround. My Halloween project is alive!
Re: Analog audio stops working randomly
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
https://astro-pi.org