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
494 stars 107 forks source link

Add led gamma correction #473

Closed stephen322 closed 9 months ago

stephen322 commented 9 months ago

This adds gamma correction to support a perceptual linear brightness gradient due to LED dithering/PWM. https://learn.adafruit.com/led-tricks-gamma-correction/the-issue Left at gamma of 1 for backwards compatibility - no change, but use 2.8 to get the effect in the article.

Updated rpi_ws281x in the process. And attempted to convert all internal RGB order logic to RGB rather than GRB. Hope I got everything.

stephen322 commented 9 months ago

After trying it out for a while, I think original gamma of 1 is best, since this project is designed that way -- bright colors adjusted with the brightness slider. Gamma > 1 also means lost colors. Only applicable consideration would be for the fade mode to produce a more gradual fade, but that can be coded with a custom algorithm.

The other consideration, and the reason I was investigating gamma, is because I want to implement various colormaps for use in Velocity Rainbow and a new color mode. But I can create colormaps with this in mind.

Maybe gamma correction UI should be moved to Advanced Mode?

onlaj commented 9 months ago

Later I will move the "advanced mode" switch somewhere else for easier access. I tested it and it works fine. Thank you for your contribution, merging.