HISE Logo Forum
    • Categories
    • Register
    • Login

    Do something only when automating?

    Scheduled Pinned Locked Moved Scripting
    7 Posts 2 Posters 83 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

      Is it possible to know when a parameter is being automated by the DAW, and only execute it's callback then? Ideally, with some simple logic like:

      Not automated - do something

      Automated - do something else

      Thank you!

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

        @tomekslesicki You can attach a mouse broadcaster to the UI knob that will track whether you actually interact with it while changing parameters. In Pseudocode:

        broadcaster.attachListener(function()
        {
           IS_AUTOMATED = !event.clicked;
        }
        
        onKnob1Control(component, value)
        {
            if(!IS_AUTOMATED)
            {
                // whatever...
            }
        }
        
        T 1 Reply Last reply Reply Quote 3
        • T
          tomekslesicki @Christoph Hart
          last edited by

          @Christoph-Hart clever, thank you!

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

            As a precautionary method: what are you trying to achieve here? Whenever people start making this distinction, it's usually a warning sign for a underlying design flaw.

            Oh and another way of checking this (which also covers the case where you have assigned a MIDI controller to a knob) is to check the actual thread where this might happen from:

            
            inline function onKnob1Control(component, value)
            {
            	if(Threads.getCurrentThread() == Threads.Audio)
            	{
            		Console.print("Plugin Parameter / MIDI controlled");
            	}
            	else
            	{
            		Console.print("UI Interaction");
            	}
            };
            
            Content.getComponent("Knob1").setControlCallback(onKnob1Control);
            

            Although that might not be 100% robust because I know that some hosts are calling the plugin parameters on a different thread (IIRC Protools does that).

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

              @Christoph-Hart thanks! In this case, I have a bunch of buttons that control stuff - isPluginParameter is disabled for them. I want to add a slider, which would be plugin parameter enabled, and would set these buttons depending on it’s value (slider at 0 - button 0 on, slider at 1, button 1 on, etc.).

              The end user never sees the slider, it’s only there to automate the button states. The buttons are displayed on the interface, though, and they should update the slider’s value when they’re interacted with - button 0 on, slider value set to 0.

              What I actually want to achieve is to prevent creating a loop where the button state fires its callback, and changes the slider’s value - which then changes the button’s value, and fires the callback again, and so on. So my idea is:

              • button pressed on the interface a fire button callback, and set the slider’s value

              • slider automated - change button state, but don’t set the slider’s value again (and don’t call it at init)

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

                I just figured out I can actually do this by checking the button’s value on the knob’s callback and just if it from there, which would be a much simpler solution I guess

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

                  @tomekslesicki yes there are plenty of other solutions

                  1. just not calling changed() in the slider would prevent the infinite loop
                  2. writing a custom panel instead of the buttons that store its value and is assigned to a plugin parameter would also work.
                  3. you could even get away with just styling the slider with a laf and make it look like a few buttons but that‘s advanced hackery and might not work with you design.
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post

                  24

                  Online

                  1.8k

                  Users

                  12.2k

                  Topics

                  106.1k

                  Posts