HISE Logo Forum
    • Categories
    • Register
    • Login

    Randomizer on 3 Grouped buttons, How?

    Scheduled Pinned Locked Moved Scripting
    97 Posts 4 Posters 4.6k 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 @DanH
      last edited by

      @DanH Why not put the randomizing code you have in your button callbacks inside the sliderpack callback? And then all the buttons need to do is change the sliderpack value and trigger its callback.

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

      DanHD 1 Reply Last reply Reply Quote 0
      • DanHD
        DanH @d.healey
        last edited by

        @d-healey argh making a mess of this lol! I think I've misunderstood your suggestion... (or which bit of the code to switch out into the sliderpack callabck)

        DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
        https://dhplugins.com/ | https://dcbreaks.com/
        London, UK

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

          @DanH The button callback contains some code that randomizes the filter. Take that code and put it in the sliderpack callback.

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

          DanHD 1 Reply Last reply Reply Quote 0
          • DanHD
            DanH @d.healey
            last edited by

            @d-healey do you mean this code?

            inline function onRandITControl(component, value)
            {
            
                local randomValue = Math.randInt(0, 5);
                Console.print(randomValue);   
                
                btnRandom[randomValue].setValue(1);
                btnRandom[randomValue].changed();
            
            };
            
            Content.getComponent("RandIT").setControlCallback(onRandITControl);
            

            DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
            https://dhplugins.com/ | https://dcbreaks.com/
            London, UK

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

              @DanH No, I'm talking about the code that randomizes the filter. The part that sets the attributes.

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

              DanHD 1 Reply Last reply Reply Quote 0
              • DanHD
                DanH @d.healey
                last edited by

                @d-healey so this?

                Filter1.setAttribute(3, FilterModes[idx]);
                Label1.set("text", FilterNames[idx]);
                

                If so I've been trying to figure out how to get the idx value (from the button callback) into the sliderpack callback

                DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                https://dhplugins.com/ | https://dcbreaks.com/
                London, UK

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

                  @DanH Think of it this way: the buttons are only there to provide an interface for the user, you don't need them (except for the randIT button). So write your code so that is uses the sliderpack instead of the buttons, once you have that working you can add the buttons back into the mix.

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

                  DanHD 1 Reply Last reply Reply Quote 0
                  • DanHD
                    DanH @d.healey
                    last edited by

                    @d-healey I still need the 'Tabbed Interface' script though don't I?

                    DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                    https://dhplugins.com/ | https://dcbreaks.com/
                    London, UK

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

                      @DanH I'm not seeing a tabbed interface in your snippet

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

                      DanHD 1 Reply Last reply Reply Quote 0
                      • DanHD
                        DanH @d.healey
                        last edited by

                        @d-healey So the buttons are the 'tabs' if you like. In order that they behave like a radio group.

                        //// TABBED INTERFACE SCRIPT
                        
                        const var NUM_TABS = 5;
                        
                        for (i = 0; i < NUM_TABS; i++)
                        {
                            btnRandom[i].setControlCallback(changeTab);
                        }
                        
                        //Tab button callback function
                        inline function changeTab(component, value)
                        {
                            //Get index of clicked button
                            local idx = btnRandom.indexOf(component);
                            //Toggle buttons
                            for (i = 0; i < btnRandom.length; i++)
                            {
                                
                                if (i == idx)
                                {
                                    btnRandom[i].setValue(btnRandom[i] == component);
                                    SliderPack1.setSliderAtIndex(idx, btnRandom[idx] == component);
                                    Filter1.setAttribute(3, FilterModes[idx]);
                                    Label1.set("text", FilterNames[idx]);
                                }
                                
                                else
                                
                                {
                                    btnRandom[i].setValue(0);
                                    SliderPack1.setSliderAtIndex(i, btnRandom[i] == component);
                                }
                            }
                        
                        }
                        

                        DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                        https://dhplugins.com/ | https://dcbreaks.com/
                        London, UK

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

                          Rewrite it without the buttons at all. They are only there to provide an interface for the user, they are not important for the functionality. Once you have it working without the buttons you can re-add them (with the radio behaviour too).

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

                          DanHD 1 Reply Last reply Reply Quote 0
                          • DanHD
                            DanH @d.healey
                            last edited by

                            @d-healey Thanks for all this David - ok I'm trying this but am unclear on a few things. Trying to store the random number inside the 'btnRandom' array and use that to call the right filter mode in the Sliderpack callback. Not sure why I'm getting this error though:

                            Line 42, column 25: API call with undefined parameter 1
                            
                            HiseSnippet 1941.3oc0Y0sbabaEdWYuIgJQoIY7jY5cn7JpXZJt7G8SU8T9iHSXi9gVj1oc7nwAbIHIFuDfdWPYo5wy3dSm9Nza5iPeD76SuIuAsG.rjKnHopDSrmXbgFBbNGb9vAe3rG.0Lf6QBC4AV1IZe4Hhk8m4z5RlXP0AXJypwAV12yACs.Yafr86flUkKGgCCIcsrsuy2J0zNwcsTse5OVA6iYdj3grrdBm5QNjNjJhGsYoum56WG2kzlNzP6BkZ3wYU497w.ptiSVqQXumi6SNFKUaMGK6OpVWpfGzRfEjPK66Vg28xVC3ujo0+IzPZGehriqUKXhzCWm62UhX4nVUGP861bxpOzBlklwwh6niE2y4HZW5zwiiIegR.J1By3g8ZWG7bMgW1aN7rMf2c0v6KcZ4EPGIhkHw1m5zfIHA8vvVfIrz5ZsVsDNU4fFLQlg3mSpG.clZQpsyl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ze.4bnjdccnIbNfD9bAejk85S+.ik8GqQ3mGgvJpi5JzkvIpzJqKlV2+a6T5x3KAzpDgggvmrL6CI3fnJ6CwmSZvZFP.FldjyMKl15V48bKy6H76AumeYd+sCdO38BKy6kF8y16ezR89m3nKqvv4uot41992Tma5OGs+1HxepTiQtSmlzzclq0e77Rxbm.q0YRApyLwIDQ2BTOw084XAk0uMEV0x4+23XNzLt4DS2bQonSP5iKfYpT0GPCG4iuzpS+IW18ybJjaW2hEJVLWdKpfLzTvdE1a6cxsWQCA4jRx4VXmB6le6B6XoNvZmyQkAO4zTHM5l72ildQM0MDRpxKCC+.WHS6h19tQIVhWw+jvXE+l+TIc45kGxGyLty+8JEJHiZQ+qDyGL31QcKZ3UKOCulM7mM08SuU63lIPrxYfj+0aJ8RZWwfoC7O9akFPn8GDGJdK6pjBM.qDveYHIXVRg61Y2ovdE2d24HE6ty16kambtWkTnnKEcccKpIEq8.6HVg7KOsfHhNxBL.Q.bmgohpcwHLKD9BXX4PX9FOTpROLTpPrNpWpHXISf7awgyOsv2J0FLur53y4A.9kO6yLBOd7PMDj1jSOldfePFcOE1H3fjmpKZHal7Wok9VKPN9YpCDy+ZKegCTP1XerX1GBR95WQBfn1Lu3h7UUfXo3RSx96jWG5lB2uzoIU3MXw3csEfW3y+uqwazassgi9EkhA6ccp+meO+vZQuA5W4zj6e4nAbF0Sm1TAnDQItcW1ye9l+yiteo5AjWLlv7lDEKk+kunziLo.xB6i6iJ8nwXein9+9e92KWgNh6iCtQ6H24lU44+mm775nMesyzEE5CHttbm4CG79ach1zQxf8GN39ycdzuB.6o7wxOKeDFtFM7UYG3aGsfOF5Q.fxXvUckW+YM4coz8yJ6qtoAg0U04+BsHgtStqjTn6DgVCwdA7m4ouAl77ymnFAvDS8ulHgyQx9n3Kb4jMSVqgP4HOyySlP6A.1WrM4VAaxuB1TXEro3JXy1qfM6rB1r60ZirRvxiE7gZtILPyZ5hjsqoJUTQSs9efxhbzA
                            

                            DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                            https://dhplugins.com/ | https://dcbreaks.com/
                            London, UK

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

                              @DanH What do you expect this to give you (keep in mind that this is in the sliderpack callback)?

                              local idx = btnRandom.indexOf(component);

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

                              DanHD 1 Reply Last reply Reply Quote 0
                              • DanHD
                                DanH @d.healey
                                last edited by

                                @d-healey Well, one of the things I'm unclear on sliderpack callabacks 😆

                                I have no idea how they are supposed to look!

                                DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                                https://dhplugins.com/ | https://dcbreaks.com/
                                London, UK

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

                                  @DanH Same as any other control. But your slider pack isn't in the buttons array so looking for it in there will return -1.

                                  The value parameter of the callback will give you the number of the slider that was moved.

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

                                  DanHD 1 Reply Last reply Reply Quote 0
                                  • DanHD
                                    DanH @d.healey
                                    last edited by

                                    @d-healey Oh right, so then I don't even need to get the value of the 'btnRandom' array then I guess, will give a go tonight

                                    DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                                    https://dhplugins.com/ | https://dcbreaks.com/
                                    London, UK

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

                                      @DanH Yeah, like I said, you can do the whole thing without the buttons. The buttons are only needed to provide a nice interface for the user.

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

                                      DanHD 1 Reply Last reply Reply Quote 0
                                      • DanHD
                                        DanH @d.healey
                                        last edited by DanH

                                        @d-healey So two issues now, firstly the random button doesn't trigger the SliderPack callback. Should

                                        SliderPack.changed();
                                        

                                        work? Doesn't seem to be.

                                        Secondly using the value parameter inside the SliderPack callback sets the filters every time a slider is engaged - probably better to have it only when it's value is 1.

                                        HiseSnippet 1941.3oc0Ys0babaEdWYuogJQoIY7zY5an7IpXZIRJRcopdJuHxD1nKzhztsiGMtP6BRhwKAn2ETVpd7Ltu0m5ug9Sw+e5K4eP6A.K2E7lBEyXO03AMD3bN37gC9vYO.pU.2kDFxCrrS04lgDK6uzo8MLQ+Z8wTlUyirrefCFZAxVeY62AMqp2LDGFR7rrsu22K0zN08sTse5OVE6iYtjjgrrdFm5RNlNfJRFsU4ej562.6Q5PGXncwxMc4rZbe9H.U2yIm0Pr6Kw8Hmhkpslik8mU2iJ3AsEXAIzx99U4d2ztO+0Ls9OiFRuzmH6j2pMLQ5gav88jHVNpUs9TeuViW8gVvrzJIVbOcr3ANmP8nwimDS9Zk.ThElwC60tM3k2Dd4Vd3Ya.u6qg223z1MfNTjHQhsuvoISPB5hgs.SXo00Zs+UJmZbPClXqA3WRZD.chsHyt4xkEsetbad3FqCaCgBzU3.TCpOnPdziQJxwV8Hh5c6RbEYRGIJ8jFbL9RhuT+wtBrnFevPNC5jIsV7T1z1m5QBZAa1K1PCcTVuw5aCMzI+UT0m1oyYm1FkgAzDOT.l4wGf5xCPLNJffC4rMM81kB14ZcdL54y2YmW4ziN6DvQY2Xcz7a2lgEVUC2YUMr3pZXozadwgKzxYYBxihgx.W5pzWMB6gNtU5ro+glnZOsC7iiOK5GspW4GSmEIkz9GpebizWLGZ0IbO8jseVzAYQ4ABX97YQ6Lotgw67MYdjqk5KULKp.nZVTwKTrgH9voU5TA3B5EWD0PJjx7oLBp6HlqfxYHthCzriL1Dv8y3NNvjE7o+HBvXdizNYTvm6h8i3UOSJDfvIX3vfbH3.TF.Nk1LJJBSXH2mr0v.JHwvnMOTEPQw+c6siYhO2PuK1JjHT+JS9wSpA4WJU2shPEOL8ADVlmIt8wrdDuLJYxU0aUgrEvKTwkzaJcTTzoF12+RX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5oMDQzQVfAHBf6dDKp90CwrP3SfgUBg4az.oJcwPsBI5ndyifELAxOFGN6zBerTavrxZfuhG.3W9.RSH7zQCzPPZSA8X5A9yxn64vFAGj7bcUC41ZmoZYuyBjieg5.wruayW6.UjMxGKl7IkjuiVj.HpMwa2HeeFHVJtwjr+A4clVV39MNsnB29yGuqMG7Be++CMdid0tMbzuMUBXuuSi+xG4mnK50T+VmVb+aF1mynt5zlJ.kJJwc9E8Ppu6+7jGVtQ.4UiHL2wQwx675WU9IlT.Yk8I8QkexHr+TQ8pzgbebvRsibukqzyelGO81nM+Fm3EE5SHttbm4SG79ach1zQxf8mN39qbdx+G.1y4ijeV9DLbOZ3qxNv2NZCeLzk..kwf65Ju+yZxKSo6ma78gZSXdpN+WnEILurucjv7iEZM.6Fvegq9JXxyOetZD.SL0+jiTNmH6iRtwkStsxYM.JG4EttxDZOBv97sovJXyNqfMEWAaJsB1r6JXydqfM6eq1HqDrxHAeflaBCzpttHY65pREUzTq+22uxk9
                                        

                                        DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                                        https://dhplugins.com/ | https://dcbreaks.com/
                                        London, UK

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

                                          @DanH said in Randomizer on 3 Grouped buttons, How?:

                                          the random button doesn't trigger the SliderPack callback

                                          Sure it does. Put a Console.print in your sliderpack callback and then click the button.

                                          probably better to have it only when it's value is 1.

                                          I agree.

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

                                          DanHD 1 Reply Last reply Reply Quote 0
                                          • DanHD
                                            DanH @d.healey
                                            last edited by

                                            @d-healey

                                            Sure it does. Put a Console.print in your sliderpack callback and then click the button.

                                            I just get 'Interface: [Array]'

                                            The sliders move when clicking the random button but the filter and label don't.

                                            DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                                            https://dhplugins.com/ | https://dcbreaks.com/
                                            London, UK

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

                                            34

                                            Online

                                            1.8k

                                            Users

                                            12.1k

                                            Topics

                                            105.2k

                                            Posts