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.
    • 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+ftCcD79BeQLvmpFsQgDmYjSnGQzgUw.MmQOUhvsMtemVQyrlb9yaoG8Zsb7MiOlIG6LGle9wpA8S8ibhihnb0X.NBaf+CXfMdgKSIhrUDEEVyp8DtKrmJNkm9oGyjrI9TsgExF3T5zn9SY9tiVl1jHDt1n7jX0zj3sMNj4xVMedx7lINLyQTLchqrNkpsFkr1DkNP36pWfMPObA5UKkd2xv1IhEpx8n41MLFxgyYOBbBVjVowhp7KXi9BHBtpU.YF8fHvXEhceT61207gsau2Sa1nYC3bTpLmShLmDqTBt49lKwdBU0WDDJ3fwt2oWhaq6ngkCZFWLwZiXdk1aIH5boH5.H7h4NJFPGA+Hgh9Z9t603hF0a7gF+UOddk4Ru5QBeeZTYd0p4nKA1t73fIzn6BD1OlpiqYCSXv7LybYt+9YIr8RccQ5O5QRNokDjCKWtzk4oqGRm0Bw5dYAkDyGRCEHGHEVWqcsqlVyIM8VHPAeHmodcHMyNWMZUhZDkc9.5xpYbD9mJQUtSlpLURfXvhT2HSefR1FEKrf1DbaelKMJA90MRjJ+a.2oDvuc3.hhnuZksafcXHMRwzIR7.5bnjW5Es5FCnxYJQXx1MSNBI6qvF9rUexu2q6hUF+7wcOk4plpKi8Cf8TJ6joJs0WmtuV8Q14ylVNSC6GATKz+4Wg+rgkFpqfjpEZ4v0RvhBXtt9zQBISKwKzC3mfVEg1rySxXWb6O8xe67O9rfhsIPn.xYE6ZHi87XmkTe2i4GHU.cGF.k8Q3ux3sRpoK0iD6qLkyf0Y9RgItZwcayO64Xgu4oESnuu6+C10n+dQbnUhvM1mnVu+htmblCMGKVHWWrlCbeQQdrEMcZWZSmRuleEo6sLFwTNSKmuUJguvkt+q4aVK7lFuvyi5nxIaMiCN9eZ+5sfJemHVw3mbHATD5anGEGXCOHxgBLgyo9Rs1rh9tdpcassNyXS4tsW97lLmVZablSqkNAsnSj3cNoEA0OR3KRlA3DO4oV0g27A1lqJcp4Mn9YuywQmHtmEBUNhNaMh6u0HdvVi3gaMhGs0Hd7Vi3IWBB8yDedrRDjds.g9S9l4FWC
      

      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
                                      • Dan KorneffD
                                        Dan Korneff
                                        last edited by Dan Korneff

                                        I'm almost there....
                                        With this current script, the UI initializes with all knobs hidden and button 1 + 2 are set to off.
                                        I can toggle between Button 1 and 2, which shows knobs 1-3 or 4-6.

                                        Content.makeFrontInterface(600, 500);
                                        const var Button1 = Content.getComponent("Button1");
                                        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);
                                        
                                        
                                        inline function onButton1Control(component, value)
                                        {
                                        	Button2.setValue(0);
                                        	Knob1.showControl(true);
                                        	Knob2.showControl(true);
                                        	Knob3.showControl(true);
                                        	Knob4.showControl(false);
                                        	Knob5.showControl(false);
                                        	Knob6.showControl(false);
                                        };
                                        
                                        Content.getComponent("Button1").setControlCallback(onButton1Control);
                                        
                                        
                                        
                                        inline function onButton2Control(component, value)
                                        {
                                        	Button1.setValue(0);
                                            Knob1.showControl(false);
                                        	Knob2.showControl(false);
                                        	Knob3.showControl(false);
                                        	Knob4.showControl(true);
                                        	Knob5.showControl(true);
                                        	Knob6.showControl(true);
                                        };
                                        
                                        Content.getComponent("Button2").setControlCallback(onButton2Control);
                                        
                                        

                                        The Only thing I don't have previsions for yet is what happens when a button is unselected. For instance, If I select Button1, knobs 1-3 are revealed. When I hit Button1 again, the button turns off, but knobs 1-3 are still visible.
                                        Would an IF/ELSE statement work after the callbacks? or is this something I need to set in each callback?

                                        Dan Korneff - Producer / Mixer / Audio Nerd

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

                                          @dustbro http://hise.audio/manual/VideoTutorials.php ;)

                                          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 0
                                          • Christoph HartC
                                            Christoph Hart
                                            last edited by

                                            1. Use the radioGroupId property for mutually exclusive button groups.
                                            2. Check that the value of the callback is true before you do anything (the callback might get fired for all buttons with each click, but only the active one is 1).
                                            3. Use an array to store all elements in a page
                                            4. Use a dedicated function that you just call from your callback.

                                            Check out this example, which should do what you need in the most recommended way:

                                            HiseSnippet 1235.3ocsWssaaaDDcosoSDSUPBPerOrvOIA3pHJeoEnvnNVNNPH0NBUtFEnnHXE4JyshZWgcWZEUCCj+u9Izeh9GzNKuHRYKoXFWym3d4LyYNyr25JEdTkRHQVO67oioHquxt2TtNnc.gwQcNFY8b6SIJMUhS55noiIJE0GYYs9aMcXUYCT72+7iGQBIbOZdWHzEBlG8mXiX57dGe36XggmP7omyFUX16dXGOAusHTDA7Yc6lnwDugjKomQLSaMazUL5DExpo8NsZHG51+Oecia8MgdTiFCFLe+HuHojx0W.vQV1V+K7YY+FelVH6oIZJXy0OR3OsWfXBOw0WvTr9gTSCWTOfSIciZGvB86lIaJDxZit4h35Ih3WaeJymMq+bw7EwCfyQTTNsVadJswbTxcYT5DQnuw.KgdVEn2FIz6k187jrw57QLb6Y1c3Pdd.AxfEoUxbQqct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ftl1VoC5lMHZDwSJ9P1Ke.Q8ow8.bhG+V1Jvipg13YmnZ38H3ogevyyHDeKv7EinUoQrSoQraoQrWoQreoQ7ckFw2uBDl2g+5HsXTxxBD5+r0WLdC
                                            
                                            Dan KorneffD 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            22

                                            Online

                                            1.7k

                                            Users

                                            11.8k

                                            Topics

                                            102.7k

                                            Posts