Thomas Kolb
d4a2e7ef4c
- basic configuration is now done via a lua script - all the animation is generated by a lua script (see pulsetunnel.lua and vumeter.lua for examples) - basic calculations (FFT, RMS) are done in C and accessible on demand from the lua scripts
71 lines
1.5 KiB
Lua
71 lines
1.5 KiB
Lua
COOLDOWN_FACTOR = 0.9998
|
|
|
|
num_modules = 20
|
|
center_module = 10
|
|
|
|
-- maximum energy values for each band
|
|
maxRedEnergy = 1
|
|
maxGreenEnergy = 1
|
|
maxBlueEnergy = 1
|
|
|
|
-- output color buffers
|
|
red = {}
|
|
green = {}
|
|
blue = {}
|
|
|
|
function periodic()
|
|
local redEnergy = get_energy_in_band(0, 400);
|
|
local greenEnergy = get_energy_in_band(400, 4000);
|
|
local blueEnergy = get_energy_in_band(4000, 22000);
|
|
|
|
maxRedEnergy = maxRedEnergy * COOLDOWN_FACTOR
|
|
if redEnergy > maxRedEnergy then
|
|
maxRedEnergy = redEnergy
|
|
end
|
|
|
|
maxGreenEnergy = maxGreenEnergy * COOLDOWN_FACTOR
|
|
if greenEnergy > maxGreenEnergy then
|
|
maxGreenEnergy = greenEnergy
|
|
end
|
|
|
|
maxBlueEnergy = maxBlueEnergy * COOLDOWN_FACTOR
|
|
if blueEnergy > maxBlueEnergy then
|
|
maxBlueEnergy = blueEnergy
|
|
end
|
|
|
|
-- move the color buffers on by one in each direction
|
|
for i = 2,center_module,1 do
|
|
red[i-1] = red[i]
|
|
green[i-1] = green[i]
|
|
blue[i-1] = blue[i]
|
|
end
|
|
|
|
for i = num_modules-1,center_module,-1 do
|
|
red[i+1] = red[i]
|
|
green[i+1] = green[i]
|
|
blue[i+1] = blue[i]
|
|
end
|
|
|
|
-- set the new value for the center module
|
|
red[center_module] = redEnergy / maxRedEnergy
|
|
green[center_module] = greenEnergy / maxGreenEnergy
|
|
blue[center_module] = blueEnergy / maxBlueEnergy
|
|
|
|
-- return the 3 color arrays
|
|
return red, green, blue
|
|
end
|
|
|
|
function init(nmod, cmod)
|
|
num_modules = nmod
|
|
center_module = cmod
|
|
|
|
for i = 1,nmod do
|
|
red[i] = 0
|
|
green[i] = 0
|
|
blue[i] = 0
|
|
end
|
|
|
|
-- don't use fading
|
|
return 0
|
|
end
|