Sampler.setSoundPropertyForSelection(); seems to have a bug.
-
Sampler.setSoundPropertyForSelection(); seems to have a bug.
When I changed the values of Root, LoKey, and HiKey in the sample from larger to smaller values, the HiKey value with the code 4 did not take effect.

-
@CatABC Use constants instead of magic numbers
-
@d-healey There are some rare cases that .setAttribute gives an error if I use param ID instead of a number. Gives an error on only certain things error: "expected int" I think the error is. I'll specifically note them next time and tell you.
-
@Chazrox said in Sampler.setSoundPropertyForSelection(); seems to have a bug.:
@d-healey There are some rare cases that .setAttribute gives an error if I use param ID instead of a number. Gives an error on only certain things error: "expected int" I think the error is. I'll specifically note them next time and tell you.
That means the constant is invalid
-
@CatABC if you change both the low and the highkey downwards you need to change the lo key first and then the hi key, cause it’s not possible to set the hi key below the lowkey
-
@d-healey said in Sampler.setSoundPropertyForSelection(); seems to have a bug.:
@CatABC Use constants instead of magic numbers
Sadly, I tried using constants, but the problem persists. Also, if I swap the positions of HIGH_KEY and LOW_KEY, and need to move the smaller value to the larger value, the contradiction still occurs.
const var ComboBox1 = Content.getComponent("ComboBox1"); const var ROOT = 2; const var LOW_KEY = 3; const var HIGH_KEY = 4; const var C1 = 36; const var D1 = 38; const var E1 = 40; const var B3 = 71; inline function onComboBox1Control(component, value) { Sampler.selectSounds("C3"); if (value == 1) { Sampler.setSoundPropertyForSelection(ROOT, C1); Sampler.setSoundPropertyForSelection(HIGH_KEY, C1); Sampler.setSoundPropertyForSelection(LOW_KEY, C1); } if (value == 2) { Sampler.setSoundPropertyForSelection(ROOT, D1); Sampler.setSoundPropertyForSelection(HIGH_KEY,D1); Sampler.setSoundPropertyForSelection(LOW_KEY, D1); } if (value == 3) { Sampler.setSoundPropertyForSelection(ROOT, E1); Sampler.setSoundPropertyForSelection(HIGH_KEY,E1); Sampler.setSoundPropertyForSelection(LOW_KEY, E1); } if (value == 4) { Sampler.setSoundPropertyForSelection(ROOT, B3); Sampler.setSoundPropertyForSelection(LOW_KEY, B3); Sampler.setSoundPropertyForSelection(HIGH_KEY, B3); } }; Content.getComponent("ComboBox1").setControlCallback(onComboBox1Control); -
@CatABC said in Sampler.setSoundPropertyForSelection(); seems to have a bug.:
@d-healey said in Sampler.setSoundPropertyForSelection(); seems to have a bug.:
@CatABC Use constants instead of magic numbers
Sadly, I tried using constants, but the problem persists. Also, if I swap the positions of HIGH_KEY and LOW_KEY, and need to move the smaller value to the larger value, the contradiction still occurs.
const var ComboBox1 = Content.getComponent("ComboBox1"); const var ROOT = 2; const var LOW_KEY = 3; const var HIGH_KEY = 4; const var C1 = 36; const var D1 = 38; const var E1 = 40; const var B3 = 71; inline function onComboBox1Control(component, value) { Sampler.selectSounds("C3"); if (value == 1) { Sampler.setSoundPropertyForSelection(ROOT, C1); Sampler.setSoundPropertyForSelection(HIGH_KEY, C1); Sampler.setSoundPropertyForSelection(LOW_KEY, C1); } if (value == 2) { Sampler.setSoundPropertyForSelection(ROOT, D1); Sampler.setSoundPropertyForSelection(HIGH_KEY,D1); Sampler.setSoundPropertyForSelection(LOW_KEY, D1); } if (value == 3) { Sampler.setSoundPropertyForSelection(ROOT, E1); Sampler.setSoundPropertyForSelection(HIGH_KEY,E1); Sampler.setSoundPropertyForSelection(LOW_KEY, E1); } if (value == 4) { Sampler.setSoundPropertyForSelection(ROOT, B3); Sampler.setSoundPropertyForSelection(LOW_KEY, B3); Sampler.setSoundPropertyForSelection(HIGH_KEY, B3); } }; Content.getComponent("ComboBox1").setControlCallback(onComboBox1Control);Ultimately, I set up two methods to call different methods depending on whether the value in the combobox increases or decreases.

