onlaj / Piano-LED-Visualizer

Piano LED Visualizer: Connect an LED strip to your Raspberry Pi and create an immersive visual experience for your piano playing
MIT License
513 stars 111 forks source link

IndexError list assignment index out of range, crash when playing outside of LED strip range #375

Closed sreich closed 2 years ago

sreich commented 2 years ago

I have an 88 key piano and I set the visualizer to 144. It is 144 leds and it is the WS281X led strip

I get the below array index error. it seems to only happen on the far keys, past the light strip. Shouldn't the LED setting I set, set that limit properly?

I don't understand the usage of the offsets, but I have light number 92 = offset 2, 55 = offset 1. These were just defaults i think

May 31 14:07:07 raspberrypi systemd[1]: Stopped Piano LED Visualizer. May 31 14:07:07 raspberrypi systemd[1]: visualizer.service: Consumed 2min 7.041s CPU time. -- Boot 1b81c9066c124aa2a35c3db8079c7ecb -- May 31 14:08:45 raspberrypi systemd[1]: Started Piano LED Visualizer. ...skipping... Aug 19 20:23:07 raspberrypi sudo[766]: Connection is already subscribed Aug 19 20:23:07 raspberrypi sudo[768]: Connection is already subscribed Aug 19 20:23:07 raspberrypi sudo[772]: Connection is already subscribed Aug 19 20:23:30 raspberrypi sudo[646]: Socket listening on: 192.168.86.151:8765 Aug 19 20:23:30 raspberrypi sudo[646]: Namespace(clear=False, display=None, fontdir=None, port=None, skipupdate=False, webinterfa> Aug 19 20:23:30 raspberrypi sudo[646]: Can't load input port: rtpmidi raspberrypi:sreich-archlinux-desktop/PipeWire-RT-Event-inpu> Aug 19 20:23:30 raspberrypi sudo[646]: Can't load input port: mio:mio MIDI 1 16:0 Aug 19 20:23:30 raspberrypi sudo[646]: Starting webinterface Aug 19 20:23:30 raspberrypi sudo[646]: Can't reconnect play port: mio:mio MIDI 1 16:0 Aug 19 20:23:30 raspberrypi sudo[646]: Can't reconnect play port: mio:mio MIDI 1 16:0 Aug 19 20:23:30 raspberrypi sudo[646]: Can't reconnect play port: mio:mio MIDI 1 16:0 Aug 19 20:23:30 raspberrypi sudo[646]: Traceback (most recent call last): Aug 19 20:23:30 raspberrypi sudo[646]: File "/home/Piano-LED-Visualizer/visualizer.py", line 397, in Aug 19 20:23:30 raspberrypi sudo[646]: ledstrip.keylist_color[note_position] = [red, green, blue] Aug 19 20:23:30 raspberrypi sudo[646]: IndexError: list assignment index out of range Aug 19 20:23:30 raspberrypi sudo[642]: pam_unix(sudo:session): session closed for user root Aug 19 20:23:30 raspberrypi systemd[1]: visualizer.service: Main process exited, code=exited, status=1/FAILURE Aug 19 20:23:30 raspberrypi systemd[1]: visualizer.service: Failed with result 'exit-code'. Aug 19 20:23:30 raspberrypi systemd[1]: visualizer.service: Consumed 4min 101ms CPU time. Aug 19 20:28:45 raspberrypi systemd[1]: Started Piano LED Visualizer. Aug 19 20:28:45 raspberrypi sudo[1082]: pi : PWD=/ ; USER=root ; COMMAND=/usr/bin/python3 /home/Piano-