I have this instrument where there is an LFO(a) modulating the rate of another LFO(b). When ‘a’ is activated it works as expected, however when ‘a’ is later deactivated, the rate of ‘b’ on the macro page doesn’t reflect the rate it was left at after ‘a’ has been deactivated.
I’ve been trying to come up with a script that would work for this but haven’t been able to get it to yield the result I was hoping for.
Here is what I have:
--Define variable for default rate and a flag for monitoring LFO b's state
local defaultLfoARate
local lfoBActive = zone:getModulationMatrixRow(14):getParameter("655370")
--Set default rate of LFO a when the script starts
function onInit()
defaultLfoARate = this.parent:getParameter("3604510")
end
--Function to monitor LFO B status
function onLfoBStatusChange(isActive)
if isActive then
lfoBActive = true
else
--Reset LFO a to its default rate when LFO b is turned off
if lfoBActive then
this.parent:setParameter("3604510", defaultLfoARate)
lfoBActive = false
end
end
end
--Callback to check LFO b's state whenever it changes
function onControllerChange(id, value)
if id== "655370" then
onLfoBStatusChange(value >0)
end
end
If I need to clarify anything, please let me know!
Thanks!