-
@Felix-W
I made some notes how you could solve this
There are some things that you have forgotten- Reference to the Sampler module
- Set the combobox callback
- Reference to the the sampler properties, Root, HiKey and LoKey is set like this:
Sampler.Root Sampler.HiKey Sampler.LoKeyit may seems a bit strange at first when the reference to the sampler is Sampler1, anyway that is the way it works.
- The ComboBox value start at 1, not zero
Here's the snippet with comments
HiseSnippet 1676.3oc4X80aSbDDeujbn3qPUAwC7PeXUDO3TEB1wg3TQQ3DaGHkDhkcHsHTEZycqsWk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1 = Content.getComponent("ComboBox1"); // reference to the sampler const Sampler1 = Synth.getSampler("Sampler1"); // Your keys const Keys = [36, 38, 40, 71]; // At init get a "current key" to compare with later reg currentKey = Keys[ComboBox1.getValue()-1]; inline function onComboBox1Control(component, value) { // you need to have a reference to the Sampler == Sampler1 Sampler1.selectSounds("C3"); // The combo box values starts at 1, not zero local key = Keys[value-1]; // Set the root Sampler1.setSoundPropertyForSelection(Sampler.Root, Keys[value-1]); // Check if moved up or down if (key - currentKey < 0) // moving down { Sampler1.setSoundPropertyForSelection(Sampler.LoKey, Keys[value-1]); Sampler1.setSoundPropertyForSelection(Sampler.HiKey, Keys[value-1]); } else // moving up { Sampler1.setSoundPropertyForSelection(Sampler.HiKey, Keys[value-1]); Sampler1.setSoundPropertyForSelection(Sampler.LoKey, Keys[value-1]); } // update currentKey currentKey = key; }; Content.getComponent("ComboBox1").setControlCallback(onComboBox1Control);
-
@Felix-W said in Sampler.setSoundPropertyForSelection(); seems to have a bug.:
@CatABC said in Sampler.setSoundPropertyForSelection(); seems to have a bug.:
@d-healey said in Sampler.setSoundPropertyForSelection(); seems to have a bug.:
@CatABC Use constants instead of magic numbers
Sadly, I tried using constants, but the problem persists. Also, if I swap the positions of HIGH_KEY and LOW_KEY, and need to move the smaller value to the larger value, the contradiction still occurs.
const var ComboBox1 = Content.getComponent("ComboBox1"); const var ROOT = 2; const var LOW_KEY = 3; const var HIGH_KEY = 4; const var C1 = 36; const var D1 = 38; const var E1 = 40; const var B3 = 71; inline function onComboBox1Control(component, value) { Sampler.selectSounds("C3"); if (value == 1) { Sampler.setSoundPropertyForSelection(ROOT, C1); Sampler.setSoundPropertyForSelection(HIGH_KEY, C1); Sampler.setSoundPropertyForSelection(LOW_KEY, C1); } if (value == 2) { Sampler.setSoundPropertyForSelection(ROOT, D1); Sampler.setSoundPropertyForSelection(HIGH_KEY,D1); Sampler.setSoundPropertyForSelection(LOW_KEY, D1); } if (value == 3) { Sampler.setSoundPropertyForSelection(ROOT, E1); Sampler.setSoundPropertyForSelection(HIGH_KEY,E1); Sampler.setSoundPropertyForSelection(LOW_KEY, E1); } if (value == 4) { Sampler.setSoundPropertyForSelection(ROOT, B3); Sampler.setSoundPropertyForSelection(LOW_KEY, B3); Sampler.setSoundPropertyForSelection(HIGH_KEY, B3); } }; Content.getComponent("ComboBox1").setControlCallback(onComboBox1Control);Ultimately, I set up two methods to call different methods depending on whether the value in the combobox increases or decreases.

Wow, this method is so cool! Thank you for the code comments; they really enlightened me.