I am trying to use an envelope to modulate a parameter that is passed through an if statement.
The issue is that if I use a k-rate variable it hits every branch of the if statement, but I need to modulate this using an envelope which is k-rate.
First I would like to know why my k rate variable is hitting every branch, and then how I would go about modulating it with an envelope but only hitting the appropriate branch?
kEnv madsr 0.01, 0.01, 0.9, 0.2
kSlider = chnget:k("slider") * kEnv
prints("SLIDER VALUE: %f\n", kSlider)
if (kSlider <= 1) then
prints("Less Than 1\n")
elseif (kSlider <= 2) then
prints("Less Than 2\n")
elseif (kSlider <= 3) then
prints("Less Than 3\n")
endif
My output from the above code
SLIDER VALUE: 0.000000
Less Than 1
Less Than 2
Less Than 3