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.
    • 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.AxfEoUxbQqctscaALCttwHxP5IRnwLD01uYysw60rY8enpSUmW8JbOxUTrNfhgbpVJBUXFWKv5IBLQJISU3ABIlRTLn1hAlgnYBtAL.PowWQj3wPx2Ee.92xb7kTcawnwBNzn1VuiK56tU8sq5fu62xgzp7P1Yq5+dbfca10Z0ra2x6p8JOj8yXGH6l7Fnz3lXPcci0XSRvv0Nbe5GwPNPA0TXJC5OShEoQSUGFOjwo3AQbOS9HdtcggpMyB0q5bcBAAiWanwYwFoNNo2qyY+vFF3sSJ.xs.9fCvPgR7ztIY1KvfsJmAcm2fN2XDjaGMB9QQZsf6lYBuLkbaHkFFQyCNPKaGP8FBxGQGqgwS.yTfrpfB4.3uIvFYXHgf8HggTev9gSwSBnbrWHyaH0upSE1fZYlthwvyTTPBLd4OhTI3ichHNqLivPCZUmahytKt.HMf1pdCko+3vpMXs9vdm0tc7lr5bYpRqUqJKORbShjHEsPLXxNPtzjdtuQQqUGEslKJ.GdFTGGmGLLQgIXOpTSRqeZT0oHAq5THdOSnoumWqty0NUbt4NiLXvhFJ06gT4hF0bVlbEvpwiF0mJyTzz4A6IO+l9ad+1z2KQEKLQAuCmoe+XZZ67iEbWvwBnzz.b.wloDDlpN93gmmd7PuPlOUhXfQdhc7dsnXtW77cz8FbqGB3cdHf28g.duGB38W.3eoywDMwbvbZJ.RKigxVlI6acL8J3BSIGSWw9XpZnVLFY8zYKUf+m2oIKMhcZE6zU6nOl6xiObZwFSX95.ykf9DzLfxtLPaZ8MPKEbhcGdWIEVBZN3WR7Yh2JEQiyphJCIZsTRb9+WjXyOa85RnvmHKiBMSxu2aWDGk1V+Ef5wv76jX9gVeYl+Ie1UFEMus0eCvWgouJauHq0KiW1aNM5wxK6emjco7zcukLbWcgeTHQO+E3MO5Ic.X+84tor41vbESOs3ihJws5atva0uvsuumz8k1cYZufEy20V.eg8kdr4a5ajpZ+lACnd5bxtg8I+5W5ChJAU9YQjlwu7ThVxLElmEMpG7hSOJvDNmFpLkGqYVHkztoosQY5Q49Myd+X5ftl1VoC5lMHZDwSJ9P1Ke.Q8ow8.bhG+V1Jvipg13YmnZ38H3ogevyyHDeKv7EinUoQrSoQraoQrWoQreoQ7ckFw2uBDl2g+5HsXTxxBD5+r0WLdC
                    
                    Dan KorneffD 1 Reply Last reply Reply Quote 0
                    • resonantR
                      resonant @d.healey
                      last edited by

                      Dear @d-healey can you make an example, I really don't know what to do :)

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

                        How can we add a phaser modulation tempo sync assignment to this button? @d-healey @Christoph Hart

                        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);
                        
                        1 Reply Last reply Reply Quote 0
                        • Dan KorneffD
                          Dan Korneff @Christoph Hart
                          last edited by

                          @christoph-hart total noob question... what do I do with your HiseSnippit? is it a link of some sort?

                          Dan Korneff - Producer / Mixer / Audio Nerd

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

                            Select everything (including the HiseSnippet part), copy it into the clipboard and choose File -> Replace with clipboard content.

                            This is the recommended way to share little example patches in HISE as it contains scripts, control properties, modules etc (but no external resources like images or samples).

                            Dan KorneffD resonantR 2 Replies Last reply Reply Quote 0
                            • Dan KorneffD
                              Dan Korneff @Christoph Hart
                              last edited by

                              @christoph-hart :love-you_gesture_medium-light_skin_tone: :love-you_gesture_medium-light_skin_tone: :love-you_gesture_medium-light_skin_tone:

                              Dan Korneff - Producer / Mixer / Audio Nerd

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

                                @christoph-hart
                                @d-healey

                                My modulators' name is PHASERLFO. I've first used "Synth.getEffect" to predefine the modulator. After that, used "setAttribute" in "onButton1Control".but it says PHASERLFO was not found. What am I forgeting?

                                Content.makeFrontInterface(600, 400);
                                
                                const var button = Content.getComponent("Button1");
                                const var knob1 = Content.getComponent("Knob1");
                                const var knob2 = Content.getComponent("Knob2");
                                const var PhLfo = Synth.getEffect("PHASERLFO");
                                
                                
                                inline function onButton1Control(number, value)
                                {
                                        PHASERLFO.setAttribute(PHASERLFO.TempoSync, value);
                                        knob1.showControl(value);
                                        knob2.showControl(1-value);    
                                }
                                
                                button.setControlCallback(onButton1Control);
                                
                                
                                d.healeyD 1 Reply Last reply Reply Quote 0
                                • d.healeyD
                                  d.healey @resonant
                                  last edited by d.healey

                                  @remarkablex It needs the name of the variable not the ID of the effect. You've put PHASERLFO.setAttribute() instead of PhLfo.setAttribute()

                                  Generally once you store a reference to something in a variable you only ever need to use the variable name from then on (not always true but mostly).

                                  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
                                    Oh, I've pasted wrong line. But even we put "PHASERLFO" it doesn't work.

                                    HiseSnippet 1169.3ocyW0saaaCElxNZswctXcqWtKDBv.bvZMjcyx9IXnNwItyH+YTmkUfcQGsDcLgkH0jnRpWQAF1d.106oXuC6gYWu2fsCEokjSTbr6V6FuHw7b32gemCO7bn5ExcHQQ7PjwcNYR.AY7tl8mvDiZOBSYnt6hLtq4g3HAIzRIZmIA3nHhKxvn7SjBLVcETx3Oe7NXOLygjIBgNkScHGP8ohLoAs1m540A6RNg5ma0azpqCm0l6wiA9T1zFEfcFiOibDVtrRlnyojKhPF1lOpY8vwMF7CaWWNFJ+yypOcz6II+aOoljEfbhCCILwo.bjgoweACCy8boBdXeAVP.atxNb2I8Gwufo15SoQzAdD4jFn9.mTh6v8bkNuTJp8HpmauogvHDXkdYAzxp.58MOj5RSkmEXeuDEVYHxGZMJMO503lomcQzyHG8VQQu6Y12IjFHxzH41cL6xfy7gX3zLOsTqEU5mKY1lCqfIp6iGS5DBSRQTaSa6GXsgs85aUsR0JvYZjv5bbn0fXgfyr9RqoXOiHZy8C3LXRs01IQci0jvx.MlwGz3ZwruTaAHZNWDMuDhde01826oGz4X.UR5uDydCGRb..oJWS4OUqPYdTFwZXLyQPAGhyzTWtigbuZrX+AjvG.11Klrd0JurZEK8H0Z0iHhsEhPJDUH0xDeBAnJPBmov2JCbh2VOBRCltSEtjlyrjFOTuHo5pUdkzCTmDRJnWUarm2.31VsK6KJeNmqdDWPNlUa8JurxpUd0UzLbXQpzFyiDVjVYYfv4.6RwS85fT3Yui7NK1cDGUZQtExYcYTwwAD874eIGoyqf6Sk0DD9kH41zc02lTwPDELxpl5.JJg84KNhtN388ntjvD32xL4P+eB3lE.9q6tKVfkkDzdC3gAjPAUFHM1kbNT1VUfXUycIQiE7fD2UeMBB1KfC+BYw1eB1sIxerE7iKnthQxI+HLYDgd1Hgb1Gp7mqy3EDNRL8WL0z+10aZ6kzzMUldeCso+8avzWshJTWm6F6gEyVrW1rTq.RtmopprxIKhJljuY5RzAvdgaPsnz8dl8nBmQEy2REvWHS5MMe08SqZpJLmQ1UL67r2xMOu0z6F8FgiHv1K4QE0LqKwlNgjuOlvblzHKbMoUpzlYR+0VcHDWYYXsrua3v+3wGRewL4Ekm04JuXN2h8ZfBSFdese8FJ6807HnphwllPSS8aVRahdy7KM7mI71sjOIsa1KZa8Ks9F74jg7Pe8wcJ7CHmAwn7RRaam+NQeeNWLhxNa1G5d+VGv4A6wvPDvMuQZGGI39S2TjwGY1bi5yNN+X4yZ+X4O+71IyQ8Ejfjp4Feq4lWd8+aMtx86W+7tRKXd2GHOZsRO9j4e+Ourohwo4V+Wx3mxiEPh2gX3ElxNZGE62G9tJGBvVFi3EI6fUR1aTM2VNOImkvbsm9URZkMjyMzJaLU4ak8vG6Dxeti5sNxrmamHA7aVxWEtJ74ovbqzWHIiM9vGV8bGGYqgGBQmhQzboQ7nkFwFKMhOYoQr4Ri3SWZDe1bPH+J1sig5VpVCHzeCf01RwA
                                    
                                    d.healeyD 1 Reply Last reply Reply Quote 0
                                    • d.healeyD
                                      d.healey @resonant
                                      last edited by

                                      @remarkablex Well the error message says PHASERLFO not found this should be a hint. The thing you have called PHASERLFO is a modulator not an effect, the effect is called Phase FX. If you want PHASERLFO you need to use Synth.getModulator(). After you've done this you'll get another error, but I'm sure you'll be able to solve 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
                                      • resonantR
                                        resonant @d.healey
                                        last edited by resonant

                                        @d-healey @christoph-hart
                                        Thank you, it gives unknown function showControl. It's strange showControl was working before but now, when we add Synth.getModulator() it didn't work. I didn't managed to solve this....

                                        HiseSnippet 1188.3ocyW80aaaCDmxNZoQctXcqOtGDBv.bPaMrcyx9SvPchc7lQbRLpyxF1dniVh1lvRjZRTI0qn.C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z1m7igDl0zZogqoMRzVOU6u1nMgXKqFqz8CCG9GO9D5ylKun37NWwUy4Vs2Ejaxv6q7q2PYuulGAkhYrtNz6T85kjdo2L+RB+oJuUC4iS6j911F+RiuAeIYH22Ucbm.uKYDDixpIo6c16D8c4bwXJaz7O48dM5x4dGwvPDvN6hzLLPvcmsoHsORu9tUleb4YvOCuu7ueVyHYTeAwKpvt12qu2hy+eqwqb+90OuqvJl28AxiVyjiOY92+yKaFy3jbq+KY7S3gBHw6DL7PSYGsSCc6CegkEAXKiQbBjcvJH6.GKWUJGkyRX1Um88RJi0jxZJi0lY7sxd3hs74O0J9YOxrmaEoA7aVz2GtE7gpfrYxikjwFW3Srdpkkr0vCgnS9Hpu1HdzZiX20FwGu1H1asQ7IqMhOcIHjeO6AgPcq3VCHzei2rckk
                                        
                                        d.healeyD 1 Reply Last reply Reply Quote 0
                                        • d.healeyD
                                          d.healey @resonant
                                          last edited by d.healey

                                          @remarkablex It's an easy one but I'll give you the answer, check your spelling, don't mix uppercase and lowercase variations. If you call your variable knob1 don't try and use Knob1.showControl().

                                          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 resonant

                                            @d-healey Thank you brother, as I say, I'm a beginner to coding. It's so hard to be a beginner sometimes :)
                                            Thank you for your help...

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

                                            29

                                            Online

                                            1.7k

                                            Users

                                            11.8k

                                            Topics

                                            102.8k

                                            Posts