Button from array
-
@Jay ok so first - please put your code in code quotes.
Second - this is incomplete, there are no buttons to turn on/off, whats irs? - assume its the array of IR names
third - ok assuming there are a set of buttons called Bottom1, Bottom2 etc.
function turnoffAllButtons() { // loop round all the buttons turning them all off for (idx=0;idx< NUM_BUTTONS;idx++) { myButtonArray[idx].setValue(0); }; } const var NUM_BUTTONS = 4; //you could use the array length instead of this var myButtonArray = []; myButtonArray[0] = Content.getComponent("Bottom1"); myButtonArray[1] = Content.getComponent("Bottom2"); myButtonArray[2] = Content.getComponent("Bottom3"); myButtonArray[3] = Content.getComponent("Bottom4"); inline function onKnob2Control(component, value) { rtLbl1.set("text", irsNames[value]); ConvolutionReverb.setFile("{PROJECT_FOLDER}"+irs[value]); //turn off all the buttons turnOffAllButtons(); // just turn on the button you want myButtonArray[value].setValue(1); // do the processing you have inside your selected button.. myButtonArray[value].changed(); };
I just wrote this in here - not in HISE so there may be some syntactical slips...
-
function turnoffAllButtons() { // loop round all the buttons turning them all off for (idx=0;idx< NUM_BUTTONS;idx++) { myButtonArray[idx].setValue(0); }; }; const var NUM_BUTTONS = 6; //you could use the array length instead of this const var myButtonArray = []; myButtonArray[0] = Content.getComponent("ambience"); myButtonArray[1] = Content.getComponent("chamber"); myButtonArray[2] = Content.getComponent("hall"); myButtonArray[3] = Content.getComponent("plates"); myButtonArray[4] = Content.getComponent("rooms"); myButtonArray[5] = Content.getComponent("spaces"); // =========================================== Selecting Bnt const var Knob2 = Content.getComponent("Knob2"); const var rtLbl1 = Content.getComponent("rtLbl1"); inline function onKnob2Control(component, value) { rtLbl1.set("text", irsNames[value]); ConvolutionReverb.setFile("{PROJECT_FOLDER}"+irs[value]); //turn off all the buttons turnOffAllButtons(); // just turn on the button you want myButtonArray[value].setValue(1); // do the processing you have inside your selected button.. myButtonArray[value].changed(); }; Content.getComponent("Knob2").setControlCallback(onKnob2Control);
it's giving me the error "this expression is not a function" on the turnOffllButtons();, myButtonArray[value].setValue(1);, myButtonArray[value].changed();
-
@Jay did you declare all those buttons? - where?
perhaps post a snippet?
-
@Jay said in Button from array:
error "this expression is not a function" on the turnOffllButtons();
Check your spelling. And you should probably use an inline function here.
-
-
HiseSnippet 1698.3ocuXssaabCDkqs21Xk5fl19Peo.D5IYjTacKoEv0HxWjRTiuHXIm1BCCCpcor1jcI2rKWmHDXf9XeLeB4k9ej+g9CzOg7GzNj6ccwWQ6Z.CwYlyvgyLb3P1wiaP884dHsE6Mxkhz9B8tiXhgaMjXwPs2FocO8cI9BpGNjzlibI99TSjl17OURPawEPpuO8jMI1DlAMkDB8BtkAcGKGKQJ0NMdtkscKhIsmkSFoq2nsAmsE2lG.1y75kQtDiWQNktGQJ1b5HsOqookf60UPDTePlM4li5Nj+FVn7uvx2puMUNnBpKnnPxnsFZYa1Ids5iPZKzIckOe3J+az20xzJgdpG3KULvoHx5CzlKuIsPNSpRVSpbFSpE21TpfYXdZYLuEBMu6q20vyxUjxQZa2UuMCBNCHfaOqYEJKZtOrn9VbPBlXEGxqns7fAIHJ83xkeH9QkKu7ZKUXoBfy2WfOi.gZN6LtcfvhyNfdF0qOdcrJsXkSohMBLs3cINt1zDaoTwIfTTpzlrSsXzUr4DSErVV1TeX94c3b6RKuFFu5p3c.t3MrswsO.aA7vNTGt2HL7q9TrKHYdqay.gfyp.1T7RCrps3NtbFLnTwH9JCXbTUuDTUmJpZWBpZSEU8KAU8hi62s77ALGcrhL3YVe80wa3z2hB6pprTAf8QkOFjnXLwUdC4rhfWL7CPHB7XINHNKDSkbXplCzrvTUgA1D3zm5keZFCS0DL0TXbsk6DpbgXpkfodFLUuhXdjBCWLbBKabL0Sv73TLiOMSESr++59gkEq7w7AP1b2whsgrt3.rRlwhxEWKCqwBl43kKnkiSXnoSXnIGm5Y3jWaYby4nG5J2u2yZdfBvREFDvLj67UtQ9fAvl4PeoeokWpv6VpPpi1lycwd7.lIl.a4Aki6GJpBrE6TIMGESPSIPwC3dXbIKy2td40f++S38Nb2S17vd81eutRBO3AKmJb5TJ+bFEZMa34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RDdVxoeu.mtPmRFTHegwn19xobN4oGgiKGaBcoLS0f+A9hXVQNVKhYkXl+uLGNDCO9IFgGwIS+tihBrtYJW8h56JGiSNVVWu7JkA2uo0IFFxMEeeEDZ5XpdCvT6Ffo9M.yitAXd7M.yObCv7iWHF4yXtQff6DVvDHzoopCCMslLBj8pJ.f9WvsHMBi
-
@Jay said in Button from array:
like we said make one small typo fix and it works
HiseSnippet 1656.3ocuXssbaaCDkz1LMVsJSSaenOhQOIOIUV2RZmw0SksrThZ7EMVxoW73wCDIjEZHAXHAchlLdl7XeLeB4SI+C8GneB8OncAHEuHKY6nlD9fFgcwYwg6tXwB10iaR784dZ5q1erKQS+KL5MlIF0bDlxz5ril9cL1C6KHdnPQaO1E66Srzz0W9QRA5qthl54e9osw1XlIIQjl1S4TSxtTGpHQZ2FOgZa2FaQ5ScRM65M5XxYM417.fOKaTVyEa9L7Yj8wxosjgl9sZYQEbudBrf3qoux1bqw8FweAKb9Ok5SGXSjCpn0CLTn31baKIikR0ZNhZa0cx6suFXktIdgkC8BeiwdTKZr7DuwWpTfRPj1enuzUQuJooW4aN8zSQuUBo2cM5Y5QcEIZjb6yM5vf.0PLDBRSqv4pszaW0nIGlASTxA+LRaOXPLhhOrb46idP4xqsQ9b4yAABeA5bLD14ry41ABJmcH4bh2.zlHUJRoyHhsBrn7dXGWaRLWJV3RPJHMZK1YTFojMGaof0lZS7g0m2kysKt1FHz5qi1Ezh1x1F04PDEzgbHNbuwH3eCHHWXlYY21ABAmUA3zjWMfUM4NtbFLnXgH8JBLMppWCppyDUsqAUsYhp90fpdgo86TOe.ywmnDCdlM2bSzVNCnDXGVk74.0GW9DXFElHrzKvmW.7hgO.BQfGK1AwYgXpjAS0LflGlpJLvl.mADurKyTXpFiolBiqsbmPkqDSsXL0Sgo5MDyCTX3hQWhYSiodLlGlfY5kYlXl3+eeePxBW9H9PHat2Tw1PUWc.VMmohxE1HkpoBlYzkInkQSXnoaXnIil5ozj0ZobyYjG5JOn+iacnB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wFmYMdLsYJa7m+UicvNtPCComS618iJZlHB5KJ9q.4HeSLTmfnpAF9W4kIfngmHsfVLqIC0WNaDa4a1YqyHg4Pdfriz8vBOpb42OvoGzdiIAxWXLhs7fa8kjmtDNt7DJzivrTC9W3IRYE4X8HkUln7SxZ3fM83mZFdDnL861JIv6MS4pW0XO4XT7w1FFkKUFb+VzSMMkaJ9tJZZyFS0E.SsE.S8E.yCV.LObAv78K.le3JwH+1iaEH3NgELAAcao5.QWuECCYupB.Z+meZiPb
-
@Lindon the problem I have is that I have like 30 or so, does that mean I have to put 30 buttons in the array?, because right now is selecting the 4 first one, but was hoping to group it by category, let's say for example: 5 ambiences, 5 plates, etc.
-
?????????
-
@Jay you have a solution - you work out how you should scale it.