I've got the following code in the Left parameter of a Level Sound:
| transition last_transition smoothing |
transition := EventVariable new initialValue: 0.
last_transition := EventVariable new initialValue: 0.
smoothing := EventVariable new initialValue: 0.
(last_transition <+ transition),
(transition <+ ((!Bar mod: 8) of: #(0 0.5 1 0 1 0.5 0 1))),
((transition eq: 0.5)
true:
((last_transition eq: 0)
true:
((transition <+ 1),
(smoothing <+ 4))
false:
((transition <+ 0),
(smoothing <+ 4)))
false:
smoothing <+ 0),
(transition smooth: smoothing s).
In the middle of the code is an array of "transitions": (0 0.5 1 0 1 0.5 0 1), where a "0" means be silent, a "1" means be loud and a "0.5" means fade up or down. The direction of the fade depends on the previous value, so if the previous value was 0 then a "0.5" would mean fade up.
I'm using smooth: to do the fading. I have some logic that sets the length of smoothing time in the EventVariable "smoothing".
But this code doesn't work. It's just silent all the time. If I replace the final "smoothing" with a literal number then it works fine, eg:
...
(transition smooth: 1 s).
if I replace it with an EventValue it kind of works for a while then stops working:
(transition smooth: !Smoothing s).
Am I doing something silly?