Switching sample maps with radio buttons.
-
This post is deleted! -
@d-healey So I have a combobox where I can select samplemaps.
So I have the array for the sample maps , unsure how I can select a sample index with a radio button though , anyone that can help me a bit with this ? -
Hey there, I played around with it a while and found a solution. It´s not @d-healey style, like looping through everything all efficient n stuff But it gets it done.
Note: I just made the basic Samplemap loading using
Sampler.loadSamplerMap()
, but did not make any actual radio buttons in the design, but I gathered you got that covered from Healey´s video.// onInit Content.makeFrontInterface(633, 400); // store references to the samplers. const var Sampler1 = Synth.getSampler("Sampler1"); const var Sampler2 = Synth.getSampler("Sampler2"); const var Sampler3 = Synth.getSampler("Sampler3"); // UI references const var ComboBox1 = Content.getComponent("ComboBox1"); const var boxVals = ComboBox1.getAllProperties(); // just get all properties of the combobox element, for later reference. // just printing all values of the combobox´s available properties: for (var i = 0; i < boxVals.length; i++) { Console.print("ComboBox1:s element id " + i + ": " + boxVals[i]); } // get state of combobox, on init: const var cboxState = ComboBox1.getValue(); Console.print("Current choice made in combobox: " + cboxState); // onControl ui-control: function onControl(number, value) // this needs to be copied into the onControl callback. { if (number == ComboBox1) { Console.print("ComboBox1: " + value); if (value == 1) { // loading Samplemap nr 1 for all three. Sampler1.loadSampleMap("Samplemap-1-1"); Sampler2.loadSampleMap("Samplemap-1-2"); Sampler3.loadSampleMap("Samplemap-1-3"); } if (value == 2) { Sampler1.loadSampleMap("Samplemap-2-1"); Sampler2.loadSampleMap("Samplemap-2-2"); Sampler3.loadSampleMap("Samplemap-2-3"); } if (value == 3) { Sampler1.loadSampleMap("Samplemap-3-1"); Sampler2.loadSampleMap("Samplemap-3-2"); Sampler3.loadSampleMap("Samplemap-3-3"); } } }
Here´s an upload of the full project from my hise testing, so you can load it directly, with a single sample in the all the sample maps.
radio-buttons-control-samplermaps.zip
Made using Scriptnode branch (2020-08 ish), if that´s important. On macos.
-
@andioak said in Switching sample maps with radio buttons.:
// loading Samplemap nr 1 for all three.
Sampler1.loadSampleMap("Samplemap-1-1");
Sampler2.loadSampleMap("Samplemap-1-2");
Sampler3.loadSampleMap("Samplemap-1-3");That is helpful thanks.
I am still not sure how to approach this ...how can I assign an index value to the buttons in the radio buttons , I guess that would be the way ?
-
Are you planning to let the user change sample maps by clicking buttons?
-
@d-healey yes , that is the plan .
-
@d-healey These buttons will be switching sample maps.
-
Ok, but if they do it while the instrument is being played they will get some surprises :)
-
@d-healey Isnt it just silence while it loads ? I tried it and cannot hear any glitches or nasty stuff ?
Its the same as changing a sample map via a combobox or a preset.
Not great for live playing but kind of acceptable in a daw ...I guess.
To be honest, not sure if that is acceptable?To do it without interruptions I would need 26 samplers.
Only 9 running at a time though ,with the other disabled when not in use.. wonder if that is a better way to do it ? Also wonder if they take any cpu if disabled ?
Just concerned with the cpu, is it advisable to run have 26 samplers in a project ?Any recommendations ?
EDIT: I could maybe cheat and map 2 sample maps into one sampler and use transpose to go from on to the other ...if that makes sense ?
That would reduce the amount of samplers needed , although that might give me silence as well....EDIT2: Could I somehow cheat by loading each sample group into different velocity layers and then switch the velocity around ? No velocity is needed for the samples themselves. Probably not...:P
-
Okay I got a little upgrade here with 6 linked buttons. It does what radio-buttons do. One turned on turns the others off. Also, no button can ever be turned off, if it is trying to set itself to 0, we simply switch it on again.
onInit callback:
- const var all elements
- set array with elements var names
- sync array with states in 0s and 1s in arr_buttons_sw.
const var Button1 = Content.getComponent("Button1"); const var Button2 = Content.getComponent("Button2"); const var Button3 = Content.getComponent("Button3"); const var Button4 = Content.getComponent("Button4"); const var Button5 = Content.getComponent("Button5"); const var Button6 = Content.getComponent("Button6"); const var arr_buttons = [Button1, Button2, Button3, Button4, Button5, Button6]; const var arr_buttons_sw = [ [1, 0, 0, 0, 0, 0], // for button 1 [0], we set all else to 0. [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1] ];
Then the onControl callback:
for (var i = 0; i < arr_buttons.length; i++) { // loop through the 6. // for any button matching one in array list. if (number == arr_buttons[i]) { if (value == 1) { var btn_nr = arr_buttons.indexOf(number); for (var j = 0; j < arr_buttons.length; j++) { // now setting the elements all in one go to their pre-set values in the arr_buttons_sw array number presets. arr_buttons[j].setValue(arr_buttons_sw[btn_nr][j]); } } else { // we dont want the value to be able to be set to 0, cause that´s not radio-style. number.setValue(1); // just set it back to one. } } }
Here´s the new project in all its might:
-
@andioak I think you can tidy up and just use this to get the array.
const var Buttons = [Content.getComponent("0Btn"), Content.getComponent("accBtn"), Content.getComponent("soloBtn"), Content.getComponent("orchBtn"), Content.getComponent("organBtn")];
-
@lalalandsynth said in Switching sample maps with radio buttons.:
EDIT: I could maybe cheat and map 2 sample maps into one sampler and use transpose to go from on to the other ...if that makes sense ?
That would reduce the amount of samplers needed , although that might give me silence as well....
EDIT2: Could I somehow cheat by loading each sample group into different velocity layers and then switch the velocity around ? No velocity is needed for the samples themselves. Probably not...:PYou have 128 keys, 128 velocities, and a whole lot of groups in each sampler. You can almost certainly map everything in a single sampler. I do this all the time unless I need different modulators/effects for different samples.
https://www.youtube.com/watch?v=dG-7K8cZoLI&lc=Ugxe66xKq5OP9f1-L2l4AaABAg
-
@lalalandsynth said in Switching sample maps with radio buttons.:
@andioak I think you can tidy up and just use this to get the array.
const var Buttons = [Content.getComponent("0Btn"), Content.getComponent("accBtn"), Content.getComponent("soloBtn"), Content.getComponent("orchBtn"), Content.getComponent("organBtn")];
If you rename your buttons you can do it in two lines.
for (i = 0; i < num_buttons; i++) buttons[i] = Content.getComponent("button"+i);
-
@d-healey I dont need any different fx or modulators , so this is perfect , will have a look at this , thanks !
Btw , is it then possible to switch without any interruptions ? -
@lalalandsynth said in Switching sample maps with radio buttons.:
Btw , is it then possible to switch without any interruptions ?
Yep
-
@d-healey Awesome , redesign time !
Finally understood the Defer script thing as well .Thanks mate !
-
ok, So I have set the instrument up with velocity switching but a bit unsure of how to implement the buttons since I am not using the keyswitching , should I set up 4 buttons in the Midi processor On Init and then link to those buttons for the main interface or do I do the whole thing from the main interface script ?
not sure if this is the right approach ?
-
Your interface script is non-realtime, so it can't change the velocity of incoming notes. So your first idea is right, you need to add 4 buttons (or a slider pack) to your velocity changing script, and then link the interface controls to them.
-
@d-healey This seems to work , wonder if you could have a quick look and see if I am breaking any practices here ?
HiseSnippet 3261.3oc6bszbbabDFKIgkHsoSriSUtRkTEJ5KTkUTviAO1njxjbIoLiIEYQJq7vQkJncGRhHr.aAfkRLpzkbH+Kx+gbLGyOgbLGyOAeOGRlAOVLX3vkX6rijcRVxCKlA8L82zyzS2eCVbTRbebZZbhRmkezkivJcdO0StLJ67dm6GDor21zBReQPV+yChNyQYqKG4mlhGnzoyhOfdGcVdIk7Oe8mskeneTebcQJJONNnOd+fgAY0kdzFeQPX3t9CvOJXHyci1Xu9wQ8hCiGSzlEU0UF42+49mgenO81VPUoy6ryffr3jSx7yvoJcVZq3AWdx4wuHp39ebPZvyBwzKLTNgzPEEuab3.pFS+tRuyCBGbTEpSUHM5Q0iAKVLF7QpGDLHXR40iEe27Jzpkfc7nyBSS8L.pdcXTukJTuOP8j9IAixpqgpauq5dQY3jS8Il.V0p3dUV3etjZuXxcDkcug9OGuaB4hIRrtit9c0r00uy8WcE5eDSQZl1E9IZOabVVbjg1OWqR7yvY8hGNJNhbw5qUV+ZTI4kx7FjxTnTV2fTVBkBcCRgVq.aZW8ivBoEW2GWfCi6GjcIoSxWeP6hFSRVespaoreBhBChvZmNNpeVPbjVbT4HEUIShCWuekFdWRODNFemUW4UqtxxUMy8RwYalkkDPDCu9jR2JuQrqjgzUuNu6tAiCs0J63d9ggOirzZcdMpx1ecZt47PyclIM2b5ZtYK0bq4gl6NSZt0z0bqVp4n4gl6MSZNZ5ZNhSyq9irfgQ6eXbF9vn0uyJuZkkW40qbkpN8Tg0U11g3DgUS2wHYZBtdz3gOCmTg2paj35rouY014atewvDyMFGsWTP1givkWeUO1JkisDe2pkZE4Vyx8b+9kdtKLKJADGzKqVtHTIWkY2PUYFD2rRb0N4ROChZAWTzrK52oQQWA0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4+a7N92qWy76eLQ+bs6rzagWOZy+e36euqXlR++uRF9V2qjg2Du5.dSzGC86mD+z9Eu+cnKxtcdIDbGk6DbY0CnWqM4kTrpp98zUFRVb8z98oC2+Xx3iXYLAHiE.YP.jwFfLN.jwEfLdSUFpesMGmEOrXoHofi1o3MJQmIaxzYQk+8dgUgd
Also, Say I need to change the velocity switching for 3 samplers in a synth group at once...do I duplicate the code from the Midi script in each sampler or can I do it in the midi script for the group ?
-
It looks fine, but I have some suggestions. I'm just putting a snippet together.