Hi Tony, try this:
var myRamp : Ramp
TRIGGER : Widget // Widget that starts the ramp
VOLUME : Widget // Widget that controls audio level
v_volume : double // Variable to get the current VOLUME level
initialization
SetGeneratorOneShot(myRamp, true)
end
on WidgetValueChanged(newValue : double) from TRIGGER
if newValue > 0.5 then
v_volume = GetWidgetValue(VOLUME)
myRamp.SetGeneratorLength(2000) // 2000 msec
SetTimersRunning(true)
myRamp.EnableGenerator(true)
end
end
on TimePassing(timeX : integer, amplitudeY : double) from myRamp
SetWidgetValue(VOLUME, v_volume*(1.0-amplitudeY))
if GetWidgetValue(VOLUME) < 0.01 then
// Reset Trigger
SetWidgetValue(TRIGGER,0.0)
end
end