Browse Source

Make VU meter symmetrical to center module

lua
Thomas Kolb 8 years ago
parent
commit
bac8df287c
1 changed files with 16 additions and 4 deletions
  1. +16
    -4
      vumeter.lua

+ 16
- 4
vumeter.lua View File

@@ -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…
Cancel
Save