Switching sample maps with radio buttons.
-
It looks fine, but I have some suggestions. I'm just putting a snippet together.
-
@d-healey Just noticed that it does 2 switches ...one for the button it is turning off and one for the button that is turned on , which makes sense I guess but could be fixed ...hmm. Console print reveals this.
It does not have any effect as such as the one it it turning off is the one selected already but might be a performance issue.
-
This is probably how I'd do it
HiseSnippet 3031.3oc6b0sbaabEFPRH1hINsIMclLcZmAiyMTQpp3mE+vwoSjDkjsZjr3H539iqGOvjqDQMH.GPPaq5wuF8t9NzK6kc5SPeD5iPdCZ2E+PrXEjB3oZscRptQb2EKv4a+NmydNmkD8hiFfmNMJVRd0Gb9Drj7Gnz+7vjQcG44GJcvtzNl9B+jAi7COyVZmym3McJdnjr7x2kdExqthT5eeyWtiWfW3.bYWRROLxe.9P+w9Ik81aquxOHXeug3G3Ol4pQacvfnvtQAQyHRyxJZRS7F7Luyv22idYKoHI+d6MzOIJtehWBdpj7J6DM779ihdQX10+P+o9OM.SanK0mbix5d+nfgTIl1qT2Q9AC6Uf5oRjaZux0fkyVC9Dki7G5Ou+x0heb5.pkyfc8PdoqR7zYEOslKdxLh2JYh2GozePr+jjxQnx16qbPXBN9TOBEvJVYWqzR8VRoaD4JBS1br2yv6GSZLeFss0z1P0RSas6bqV2pEgHlln9buX0miChF3mbt5uVMUuXyyvIUVbZe6hK417y8oyRRHMHS8QONcnSihUa6SZqcGUe0uPEQ925qu1sZ8pa0Rk7W9D1bxroiZWHrjGX2nwShBIMZe6rK41pqStQqqu1ZzmIyTej+i2bJcBgIwQAc8BBdJQIpc1nEMW6NsdMUb7CC7CwpmNKbPheTnZ0qp8fhm5FDzDLCWJmD75En5GND+RBXJj5z1GeZ47JjshEHpjscRRrOYF313WhGvt3sY18Y8zaSwijHoyEunv6GkfONr8ZsdUqUa85Vp7Cc5o0NV9pQ.Nt1golgwW0DaGNa7SwwExTwERzGqpvqb4J7r1iCxHVlKLJ7fP+jimfCuLy.obsAhAgRtTQtzjTygOL2bXmz0OIehV+pJYKl5RohLqWJoEX5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JPLEWTdDSJfE1RHZefJtEewF5XnAr3VhASf1ihmmp8LVZRAtDBl1w35HB1Nt.KxkXvDDdBwkEnE3BcIDmDfJ1ksAOnrc.VrKAAJHLkMGnbqM.olTvKgn8AonWjjnpVSEaGDvhdIFLAJlOtLNbb6.rvWBQ4CTwurL3puuoiKvSvTPfBDSweLlZF.qnmPz9185nnDNVPqpmXvDjX9rLaR7QMoxdBASPptGxkyfBY6Br5dhASfh4Cwenl5.qvmPbR.pJe1ZVbmjdsmKSSpxmf.EDKJc9JHUejrMvKApDTVWFntykCpiiI.hCVo8AySga0LozcQc.5oPX3Bh2hKTGIMCKfdKDGttF9pEZnUe17MviQSv0W.AWf7ZXoWMUQcGSndMDHvfvXnp6aYnqC8LBDll39fBvkmvpuXYM3bBDGtfrmLWQ.MzpUQrImUfvTDgcdAc3HLacneIdEHv.cNo1bLltEvyLPXZhPN2.Kqp0uP2xvD34FHNbA56c.hiuzfd1ABSQD34GXyQXt1.O+.ABrEmwHwXTcOLMsZAVSNCAgoIB4bDr5vYgYifdNBhCWfh4PiyByE5WVVggKPmm.mdntskCvySPb3BzNXb7ktqFvyTPXNNf8knUupAlVGCWfmqf.AFju4O5Vb4MW62Evlb1BBSSDzWpVatJRYna.77EDGt.8CvgySuiMB3YLHLEQXeIaQ7A+ZA8WJk.AFDKLDeTh09iBsIm0f3p3FjXNrM49VQS+wgx76n9lY+Np+YJ2MH5odAk+ZpiBS77CyeC97KxGVc93pyufq5sl0+55+slE+6InUZ1a6fuk2Oqq7N8qO1l9Ce+mbAZZ5++Uxv24dkL7l3UGvahmwXuAwQOYP16eGpQ1MS6gf6vTmfqpbDss57W5OJJZapIMlXb8jACnK2+Rx5S8yw.vbLALGDf4XAXN1.liCf43dkyg5Wa6YIQiyLEIczaur2nDxy2jQdYo+KPMeIr.�
-
@d-healey said in Switching sample maps with radio buttons.:
Yep, that is much,.....much neater :)
Thanks !EDIT: is it safe to have a loop in the Oninit of the midi scriptprocessor ?
Also, what is the exec for in this.
velocity.setAttribute(exec("velocity").button+index, value);
-
is it safe to have a loop in the Oninit of the midi scriptprocessor ?
Yes, the
init
callback is not real time so we're safe there.Also, what is the exec for in this.
My secret sauce :D It executes strings as if they are code. I posted a video about this on Patreon a few weeks ago.
-
Actually the secret sauce isn't needed here, I was trying something else and left that in by mistake. :p
-
@d-healey This is turning out pretty smooth .
Btw I am using the Midi processor at the top of a synth group , works very nicely and switches all samplers in the group. -
@d-healey found a small problem with this , I am now velocity switching a synth group with the buttons and that works perfectly , but when I recall presets , it loads the correct button but does not do the switching ?
I can see it also switching the buttons in the Midi processor.I can also see that it always goes to the sound represented by the last button ?
BTW> same thing happens with my earlier version of the script ?
Any ideas ?
-
When the preset is changed you need to update the variable that tracks the velocity offset.
-
@d-healey How can I track when a preset has been changed ?
-
All control callbacks (for controls that have saveInPreset enabled) are triggered after a preset is loaded.
-
@d-healey This seems to have solved it.
reg mapSelector = 0; const var maps = [0, 2, 4, 6]; const var buttons = []; for (i = 0; i < 4; i++) { buttons[i] = Content.addButton("button"+i, 150*i, 10); buttons[i].setControlCallback(buttonCallback); } inline function buttonCallback(component, value) { **if (value == 1) { local index = buttons.indexOf(component); mapSelector = maps[index];** } }