Fade out audio on button press
I bet it’s simple, but I’m having hard time figuring it out for some reason. I’d like to have a button that when pressed would smoothly move the Simple Gain gain from 0db to -100db over 1 second. How would you approach that? I assume it needs a timer but how do I smoothly change a parameter over time like this?
I’m just bumping it subtly
Does it need to be a simple gain module, or do you just want to fade out the signal?
If you ask me in 2 months, you should use a simple scriptnode patch with a long fade-time (it's trivial to setup), but at the moment, I would recommend using the soon to be deprecated scripting DSP modules:
@Christoph-Hart so in 2 months official release of hise 4 directly? ^^
MikeB last edited by
@yall : Lol - version 3.0 would be enough for me for now
@Christoph-Hart Thank you! Now, a side question because my brain doesn't comprehend this.
I have some other actions I'd like to perform on the fade button. How can I set the timer so that it works like this:
- Button pressed: 1s fade
- Wait 1s
- Rest of the action
Is this other action something on the UI? And is the event triggered by a control callback?
@Christoph-Hart yeah, if’s on the UI. In fact, the fade is implemented in this context on an FX plugin:
- if slider changes value
- it activates the fade button
- now the script should wait until the audio fades
- convolution file is swapped
- fade button gets new value, the audio fades back up
It’s really there to hide clicks during the convolution swap. The fade should be very short (I can figure how to do this with the snippet you posted earlier so all good here) but generally speaking, I need some smoother experience without clicks in the audio.
I already have the ir swap and button change working, just need the wait part
Try a UI timer
- Fade out the signal, start the timer with the same duration as the fade-out
- In the first timer callback, swap the ir
- In the second callback, stop the timer and fade in the signal again.
You need a variable that stores the state (and change the state in each timer callback callback)