HISE Logo Forum
    • Categories
    • Register
    • Login

    A Button that shows/hides knobs?

    Scheduled Pinned Locked Moved General Questions
    36 Posts 4 Posters 5.0k 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.
    • resonantR
      resonant
      last edited by resonant

      A button that shows Knob1 & hides Knob2 when button is active. Else, shows Knob2 hides Knob1.
      I try this at "on init" but it doesn't work.

      inline function onButton1Control(component, value)
      {
      	if(value == 0)
      	    
      	    Knob1.showControl(true);
      	    Knob2.showControl(false);
      	else
      	    Knob1.showControl(false);
                  Knob2.showControl(true);
      };
      
      1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey
        last edited by

        Is showControl a command? I think you should be setting the visible property.

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        resonantR 1 Reply Last reply Reply Quote 0
        • resonantR
          resonant @d.healey
          last edited by

          @d-healey

          I've picked showControl from API.
          Visible property is not working. By the way, I'm a beginner to this coding stuff :)

           inline function onButton1Control(component, value)
          {
          	if(value == 0)
          	    
          	    Knob1.visible(true);
          	else
          	    Knob1.visible(false);
          
          };
          
          
          1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey
            last edited by d.healey

            You're correct, I hadn't seen the showControl() command before, good to know!

            I think I know what is wrong with your example, are you storing the controls in variables using the getComponent() command? Here is a working example (note that I use the generic control callback rather than an inline function but either will work).

            HiseSnippet 991.3oc0V0riaaCDlz1Jo1odQRQN1CB4zt.IFVN+BDrHN1NapQ5twnJwXukRKQslwRjBhTdWuKBPOjmmf9FzduG6SPeC5aP6PIYK4V4MqaQOTdwd3LeTeb3GmgihDNToTDgv23MKBoH7WZXufql1eJgwQCGfv6XbHQpnQloS0aQHQJotHLt5K0SfqWCkL98m0i3S3Nz7oPnwBlC8aYALU9rgceEy2+.hK8MrfBQ+ftCcD79BeQLvmpFsQgDmYjSnGQzg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WC
            

            The visible property is a property of the control it is not a command so you can't use it like a command. To set it, or any other property, you need to call the set() command like so: Knob1.set("visible", true);

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            resonantR 2 Replies Last reply Reply Quote 1
            • resonantR
              resonant @d.healey
              last edited by

              Thank you so much @d-healey . It worked lke a charm...

              1 Reply Last reply Reply Quote 0
              • resonantR
                resonant @d.healey
                last edited by resonant

                @d-healey

                What if we want to use this with an inline function? I tried this but there is something wrong.

                Content.makeFrontInterface(600, 500);
                
                const var button = Content.getComponent("Button1");
                const var knob1 = Content.getComponent("Knob1");
                const var knob2 = Content.getComponent("Knob2");
                
                inline function onButton1Control(number, value)
                {
                
                    if (number == button)
                    {
                        knob1.showControl(value);
                        knob2.showControl(1-value);
                    }
                    
                }
                
                
                1 Reply Last reply Reply Quote 0
                • d.healeyD
                  d.healey
                  last edited by d.healey

                  You have to assign the function to the control, otherwise HISE will have no way to know when to use that function.

                  You need to use the setControlCallback() command.

                  Content.makeFrontInterface(600, 500);
                  
                  const var button = Content.getComponent("Button1");
                  const var knob1 = Content.getComponent("Knob1");
                  const var knob2 = Content.getComponent("Knob2");
                  
                  inline function onButton1Control(number, value)
                  {
                          knob1.showControl(value);
                          knob2.showControl(1-value);    
                  }
                  
                  button.setControlCallback(onButton1Control);
                  

                  Libre Wave - Freedom respecting instruments and effects
                  My Patreon - HISE tutorials
                  YouTube Channel - Public HISE tutorials

                  resonantR Dan KorneffD 2 Replies Last reply Reply Quote 2
                  • Christoph HartC
                    Christoph Hart
                    last edited by

                    What‘s knob.showControl()?

                    resonantR 1 Reply Last reply Reply Quote 0
                    • resonantR
                      resonant @d.healey
                      last edited by resonant

                      Thank you so much @d-healey .
                      Last question, for example:
                      At the same time; if I want to assign this button to Phaser LFO Modulator TempoSync, should it be like this? But it doesn't work.

                      Content.makeFrontInterface(600, 200);
                      
                      const var button = Content.getComponent("Button1");
                      const var knob1 = Content.getComponent("Knob1");
                      const var knob2 = Content.getComponent("Knob2");
                      
                      inline function onButton1Control(number, value)
                      {
                              knob1.showControl(value);
                              knob2.showControl(1-value);    
                      }
                      
                      button.setControlCallback(onButton1Control);
                      Button1.setModule(LFO Modulator, Synth.getEffect("TempoSync"));
                      
                      
                      d.healeyD 1 Reply Last reply Reply Quote 0
                      • resonantR
                        resonant @Christoph Hart
                        last edited by

                        @christoph-hart
                        For showing or hiding 2 knobs relatively, with a button on/off.
                        When button is on, knob 1 will be showed (knob 2 will be hided)
                        When button is off, knob 2 will be showed (knob 1 will be hided)

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

                          LOL don‘t know my own API anymore :)

                          1 Reply Last reply Reply Quote 2
                          • Dan KorneffD
                            Dan Korneff @d.healey
                            last edited by

                            @d-healey this worked great! Thanks!
                            What's the best way to set a knob's visibility at initialization?

                            Dan Korneff - Producer / Mixer / Audio Nerd

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

                              Just call onButton1Control in the onInit callback with the value you need.

                              resonantR 1 Reply Last reply Reply Quote 0
                              • resonantR
                                resonant @Christoph Hart
                                last edited by resonant

                                @christoph-hart Can you give an example, excuse me I really struggle with this stuff bro.

                                1 Reply Last reply Reply Quote 0
                                • d.healeyD
                                  d.healey @resonant
                                  last edited by

                                  @remarkablex There isn't a setModule() command so I'm not too sure what you're trying to do. Whenever you want an action to happen when a button is clicked you must put that code inside the button's callback. So if you want it to control an FX module you first need to grab that FX and store it in a variable (similarly to how a control is stored in a variable), you can then use the setAttribute() command to change a parameter of that effect.

                                  @dustbro If you want it set at initialisation then just set it in the property editor, no need to script it.

                                  Libre Wave - Freedom respecting instruments and effects
                                  My Patreon - HISE tutorials
                                  YouTube Channel - Public HISE tutorials

                                  resonantR 1 Reply Last reply Reply Quote 0
                                  • Dan KorneffD
                                    Dan Korneff
                                    last edited by

                                    I have set visible in the property editor to disable. Once I enter in my script, the knobs become visible again. :(
                                    Here's what I'm doing:

                                    const var Button1 = Content.getComponent("Button1");
                                    const var Knob1 = Content.getComponent("Knob1");
                                    const var Knob2 = Content.getComponent("Knob2");
                                    const var Knob3 = Content.getComponent("Knob3");
                                    const var Button2 = Content.getComponent("Button2");
                                    const var Knob4 = Content.getComponent("Knob4");
                                    const var Knob5 = Content.getComponent("Knob5");
                                    const var Knob6 = Content.getComponent("Knob6");
                                    
                                    inline function onButton1Control(component, value)
                                    {
                                    	Button2.setValue(0);
                                    	Knob1.showControl(value);
                                    	Knob2.showControl(value);
                                    	Knob3.showControl(value);
                                        Knob4.showControl(1-value);
                                    	Knob5.showControl(1-value);
                                    	Knob6.showControl(1-value);
                                    };
                                    
                                    
                                    Content.getComponent("Button1").setControlCallback(onButton1Control);
                                    
                                    inline function onButton2Control(component, value)
                                    {
                                    	Button1.setValue(0);
                                    	Knob1.showControl(1-value);
                                    	Knob2.showControl(1-value);
                                    	Knob3.showControl(1-value);
                                    	Knob4.showControl(value);
                                    	Knob5.showControl(value);
                                    	Knob6.showControl(value);
                                    };
                                    
                                    Content.getComponent("Button2").setControlCallback(onButton2Control);
                                    

                                    Once I hit compile, knobs 1 2 3 become visible. If I remove knobs 4 5 6 from the project, the knobs stay hidden.

                                    Dan Korneff - Producer / Mixer / Audio Nerd

                                    d.healeyD 1 Reply Last reply Reply Quote 0
                                    • d.healeyD
                                      d.healey @Dan Korneff
                                      last edited by

                                      @dustbro After initialisation all control callbacks are called so this will undo anything you set in the initialisation or in the property editor for controls that are affected by callbacks. A solution for this is to have a variable that is set to a value in the last control callback called and then in any other callback you'll be able to check this variable and only carry out the actions after it's value has been set.

                                      For example create a variable called initComplete and set it to 0. Then in your last control's callback you can put initComplete = 1 Now in all your other callbacks you just need to encapsulate the code inside an if statement if (initComplete == 1){};

                                      Another option instead of using a variable is to use a button set to 0 and then set it to 1 in its own control callback and check its value in the other callbacks.

                                      @Christoph-Hart Maybe it would be good to have a built in variable for this purpose that can be tested when you don't want actions to happen straight after initialization?

                                      Libre Wave - Freedom respecting instruments and effects
                                      My Patreon - HISE tutorials
                                      YouTube Channel - Public HISE tutorials

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

                                        Just set saveInPreset to false for the button that toggles the visibility, that‘s precisely what it‘s for, then call it in the onInit and it won‘t get overriden.

                                        Dan KorneffD 1 Reply Last reply Reply Quote 1
                                        • Dan KorneffD
                                          Dan Korneff @Christoph Hart
                                          last edited by

                                          @christoph-hart said in A Button that shows/hides knobs?:

                                          Just set saveInPreset to false for the button that toggles the visibility, that‘s precisely what it‘s for, then call it in the onInit and it won‘t get overriden.

                                          Is there documentation on the Property Editor?
                                          That did work somewhat. But after I recompile, some knobs are still visible intermittently. Adding setValue before the callbacks did the trick.

                                          Button1.setValue(0);
                                          const var Knob1 = Content.getComponent("Knob1");
                                          Knob1.showControl(false);
                                          const var Knob2 = Content.getComponent("Knob2");
                                          Knob2.showControl(false);
                                          const var Knob3 = Content.getComponent("Knob3");
                                          Knob3.showControl(false);
                                          const var Button2 = Content.getComponent("Button2");
                                          Button2.setValue(0);
                                          const var Knob4 = Content.getComponent("Knob4");
                                          Knob4.showControl(false);
                                          const var Knob5 = Content.getComponent("Knob5");
                                          Knob5.showControl(false);
                                          const var Knob6 = Content.getComponent("Knob6");
                                          Knob6.showControl(false);
                                          

                                          Dan Korneff - Producer / Mixer / Audio Nerd

                                          1 Reply Last reply Reply Quote 0
                                          • Dan KorneffD
                                            Dan Korneff @d.healey
                                            last edited by

                                            @d-healey Hurry up and make a HISE tutorial so I can purchase it!! ;)

                                            Dan Korneff - Producer / Mixer / Audio Nerd

                                            d.healeyD 1 Reply Last reply Reply Quote 1
                                            • First post
                                              Last post

                                            48

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            101.8k

                                            Posts