local flashUntil = 0
local FLASH_MS = 120
local REST_R, REST_G, REST_B = 0.12, 0.12, 0.12
function onReceiveOSC(message, connections)
local beat = 0
if message[2] and message[2][1] and message[2][1].tag == 'i' then
beat = message[2][1].value
end
if beat == 1 then
self.color = Color(1.0, 0.55, 0.0)
elseif beat == 2 or beat == 4 then
self.color = Color(0.0, 0.75, 0.9)
else
self.color = Color(0.2, 0.85, 0.3)
end
flashUntil = getMillis() + FLASH_MS
end
function update()
if getMillis() > flashUntil then
self.color = Color(REST_R, REST_G, REST_B)
end
end