Change keyboard note colours in a Preset within an Expansion
-
Hi guys, I'm using LAF for my keyboard. I have a new expansion in which I'd like to use two different sets of colours in a few of the presets. The keyboard colours will be identical for each preset. My current thinking is to create second keyboard with these colours, and use a hidden button to switch which keyboard is displayed, depending on the preset.
Currently I'm unsure how to grab 4 notes at a time and set their colours independently of the rest of the keyboard. Help hugely appreciated!!
HiseSnippet 1535.3ocsW01aZbDD9NrunBMsMQpeppeXKe5nAiuChM1IJMFafTqXGaYbRZkkUzxcKvVerK5tEaih7+49Ovc1cO3Nv32nJfjk24kcelcm4gYNLj6Qhh3gFlYOdz.hg4SsZMhI5sSOLkYracCyezZebjfDhzh1dz.bTDw2vzbo2IEXlcYC0m+8saiCvLORhHCiOwodj8n8ohDoGt06oAAMw9jio8SY8K2ZWONaGd.eHfmkrbLFf8NC2k7ArzrLVFlOogOUvCaIvBRjg4xay8G0pG+Bl19OQinsCHxEtFsfMRKtIOvWhXoTic5QC7ObbbGY.6xgI2BKouE9Yq8o9zIxStMdlRAJwiz2GlYlFdKME7buM3MGHYlBRKqgzysZ4ERGHRzHwy2asKCdb5fgq8zPQaqQlmk0ZGNXASTpO9LRyPXwDOrW2woHB9SgWmKGb0GIPmiCQA3Nn2fZv5RYjRdgDHXdW.uMNPuo6w4mUi42jPBrAGWcUz6a72aePsipmKG3ZoPRWpLgo4PlmfxY148CwW74dTA4CbAIeQTmwZ5VDwa+OEx80bYkGLFN1S.AkvvgdhyoJs5EtoWTN8hJmhVA4d5qykMWVZGjsTgObkWHW1rJsu3MHWH9x1sTDQnytrctrYyFUjegH.zzARHOhOjAoIGQ7DXV2.hMtHRoN6M2Y.v586cgXeJb61D1.6SbtTdgpgtFy5yKpzETQuZAC5gsGKoc.jbWD4TZsBItT4zSUm38fnqRGrmQFo2Szu8FjSZvEGrSYzid66wOmD9+Kjk21NNU2bipEQtyIZWc0zv8V72s5ZUWS5uxkwuEn2htqfA8Jz8Eqvq6z4FS8.U30nUWE.PmNkUezoKxD54tiPpncEzuilj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T7qfeVNkbL5CI7ewySF9q.zfy2mxKfOUV.ed4B3yZKfOqu.9TcA7Yi6zGIWSsg.Gmtb.DbXCEqpoYCFFxrTYgF+GjPaU3L
-
@DanH said in Change keyboard note colours in a Preset within an Expansion:
My current thinking is to create second keyboard with these colours, and use a hidden button to switch which keyboard is displayed, depending on the preset.
Keyboard colours apply to all keyboards, so that's not the way to go.
Make an array containing two sub-arrays that have the key colours you want (we can discuss the details of this if you have a complex colour scheme). Add a hidden knob to your UI that is saved in preset and will be used as the index to the sub-array.
Then in the knob's callback you loop through all the keys and colour them based on the values in the array.
Use local laf for this not global.
-
@d-healey Thanks, I'm gonna need help with this one! How do I make a sub array within an array?!
-
const myArray = [[], []]; // An array with two sub-arrays (also called a 2D array)
-
@d-healey thanks, I only need two key colours really. Do I need an array at all?
-
-
@d-healey Undecided but lets say red and blue.... alternating every 4 keys... 4 keys red, next 4 blue, next 4 red, etc etc
-
@DanH And for the other one?
-
@d-healey the other keyboard is the normal black and white...
-
@DanH In that case you don't need an array
HiseSnippet 1315.3ocsV0saaaCElJIpXRcqaEXWsqXCvvrQcckRyRRa1PSiiSmQaZLhS61MCELRzVDglTPhJIFE4l8jsWlc+dCxNjT1RNMKq0.yWXnyeemOdHOGx9YxHZdtLC43c7jTJx4KcGLQnR5jPXBTu8PN2y8.Rthlgsp1cRJIOmFibbV9kZENdqfL+96muKgSDQzJUHz6jrH5qYiYpJs824ULNeeRL8X13Zdu9N8hjhNRtr.3yxtAnTRzojQz2PztsjKx4NciYJY1.EQQyAe1UFOYPh7bg0+2wxYmvoZgPz..HqZTmDFOt+z0ZNB4rR+pU9x1U925d.KlMSeUE3aLFvUQTuF3rzsQovOCJ4TiRqXoz8cGDkwRUUVz74tt8DvFxPBTpqSEqunk9qkc6HAODp1iImR2OCDlEQiMBBZgg+ZtsuOSvYBJdXgHRwjBrTragRIEg53yj7FQxwoRAfTK7YDdAso+G78hL6PuhN4DIIKtg0v19WB.NMuinpNSCswpkftZy14Z8Fn6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AFPEwFAcyYowPsrSowvoFQiIQYx2GYmPpee2WXz.bRXdNqG7tZPFOavnqaP6.zXnC38QQ5k+ifwu2bLqs.w7jEHl0WfX9wEHlMVfX1bAhYqaMF8vmWT.C8rsCfh9cMiYcb5JHvIKyoPz+.h4yrg.
-
@d-healey that's clever! I am using LAF for the normal keyboard, however (sorry when I said normal I meant normal colours, not the stock HISE one).
-
Your laf should read the key colour values set with Engine.setKeyColour.
-
@d-healey why is that better than what I have already?
-
@DanH You're hardcoding it in the LAF function which means any time you want to change the keyboard colour you have to edit your LAF. If you read directly from the key colour properties you can change the colour at any point in your script.
-
@d-healey Can you show me how I get it into my script pls?
-
@DanH Something like this
HiseSnippet 2036.3ocsXstaiabElx6xfRkKMAn+p+ZVADDptZ0RJYuxabShkkkRMV60F1NaZggQvXxQRSM0LBjirsPfAxCV+aeO5iPeC1dNyPJRIKeYc5JCXv4Ly4LemaejybPrLfkjHisJ4b7zwLqRel8QSEpgcFR4Bqc11pzWXuGMQwhIFQaMcLMIgEZUpzS9QTPImmZo+8e+gsnQTQ.KWjk06j7.1t7QbUtzC17M7nndzP1w7QEV8patSfTzQFIm.34I1dVioAmSGvdKEW1J1Vk9jtgbkL9HEUwRrJ8zsjgSOZn7RgY8uimvOKhgC7sNBLjQbOYTHhXTpUmg7nvCx76DKvJGjGEdhIJ7mr2iGxmIOOZ7k5IH4ZTLdTZk4g2SlCd9EgmWA3sDHUp.jdpARek8QAw7wp7YP77o16HfjSeJD1KBEyZsV4e+41cjvJDp5inmy5ECClog6q77pQf+Ucixk4hHtfQ5OQDn3RAQJ1ZhRIE9n9wxH2.4nwRAXoZjKnQSXUK+qkcBzYq2vldljFG5ZlXixWCFLaeGvTcxT0sRpQqTsdBJWa5NznnyfTs6h6IhqW9RnxiEbNg2mHjJFQLYzYP4HOgbVDnD4b1za.ddxV3b.tbEZbFyTShED2S7qQZB9bMx50H9dmVmKBYWsee2wz3DFDYf0S9Zheipjm8cjW3i9xMiMK30ijglnAf0CYf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yCos80a2tKj7q6U8FNwR7h6wMfD9GIhK+Thqag459oXZ2bluVsHqzho5708Axy2ZIAvG.gJTTh0Oe3rp2jhzjktSNwFy3+muG3l7e2OUF1aW3rOX269BWc6J7sNjEmpe+kNW54VhXwKcZ77tw2khtlC2T7DV3BgCAN+IKsu8SVV7fuAlOhpvBkhcDb09iYha63vVoe4EdJzTTAKUoOC5WjdFTyozr3vQMcrSOxlkFxEO6u0Osy1TEMyPfMg8YLKVwQWnz1rK3ALygacr2lkbtRNFNl+rO2C75Gv1dEDMJ8ufcaJ9PeKsGLyBelJ877FKT7yE014OZO2WPhVKyA99MmlOPs4k7P0vYB9O+1lCY7ACyuVie6jMS8RiKU1N67gVmMH6RMb9jvvv2iKG9FyQ4Re+6e+eddoMREqWrBdyU9hyBu5f6JmVx9WKSHUfc6mQHV4aI9qV2qFJaadx3H5z8gdlKRe2KLceJb5P876JuDTCD8Z8v+F2LxuQK83NSRTxQPG+3g7fj4zbaVe5jHU6wiYzX7RefYUwSLSlcb1Cg.qDlvq9qds925qCT.ds70q5X4.nOdO3rhyYY76F5LjJDrHDJZY+TB6cPiuLt.Vlsavj8hnpiTSiVvRGzMKErnbnOJVkuKMxj2UDVXueU4qsrt4Mw7k1.nguyPM+ECg2FV5DPO8b2FCdiKhDtZZwaK6+a2VzCEhek8AbUvvkiwUVBFgN2OFXL8N19b6t86CY0b.9T6d+8ONWnlE75CrIeOpJliLFPyvQP6T.KMcibpkVA4NLi8vwXD3HlHTO.6ESmzGGWJcR+rIsFQChk+RfgyDuEu+fVBfIg9BLcr2CGSlQUZa6U2yZDTv+KAAn6+BfPd45z3QnSyGgNq9HzYsGgNu5QnSqGgNqem5fbMsm.bbl1APvAc0rpkJ0UPgJKcUn0+C.O.zZL
Your script needs a bit of cleanup. For resetting the key colour I needed to add a function to check if the note number refers to a black or white key, apart from that it's pretty much the same as I had in my snippet.
-
@d-healey Amazing, that's working, thank you! It seemed counterintuitive to me to define the keyboard colour in the main script, as well as having an LAF for it as well...
-
@DanH It's the same idea as setting the component properties in the property editor and using those within LAF.