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
517 stars 111 forks source link

The led light does not align with some keys #270

Closed Joker-rider closed 2 years ago

Joker-rider commented 2 years ago

Hi guys, Is there a way to adjust the separation between the leds to line them up with the keys? I have a little problem where as the keys go down or up the light alignment drifts. The central C and a few other keys are perfectly aligned. My 76-key keyboard. Config origin. I tried to adjust with the web interface but apart from moving the leds and my central C nothing changes. Impossible to say that when I reach a certain key the led on changes. Example: C = do = LED 72 + 8 = OK Coming down : Note D# (Re #) = LED 63 = OK, (Re #) = LED 39 = KO => LED 40 = OK. And amount Note B (if)(si) = LED 72 + 30 = KO => LED 72 + 29 = OK 16362221212827683533777697058386 16362222367564817665638788167103

For information i'm french

Thank you for your help

onlaj commented 2 years ago

Hello. It seems unusual, I wonder if the reason is the non-standard width of the piano keys or maybe a different model of the led strip. I will try to make some option to adjust spacing, but for now you can try to fix it by yourself. The function that is responsible for that is located in /lib/functions.py under

def get_note_position(note, ledstrip):
    if note > 92:
        note_offset = 2
    elif note > 55:
        note_offset = 1
    else:
        note_offset = 0

It means that for notes higher than 92 the offset it equal to 2, and for notes higher than 55 (but lower than 92) it's 1. You can try to adjust those values, change 92 to something lower like 72, and 55 to 35, you need to test it by yourself.

Joker-rider commented 2 years ago

Hello Thanks I will test the solution tonight and give a feedback.

Joker-rider commented 2 years ago

Hello. Is there a possibility of being able to carry out several offset? Example : one for note 92 , one in note 72, one in note 55 and one in note 35? Two offset towards lower notes and tow offset towards upper notes.

Joker-rider commented 2 years ago

Hello is there a test mode to light all the leds corresponding to the keyboard notes in order to best place the led strip. the ideal would be to be able to make the adjustments directly with the leds on (number of keys = leds, offset settings in order to correct the drifts ...)

I am still in settings mode to align the leds on my keys.

Bye

Joker-rider commented 2 years ago

Hello Onlaj, I would like to know if it is possible to put more than two offsets (example 4 offsets)?

onlaj commented 2 years ago

Yes, just edit the code accordingly.

for example:

def get_note_position(note, ledstrip):
    if note > 92:
        note_offset = 3
    elif note > 55:
        note_offset = 2
    elif note > 35:
        note_offset = 1
    else:
        note_offset = 0
Joker-rider commented 2 years ago

Ok Onlaj. I made this change, but it blocked the raspberry (white screen) and web interface not accessible. Nothing Works anymore. A step back solves the problem

Joker-rider commented 2 years ago

Hello Onlaj Have you other solution ?

onlaj commented 2 years ago

Can you show me how you edited the "get_note_position" function? Screenshot of your text editor will be fine.

Joker-rider commented 2 years ago

Hello, here is the screenshot IMG_20211118_222159

Joker-rider commented 2 years ago

Hello Onlaj do you have solution to my problem ? Thank you so much

onlaj commented 2 years ago

Sorry, somehow I missed last response. Can you launch visualizer (with your changes) manually?

sudo python3 /home/Piano-LED-Visualizer/visualizer.py

if it crash post an error message here.

Joker-rider commented 2 years ago

Here is the test. IMG_20211122_212453

onlaj commented 2 years ago

Did you copy the code from here or retype it by yourself? When editing code, use 4 spaces instead of tabs.

Joker-rider commented 2 years ago

I used 4 spaces instead of tabs and it worked. Perfect. Thank you so much.