Randomizer on 3 Grouped buttons, How?
-
@DanH Sure, just edit the button callback
-
@d-healey Thanks, I'm thinking cycling through the array may work better for me. Been searching through JS forums but finding it hard to translate into HISE script!
-
@d-healey Had a bash at this and I don't think I'm approaching it in the right way. The sliderpack stores the correct values, but the sliderpack itself doesn't trigger the button callbacks needed to make presets work. In order for this to work the sliderpack itself needs to be controlling the callback functions (I think)...
HiseSnippet 1962.3oc0YssaajaFdjSlh0dWuM61EEn2QnqjPTr0nC9PcCpNXocUiOnXojtKBLRomgxhHiHUlgxGZfAbuaeD5k8QYutuJ8l8Mn8mjilg5jWaglhlI.Fh7+zG+OP9Sl1AbWRXHOvJ0pcudHwJ0WX24Zlne89XJyp09Vo9M1sahNo5Q6e7gnZupa2iOpiUsqGhCCIdVoR8nuUxXpUerk56m+i0v9XlKIYJKqWyotjCnCnhjYaW4ETe+lXORW5.CtKUokKmUm6yGAf5Q14sFhceG9bxQXIaqXak5W0viJ3AcDXAIzJ0iqw8ttSe9kLM+ulFROymHG3X0ATjd5lbeOIhkyZUuO02q83EenEnk1IthGocEei8gTOZ77ItjmnHfRjvzejZk6BdNlvK+8GdoLf2i0v6qr63FPGJRnHw1ma2hIHA8vPHvDVZdsV4EqZWmCbvDaL.+NRy.XPrDY1Je9bncxmO6dquFDFBEnKvAnlTefAGzyQpbiMNmHZzqGwUjIcDozSJvA3yH9R9GaJPh57AC4LXPlzZxJYj+aS3Cc3OLN6BkgAgZOT.l4wGf5wCPLNJffC4rrlV4LA6DMOOG8l4aIcdKXpbquFZ9e2kfEVVAKtrBVZYErb5rmt2Bkb1norbJT53RWi99QXOzAsSmK820BU+UcgebvwQ+ncipuHcNjjRmuqwAMSe5bRMNj6oU1N4P6lC4.IQNN4PEOcu336QU6VEhsSrQhjHk4SYDTuQLWAkyPbULsUW4ZMf6mwc7BMGXO+QDHC3CR4jqJetK1OJO40Rh.DNDCInxofj5L.NJmMxq.JLj6S1XX.EnXHT18TNHT7eiyqdiAWmtQHQn9UFmwpbAL51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P+qDy2A3gktV1vpVtFVMe3xj974Onfr4tAVELL9+31JWR8D8im3G+aU5SjmukTawlNOPioZA7KCIASlG3rU9sKsa4s1Yl7fc1dqcKrcAmoyCTYHkcbbJqyCV4YohRDjmdzAbBZmIDzEAiH4hI03pgXVHbJVX0PPeiFHYoGFZ.KgG0aNDr.EHOOMbV0Bm2oEXVZMwWvC.7Ke.mIHdznAZHHkofdN8D+Yo28DHPvAJuQ2XP9MJN0WtGLA47mppAl8cSdhMzj6HerXxmzQ9NVQD.u1Duch78Q.eo3Zy76OJuyy8Etekcapvs+7w6JyAuvw2erwazqlsts9sgR.6isa98+O9IxhdLyu1tM2+5g84LpqdmREfVMZuZmE8Pl29ud4SqzLf79QDl6XuXkhW99JuzLEPdYojwnJubD1Owqe6O9O+6UqQGx8wA2qHxitecO9K73k2UZyu0NdQg9DJWWFY9zAu+N6nfNR5r+zA2eo8K++.vdBej7X4Cwh.JbprMb1QG3vPWB.TFi3KukUpUj2GRONubr5lBDlmZv+F9hH5HGmJhnyXhVCvtA725puEkr94yTy.Xho9OYXU6CkiQwWZx1N+F4sF.cf7VWW4FZOCv97kovRHSwkPlRKgLkWBY1ZIjY6kPlctSYjM+UcjfOPmaBSztgtu3TMTcGpRSs9O.5ywCt
-
@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.
-
@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)
-
@DanH The button callback contains some code that randomizes the filter. Take that code and put it in the sliderpack callback.
-
@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);
-
@DanH No, I'm talking about the code that randomizes the filter. The part that sets the attributes.
-
@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
-
@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.
-
@d-healey I still need the 'Tabbed Interface' script though don't I?
-
@DanH I'm not seeing a tabbed interface in your snippet
-
@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); } } }
-
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).
-
@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+IzPZGehriqUKXhzCWm62UhX4nVUG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ulHgyQx9n3Kb4jMSVqgP4HOyySlP6A.1WrM4VAaxuB1TXEro3JXy1qfM6rB1r60ZirRvxiE7gZtILPyZ5hjsqoJUTQSs9efxhbzA
-
@DanH What do you expect this to give you (keep in mind that this is in the sliderpack callback)?
local idx = btnRandom.indexOf(component);
-
@d-healey Well, one of the things I'm unclear on sliderpack callabacks
I have no idea how they are supposed to look!
-
@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. -
@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
-
@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.