Master Bypass Button
-
@ustk Thanks again for doing this, super helpful I have a few questions if that's ok?! Feel free to answer whatever you feel like by the way!
-
Declarations: So I'm declaring the modules and buttons outside of Arrays because I'll most likely need to refer to them in other parts of the script. As far as I can work out, only declaring them inside of an array prevents me from referring to them in other functions - is that correct? Otherwise this is a very neat solution :)
-
bypassArray: In the first example of the bypassArray, the line inside the callback 'bypassArray[0/1/2/3etc] = value;' will load the '= value' value into the index of the array, is that right? So if the value was say, 59, and the index number is 0, then the first value in the array is 59?
-
bypassArray example 2: 'var btnIdx = buttonsArray.indexOf(component); - nice, I haven't seen this before, I assume I can use this in the same way for other Arrays? However the last line 'for (b in buttonsArray) b.setControlCallback(onBypassButtonsControl);' is confusing to me... I've not seen a callback like that before. What does the 'for' do, and likewise. what is the 'b' for?
-
Lastly, I'd like the buttons to all switch off as well, and then return to their previous state like the modules do. I've tried adding buttonsArray.setValue(1); but can see that's probably not going to work (and doesn't!). Make a second array for the buttons? Have a duplicate set of buttons which are linked?
Like I said, thanks so much for this, even just typing these questions is helping me get a grasp of it all.
-
-
@DanH said in Master Bypass Button:
As far as I can work out, only declaring them inside of an array prevents me from referring to them in other functions - is that correct?
An array is just another type of variable, you can refer to your modules from the array variables or from individual variables. You don't need to use both.
'var btnIdx = buttonsArray.indexOf(component); - nice, I haven't seen this before
You should watch more of my videos ;)
-
@DanH said in Master Bypass Button:
the last line 'for (b in buttonsArray) b.setControlCallback(onBypassButtonsControl);' is confusing to me... I've not seen a callback like that before. What does the 'for' do, and likewise. what is the 'b' for?
Please go read up about Javascript - this is standard notation....
This interwebs is full of explanation for this sort of thing:
W3Schools.com
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
(www.w3schools.com)
-
@d-healey ha I do... but there's a lot to take in when learning for the first time. I have to rewatch them from time to time when I've learned more, and they make more sense to me.
-
@Lindon good site thanks
-
@DanH said in Master Bypass Button:
- Declarations: So I'm declaring the modules and buttons outside of Arrays because I'll most likely need to refer to them in other parts of the script. As far as I can work out, only declaring them inside of an array prevents me from referring to them in other functions - is that correct? Otherwise this is a very neat solution :)
As Dave said, you don't need to use both, but you can if it's better for your implementation. You can also just keep the array style and refer to them later in the script with
moduleArray[x]
- bypassArray: In the first example of the bypassArray, the line inside the callback 'bypassArray[0/1/2/3etc] = value;' will load the '= value' value into the index of the array, is that right? So if the value was say, 59, and the index number is 0, then the first value in the array is 59?
I'm not sure of what you ask.
value
is the value of the button you pressed. it will be stored inbypassArray
at the indexbtnIdx
, so the one corresponding of the button pressed. Play with the buttons and watch thebypassArray
content changing in the ScriptWatchTable tile, it'll make sense to you...- bypassArray example 2: 'var btnIdx = buttonsArray.indexOf(component); - nice, I haven't seen this before, I assume I can use this in the same way for other Arrays? However the last line 'for (b in buttonsArray) b.setControlCallback(onBypassButtonsControl);' is confusing to me... I've not seen a callback like that before. What does the 'for' do, and likewise. what is the 'b' for?
Like @Lindon said, go learn more javascript related stuff, try to find exercises online, it helps a lot...
for the moment I can just tell you that this is equivalent to:buttonsArray[0].setControlCallback(onBypassButtonsControl); buttonsArray[1].setControlCallback(onBypassButtonsControl); buttonsArray[1].setControlCallback(onBypassButtonsControl);
Or,
for (i=0; i< buttonsArray.length) buttonsArray[i].setControlCallback(onBypassButtonsControl);
but
for/in
is better isn't it? ;)- Lastly, I'd like the buttons to all switch off as well, and then return to their previous state like the modules do. I've tried adding buttonsArray.setValue(1); but can see that's probably not going to work (and doesn't!). Make a second array for the buttons? Have a duplicate set of buttons which are linked?
So you mean the opposite of Master Bypass? In this case, just do the same thing using
moduleArray[i].setBypassed(false);
instead oftrue
With all of this, you can now even make a single callback for the Master Bypass/unbypass buttons, since the only difference istrue/false
. Just use theindexOf
magic trick to determine which button has been clicked, and thenif
you should usetrue
orfalse
(there's even something shorter but I'll let you find your way with a simple IF statement first ;) ) -
@ustk Thanks mate! Making a lot more sense now :)
So my last question: I just want the buttons to do the same as the modules - they all turn off when you press the master button, and then they return to the state they were in before you pressed. So doing exactly the same as the modules.
This is because the buttons are on the ui, and need to show that the modules are off (otherwise the user can't see it). Does that make sense? Becasue buttonsArray is already in the callback I don't think it can be used again...
And I will try to figure out the quicker method, give me a few weeks :face_with_tears_of_joy:
-
@DanH so just add them to the Master callback
inline function onmasterControl(component, value) { for (i=0; i<buttonsArray.length; i++) { if (value) // If Master bypass ON { moduleArray[i].setBypassed(true); // Set all to bypass buttonsArray[i].setValue(true); } else { moduleArray[i].setBypassed(bypassArray[i]); // Or restore their state from the array buttonsArray[i].setValue(bypassArray[i]); } } }; Content.getComponent("master").setControlCallback(onmasterControl);
But this is weird because then the user can change individual bypasses while the master is still enabled, so the Master doesn't reflect what it should anymore and you just transferred the problem... I would prefer to hide the individual bypasses when the master is on. Another solution is to add a safety in the individual bypass callback so when you click a button, the master automatically switches off
-
@ustk Ah, I was trying to add buttonsArray[i].setValue(true); etc to the callback but I didn't have the extra {} - why do you have to put these in, if you don't mind my asking?
Yes could be a bit weird but I think it will work for its purpose (It's an audition tool, to let the user hear what the sound is like without all the fx and modulation on it).
Legend :)
-
-
@ustk Hi mate, one last question on this! So it would be really neat if the buttons could execute whatever their functions are with this script. So then we may not need the modules array, and can add extra functionality to each button from separate callbacks. (I'm saying this because the project I'm working on is way more complicated than this snippet!)
I've been trying to put in .changed(); but it changes the state of the buttons permanently, rather than referring to the bypassArray, perhaps because the values have now changed within that Array?
inline function onmasterControl(component, value) { for (i=0; i<buttonsArray.length; i++) { if (value) // If Master bypass ON { buttonsArray[i].setValue(true); // Set all to bypass //buttonsArray[i].changed(); } else { buttonsArray[i].setValue(bypassArray[i]); // Or restore their state from the array //buttonsArray[i].changed(); } //buttonsArray[i].changed(); } }; Content.getComponent("master").setControlCallback(onmasterControl);
-
@DanH Which of those
//buttonsArray[i].changed();
lines were you using? Or were you using all of them? -
@d-healey I tried each one but they all had the same effect... EDIT - Or slightly different effects but none that were desirable :smiling_face_with_open_mouth_closed_eyes:
and different combos
-
@DanH So I finally went back and looked at this and managed to get my desired result by using a set of parallel buttons (containing the callback functionality I needed) which were linked to the buttons in the buttonsArray
Snippet below if anyone interested. PS - I'm not gloating its just nice to tie up threads with solutions if and when possible
And thanks to everyone who helped solve this :)
HiseSnippet 1915.3oc6bstaaTDEd2jrPsKAQQ7C94pJ9giZavWpMfBn5bErnIwpNM.pppcxtiiGkcmwr63PiphDOJ7H.hW.dD3QfGg9F.mYlc8Na55qsosJrahr7b47semK6bNyXmzNf4fCCYAFlEN3r9XCyOvpyYTduM6gHTiVaYXdMq06rE7qwFm0GEFhcMLMW7aEiZVXIC40Kt2FHOD0AmzkgwgLhC99DeBOo21M+dhm2NHW7ADesYe2lsbXzMYdrA.SVzprQejyIniw6gDSaAKCy2aaWBmEzgi33PCyk1f4dVmdregpl+gjPxQdXQiJFc.fTcuCyyUvXw6M1rGwyscrFGZXXVrch9unR++DqcItjg8mXG9H4.1IRnaOLWXbzqhN8JmI8pjE8L0n2RJ5cCqNNAj97jQDb65VsnbbPWD3BzokZtFK7mW2ZSFLCJeUezI3cBfFCknTixkusc8xkWYskKBtgPt8on.6e.cJli.RKiGvgjPbPE6uwV1b0iwbIeksJcygS1Ve12bxHVclPr5TfXsYBwZW.w1HJ1Snlw1KAHL+9LJznzMUCmkLUGuLUyRlZiWFE2h+IQ1iFv4Pi0CBPmAH7nrgXC4r.td6kKZOxqwIa0WAYAt+30RSael6.O7PVmoOpSq81dBTdjxUcNkKhpiTvT5vDL56pz96NRpLVwpOeh0H1VmJHQtLfhtB9930D374et8A8v1HY27dHtcHrpENDdONNtB5RrHlcIEDqnPFjr0da05vVa8v0uu8F+T606zY6NKWjP8HTrc2ATGNgQsYT0BPJpEJHd.yqjSLquMvNuAX.0mqTUIY4zVtOCnodn8pDpK9Y62MQ1UVSoB+POhSun4Z2CEZeDFSsc7HNmfcUnpdU4tdjB9GuZHlen3lWRQg0FZdAL6f4RifCK.rGv8ykPONJlMxXlIlN8PziwtkjnolgloOdZfpIumqkkyUb2EdA48GTZxoD2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