MIDI keyboard range script?
-
Do you mean allow the user to limit the range of playable keys? Or do you want to change the colour of the keys on the on-screen keyboard?
-
@d-healey to set/limit the range of playable keys.
thanx.
-
@musictop You just need an if statement in on note on.
if (Message.getNoteNumber() < lower_range || Message.getNoteNumber() > upper_range) Message.ignoreEvent(true);
You can set the lower/upper values from whatever controls you want on the ui.
-
@d-healey thank you so much David.
-
Hi guys,
I would like to make UI with 2 flexible split points (for tenor / soprano / piccolo instruments) and on first sight your bit of code is exactly what I was looking for.
It works great when I replacelower_range
andupper_range
with numbers, but when assigning a slider to set the ranges from the UI they become just on/off switches (range 0-1 switches at 0.5 ; 0-127 at 1).Obviously I would like to set a value between 0 and 127 with a slider in the UI. Any Idea how to make that happen?
thanks!!
-
@meyerkeys Hi
You can set the slider ranges in the property editor of your sliders (0-127) (don't forget to set thestepSize
to 1)Then first solution:
- Create the slider's Script Reference in the onInit callback.
- Then in the
noteOn
callback, you can replace thelower_range
variable withmyLowRangeSlider.getValue()
Second solution:
- Keep the
const var lower_range
variable - Create a callback for your slider in the
onInit
- In the callback, place
lower_range = value;
-
@ustk said in MIDI keyboard range script?:
@meyerkeys Hi
You can set the slider ranges in the property editor of your sliders (0-127) (don't forget to set thestepSize
to 1)Then first solution:
- Create the slider's Script Reference in the onInit callback.
- Then in the
noteOn
callback, you can replace thelower_range
variable withmyLowRangeSlider.getValue()
Second solution:
- Keep the
const var lower_range
variable - Create a callback for your slider in the
onInit
- In the callback, place
lower_range = value;
'cept it couldnt be
const var lower_range
it would need to be
var lower_range
-
@Lindon Oups sorry, you're right
const
shouldn't be here... -
Many thanks guys!
I wondered about "const" as well but I got it working with both versions.
Cheers!
-
@meyerkeys yes the first solution @ustk offered may well work but the second wont as:
lower_range = value;
means you are assigning a value to a constant - and that wont work. constants get set and can never be changed - theyre, huh, constant...:-)
-
If the constant is an object you can change the object's contents.
const var foo = [1, 2, 3]; foo[1] = 10; Console.print(foo[1]);
-
Thank you guys for staying on this.
I kind of wondered about the const or const var thing anyway as David is using const var mostly in his great videos. Can't thank you enough for those btw.
So your last post clarifies again. Got it. -
@meyerkeys You can find more information in the doc about the different variables in Hise
https://docs.hise.audio/scripting/scripting-in-hise/additions-in-hise.html#const-variables