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?

    Thank you!



  • 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:

    HiseSnippet 1164.3oc6WssaabCDkqj2hH0nf1hfh9HgPePBvUQJMosnFs9hrUfQsSD75b4MCJtijH7tja4x0MJA4ao+R8SI+AsC2KVqZV3pHflBDTA8f3PNCOygyMMVq3PbrRSbZb9hHf3baWuERy7gyYBI43CIN2w8TVrAzzLQGrHhEGC9DGm5OxJvowVjzOuc2CXALIGVJhPdlRvgSDgByRoi26WDAAiX9v4hvRm9A6cLWIGpBTIHdp61mDw3WxlAOlYOVMWhymbjuvnzdFlAhINacfxeg2b0uIyN+yDwhIAfcw.hGZnLwiTA9VDa+MY3bQf+3B+NlPbbGujEpmwB208Tgu3Z4KYiOKcC5RMJyGN0tI3MnL75WI7FTA7HkP2VYnCAgxOIfYVEY1mi7MDpUeoNVZ.Yrvrn7y0+ov8ycGKL74Ui2ZUfW7g5ea7l+32x8noSAtYIX2xczK1zW52i.Qm2k6Z55w0hHCd+Vfb67kzQuXvJ.JSLo1uWyEyghMzqXZ5D5OQGprTooGy2+fDiQI6z9HICwle6so8wuco6zpYqlK0ZF50nhmHlnYZAD2KPw76zlqzP6t83Z.c4zmMnS63PkxLG7uvpDna2M0V1E8hAyXlFybwZGctu8h1gdu6Q8AF2HtBsAcJVWgFp7gpzXv1zA86mqDtCM6pDxYTCV0fZTo6GFauPgL.ud5zDI2FJQUxbez58ZUPGtJLRIQdXazECRftsZ95VMo3Gz5SUZNPEFqMm.TPfdjFsAPUZ5q.spUyFuK.6maJ5OS626gzcoC50m9i3u6aIg2jRDEj+LvLr.AK4+tVClivgrffIX0tN+cnaM109UjFhXZ3b03.1hNwrvn.3LjJ2lNIPwuzS7JnayWmi104v6z7MMokLeZ32A1s6vmyjRHHtrAqZ6UMgs9cFkKSBm.5B91ZD6Awpsql4bq0KygmwjkNnRdrTXdRDjudE2sPL1BoDnWJ8ZXtTTEkFNSkXv.tSYFs3kHxebRnG1ahCCycdTlSMhU0z08sqsUp7.oe5h+D+ju4.6Zm7MGTrIIODwl8mCIDNlzb+6jmrmk2RDXhdC27nCRJsVtZN4oGeHyvJLDZSzWh.sQXoYmCgqvNwYEUZ3dHDeoQEkd173RrjyZbsurvEWT7ixEPuSl8+TWOLcLcNhzpVeY5Z5yYWAzGAXcBaqfA2vnD+w5NJQzZOJwS3F75OWyjwQp3ULrGDJNG4f3xBeZLLRC+5Y1dSkkOTwzUt0a2cD5jUpiGyjnSaxsenJQZVooV8MpSxp85Kc9JZqr0+OeSJbqudv8enwbiBL5IrUTORdEDf4YoX7KvDqorj.SgzUCxOUIUQyURAubDvY.VdY1LPWF6U5P6aLXKhkRt6dmAA.qbz7Wu2IXTHSi7Drgbwf0mKto2quxMCtTalI8ii4Rq+QzbouGP4CQevOD2QHiqUWvyZyZikuUpDzuko+CyF3e0EWSGTzc00EGmiDhUDufysz82f7S05b+MPmucCz4AafNObCz461.c99MPme3F0w1LZ+DiJLKUDEL9nzobbbJlHAi5I+EPAHDoi
    


  • @Christoph-Hart so in 2 months official release of hise 4 directly? ^^



  • @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

    Thank you!



  • 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

    https://docs.hise.audio/scripting/scripting-api/engine/index.html#createtimerobject

    1. Fade out the signal, start the timer with the same duration as the fade-out
    2. In the first timer callback, swap the ir
    3. 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)


Log in to reply
 

18
Online

1.2k
Users

3.9k
Topics

34.1k
Posts