Make VU meter symmetrical to center module
This commit is contained in:
parent
c15d815da9
commit
bac8df287c
20
vumeter.lua
20
vumeter.lua
|
@ -1,5 +1,5 @@
|
|||
COOLDOWN_FACTOR = 0.9998
|
||||
FACTOR = 0.2
|
||||
FACTOR = 0.033
|
||||
|
||||
num_modules = 20
|
||||
center_module = 10
|
||||
|
@ -44,21 +44,33 @@ function periodic()
|
|||
local brightness = rms / maxRMS
|
||||
|
||||
for i = 1,num_modules do
|
||||
if i <= num_modules * redEnergy / maxRedEnergy then
|
||||
if i <= center_module and
|
||||
center_module - i < center_module * redEnergy / maxRedEnergy or
|
||||
i > center_module and
|
||||
i - (center_module + 1) < (num_modules-center_module) * redEnergy / maxRedEnergy
|
||||
then
|
||||
redTarget = brightness
|
||||
else
|
||||
redTarget = 0
|
||||
end
|
||||
red[i] = (1 - FACTOR) * red[i] + FACTOR * redTarget;
|
||||
|
||||
if i <= num_modules * greenEnergy / maxGreenEnergy then
|
||||
if i <= center_module and
|
||||
center_module - i < center_module * greenEnergy / maxGreenEnergy or
|
||||
i > center_module and
|
||||
i - (center_module + 1) < (num_modules-center_module) * greenEnergy / maxGreenEnergy
|
||||
then
|
||||
greenTarget = brightness
|
||||
else
|
||||
greenTarget = 0
|
||||
end
|
||||
green[i] = (1 - FACTOR) * green[i] + FACTOR * greenTarget;
|
||||
|
||||
if i <= num_modules * blueEnergy / maxBlueEnergy then
|
||||
if i <= center_module and
|
||||
center_module - i < center_module * blueEnergy / maxBlueEnergy or
|
||||
i > center_module and
|
||||
i - (center_module + 1) < (num_modules-center_module) * blueEnergy / maxBlueEnergy
|
||||
then
|
||||
blueTarget = brightness
|
||||
else
|
||||
blueTarget = 0
|
||||
|
|
Loading…
Reference in a new issue