Keyboard to display only active keys?
-
@d-healey This is what my friend came back with, he has extensive experience with coding languages but obviously not with hise.
I'm not as well versed as you are with this program, i'm still trying to learn and figure this stuff out as i go. -
i'm still trying to learn and figure this stuff out as i go.
Yeah that's we're here for.
I suggest you first learn to colour the keyboard with a fixed range.
All you need is a for loop and the setKeyColour function. All the info has already been posted in this thread but if you need any details just ask.
Also, here is a script I wrote a few years ago for colouring a keyboard range. You might find it useful to study - https://github.com/davidhealey/HiseUtilityScripts/blob/master/modules/KeyRangeColour.js
-
@d-healey Thanks for replying, wow that's a lot of code, i've brough it in to a blank project to try understand your script and go through it with my friend, and i'm getting this error;
Master Chain:! Line 55, column 6: Can't declare var statement in inline function {SW50ZXJmYWNlfG9uSW5pdCgpfDE1ODB8NTV8Ng==}
Is this a problem on my end?
-
@DailyLlama said in Keyboard to display only active keys?:
@d-healey Thanks for replying, wow that's a lot of code, i've brough it in to a blank project to try understand your script and go through it with my friend, and i'm getting this error;
Yeah I wouldn't recommend trying to use it as is. It's old and will need a few fixes to run in the latest version of HISE.
Probably the most relevant part to you is the
updateKeyboardColours
function. But again, don't copy/paste it and expect it to work as is. It's just for guidance. -
@d-healey Hi!
Thanks for all your help so far, here's how i think i understand this.
{ for (i = 0; i < 128; i++) { if (i >=40 && i <=95) Engine.setKeyColour(i, Colours.withAlpha(Colours.white, 0.0)); else Engine.setKeyColour(i, Colours.withAlpha(Colours.black, 0.4)); } }
The for loop iterates through the set 128 note numbers.
For each note it's checking if it falls between the range i set of 40 - 95 it then calls the engine.setKeyColour() function, and makes them white, or in this case, transparent as i've set the value to 0.0, so, normal key colour.
If the note doesn't fall within my set range, it's coloured transparent black?
I've tried this in my project and it works!
I need to figure out how to get this to work with the different samplemaps within my combo box still.
-
@DailyLlama Yep that's the way to do it.
You could use a 2D array for your ranges. Have one array per sample map and each sub array contains the note ranges. Then you just use the value of your combobox to get the index of the correct range array.
And you trigger the colour keys function from the comboboxes control callback. Not quite as elegant as querying the sample mapping in the loading callback but probably a bit easier to implement.
For example:
const myRanges = [[40, 95],[60, 80], [10, 24]];
-
@d-healey I would rather use a JSON object with the samplemap id as key instead of a 2D array, makes it more readable.
-
@Christoph-Hart @d-healey This is what we went with in the end! thanks for all your help guys i really appreciate it :)
-
@Christoph-Hart looks like it might be time to give weston the boot
-
@HISEnberg haha there is the link I knew it.
Alright time to go buddy… but let‘s all remember him for establishing a baseline for the least valuable contributions that almost slipped through.