HISE Logo Forum
    • Categories
    • Register
    • Login

    Fade out audio on button press

    Scheduled Pinned Locked Moved Scripting
    15 Posts 4 Posters 577 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tomekslesicki
      last edited by

      I’m just bumping it subtly ;-)

      1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart
        last edited by

        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
        
        Y T 2 Replies Last reply Reply Quote 1
        • Y
          yall @Christoph Hart
          last edited by

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

          MikeBM 1 Reply Last reply Reply Quote 0
          • MikeBM
            MikeB @yall
            last edited by

            @yall : 👍 Lol - version 3.0 would be enough for me for now

            "One hour of trial and error can save 10 minutes of reading the manual."
            "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
            HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

            1 Reply Last reply Reply Quote 0
            • T
              tomekslesicki @Christoph Hart
              last edited by

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

              1 Reply Last reply Reply Quote 0
              • Christoph HartC
                Christoph Hart
                last edited by

                Is this other action something on the UI? And is the event triggered by a control callback?

                T 1 Reply Last reply Reply Quote 0
                • T
                  tomekslesicki @Christoph Hart
                  last edited by

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

                  1 Reply Last reply Reply Quote 0
                  • T
                    tomekslesicki
                    last edited by

                    I already have the ir swap and button change working, just need the wait part

                    1 Reply Last reply Reply Quote 0
                    • Christoph HartC
                      Christoph Hart
                      last edited by

                      Try a UI timer

                      Link Preview Image
                      HISE | Docs

                      favicon

                      (docs.hise.audio)

                      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)

                      1 Reply Last reply Reply Quote 1
                      • T
                        tomekslesicki
                        last edited by

                        Ok, almost there! It works great EXCEPT that it double triggers the fade button when moving the master slider. I'm pretty sure it's something obvious at this point?

                        reg fade = true;
                        
                        const var FadeTimer = Engine.createTimerObject();
                        
                        const var Master = Content.getComponent("Master");
                        const var FadeOutButton = Content.getComponent("FadeOutButton");
                        
                        
                        inline function onMasterControl(component, value)
                        { 
                                    
                                // Filtr 1
                                if (value == 1)
                                {               
                                    FadeTimer.setTimerCallback(function()
                                    {
                                        if(fade)
                                        {
                                            fade = false;
                                            FadeOutButton.setValue(0);
                                            FadeOutButton.changed();
                                            Convo.setFile("{PROJECT_FOLDER}IR1.wav");
                                            Console.print("Swap");
                                        }
                                        else
                                        {
                                            Console.print("Fadein");
                                            fade = true;
                                            FadeTimer.stopTimer();
                                            FadeOutButton.setValue(1);
                                            FadeOutButton.changed();
                                        } 
                                    });
                                    FadeTimer.startTimer(50);
                                }
                        
                                // Value 2
                                if (value == 2)
                                {
                                        // Something else
                                }
                        };
                        
                        Content.getComponent("Master").setControlCallback(onMasterControl);
                        
                        1 Reply Last reply Reply Quote 0
                        • T
                          tomekslesicki
                          last edited by

                          @Christoph-Hart maybe I’m calling the var change in the wrong spot? The fade works great when I turn the knob but it also fires again once I release the mouse

                          1 Reply Last reply Reply Quote 0
                          • T
                            tomekslesicki
                            last edited by

                            Still can't figure it out, maybe it's just that my logic is tired. The script above works except that it the fade action again once the mouse is released.

                            @Christoph-Hart save me, please! ;-)

                            1 Reply Last reply Reply Quote 0
                            • Christoph HartC
                              Christoph Hart
                              last edited by Christoph Hart

                              • Try to save the value argument of the onMasterControl in a reg variable and only fire the logic if it changes. This prevents multiple callbacks with the same value to fire multiple times.
                              • put the setTimerCallback() outside of the control callback.
                              • if you just select different IR's based on the slider's position, use an array with the names and then just pick up the one you want - this is especially true if you move the function declaration out of the value branch.
                              • before you call startTimer(), make sure to set the fade variable back to true.

                              So your control callback should only look like this:

                              inline function onMasterControl(component, value)
                              {
                                  if(value != storedValue)
                                  {
                                      storedValue = value;
                                      fade = true;
                                      callFadeOutNow(); // no need to wait for the timer...
                                      FadeTimer.startTimer(50);
                                  }
                              }
                              
                              T 1 Reply Last reply Reply Quote 0
                              • T
                                tomekslesicki @Christoph Hart
                                last edited by

                                @Christoph-Hart thank you!

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post

                                66

                                Online

                                1.7k

                                Users

                                11.7k

                                Topics

                                102.1k

                                Posts