scottlawsonbc / audio-reactive-led-strip

:musical_note: :rainbow: Real-time LED strip music visualization using Python and the ESP8266 or Raspberry Pi
MIT License
2.68k stars 644 forks source link

Constant Freezing on Raspberry Pi 3B+ #213

Open BreakPoints opened 5 years ago

BreakPoints commented 5 years ago

I've installed the ws281x library from https://github.com/jgarff/rpi_ws281x.git and the included strandtest.py works perfectly but running this projects visualization.py, I am getting constant freezing of both the LEDs and the FPS count, but not always at the same time.

I've setup everything in the config.py file and the LEDs are reacting to the microphone but only for a few seconds, then it freezes for well over a minute with 2-3% CPU usage. I've tried turning down the FPS, turning off the GUI and FPS counter, none of this works. What does help, for some reason, is launching other software. For example launching Chromium kicks the LEDs back into action for quite a while but once Chromium has finished loading up, it doesn't take long for the LEDs to freeze again.

Leaving it running causes the LEDs to intermittently freeze for long periods until eventually it freezes indefinitely.

LessThanThreeMan commented 5 years ago

Having the same issue. I may try it with the logic converter tomorrow to see if that helps, but I'm skeptical.

All resources on the Pi seem underutilized. CPU usage is incredibly low, the GUI is off, the whole thing just seems to spontaneously lock up for seemingly no good reason.

It's also worth noting that the LEDs run fine in all test modes.

BreakPoints commented 5 years ago

I'm already using a logic converter so I don't think that's the problem.

I may have to try some of the forks and see if the issue exists there as well.

LessThanThreeMan commented 5 years ago

I'm pretty sure it's something to do with the audio stream more than anything based on the errors I'm starting to get. It runs fine until it hits the end of this string in console.

pi@raspberrypi:~/Downloads/audio-reactive-led-strip-master/python $ sudo python visualization.py ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device' ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device' ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa Cannot connect to server socket err = No such file or directory Cannot connect to server request channel jack server is not running or cannot be started JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock Traceback (most recent call last): File "visualization.py", line 356, in microphone.start_stream(microphone_update) File "/home/pi/Downloads/audio-reactive-led-strip-master/python/microphone.py", line 14, in start_stream frames_per_buffer=frames_per_buffer) File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 750, in open stream = Stream(self, *args, kwargs) File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 441, in init self._stream = pa.open(arguments) IOError: [Errno -9996] Invalid input device (no default output device)

BreakPoints commented 5 years ago

I've come across someone claiming that these errors don't matter and that they get them and it still works. May have been in reference to just some of the errors, though. I do get the same messages.

LessThanThreeMan commented 5 years ago

I just can't shake the feeling that the audio isn't reading into the Pi correctly since the code seems to run fine for most people and we know our LEDs are in working order. I'm not terribly familiar with Linux/Raspbian or Python, but checking the audio feed/playback (in terms of the Pi) seems like something worth looking into. The audio passes through to my sound system just fine.

Either that or there's maybe a memory leak in the code? I dunno.

How many pixels are you running by the way?

BreakPoints commented 5 years ago

Maybe it's a bug with a certain version of the dependencies for reading in audio or doing spectrum analysis.

I'm running 60 LEDs by the way, shouldn't be any issue for the Pi model I'm using.

DMKOfficial commented 5 years ago

My SD card broke yesterday in my pi 3b+, so i had to reinstall everything and now i have the exact same issue, but i installed it the same way as before and it was working flawlessly for the past months. Any fix so far?

DMKOfficial commented 5 years ago

Set LED_DMA = 10 in config.py solved it for me

BreakPoints commented 5 years ago

DMKOfficial, I never thought about changing the DMA channel!

That's solved the issue for me as well, performance is a little lower than what other people are claiming but no pauses in sight. Thank you!