How do I get set_key_color to apply on instrument load?
The simplest script in Kontakt 6:
on init
set_key_color(1, $KEY_COLOR_RED)
end on
works great when applied, however when I load the instrument, the keys come up all white.
All the instruments I look at have the keyswitches colored on instrument load.
What's the secret I'm missing?
I copied all the code from another instrument's script that works just fine straight into mine.
Same result, nothing.
Some setting on the instrument I created?
I copied another instrument made by somebody else with instrument keys in blue and keyswitches in red over my new instrument.
OK. The new copied one worked fine.
Then I overwrote its scriptcode with my simple
on init
set_key_color(1, $KEY_COLOR_RED)
end on
It no longer showed any red keyswitches (mine or the originals)on instrument load.
Then I copied the imported script back to where it originally was, so this imported instrument was back to how I found it.
It showed NO red keyswitches.
HOWEVER, the now invisible original keyswitches worked JUST FINE!
??????????
Comments
-
First, double-check that you’re not using the key-lighting factory script. Also, the note you’re changing the color of is 1 (C#-2). Not sure if that’s what you intended. The general approach should be: a) put all the keyswitch MIDI note numbers into an array, b) loop through that array and colorize, c) wrap the loop in a function and call it whenever needed, plus include it in the persistence_changed callback.
on init declare $i
declare const $NUM_KEYSWITCHES := 4
declare %keyswitches_notes[$NUM_KEYSWITCHES] := (36, 38, 40, 41) end on function colorize
$i := 0
while ($i<$NUM_KEYSWITCHES)
set_key_color(%keyswitches_notes[$i],$KEY_COLOR_RED)
inc($i)
end while
end function on persistence_changed
call colorize
end on0 -
Thank you for your detailed response ( which I only just saw now because I expected the forum to inform me of any response).
This is an elegant and comprehensive method for doing what I want.
However it doesn't resolve my issue:
These colorizations do not show up on loading the instrument, despite the "on init" section. It works fine on applying the code directly.
As no else seems to have this HUGE issue, there's clearly something else going on other than the obvious, but I'm baffled as to what.
I've tried:
-restarting Kontakt
-having the DAW(Reaper) rescan the plugins
-restarting the DAW
-rebooting the OS!
I was particularly amazed by modifying a correctly working existing instrument's "on init" (got no color on instrument load) and then restoring the original code (STILL no color on instrument load).
Indentation? Invisible characters? Beats me!0 -
If you keep this function that colors the keyboard inside the
persistence_changed
callback, the keyboard will get recolored every time you restart Kontakt's engine. Just so you know, that was a pretty basic example of how you can colorize.0
Categories
- All Categories
- 19 Welcome
- 1.5K Hangout
- 62 NI News
- 785 Tech Talks
- 4.1K Native Access
- 16.5K Komplete
- 2K Komplete General
- 4.3K Komplete Kontrol
- 5.7K Kontakt
- 1.6K Reaktor
- 378 Battery 4
- 845 Guitar Rig & FX
- 429 Massive X & Synths
- 1.3K Other Software & Hardware
- 5.8K Maschine
- 7.3K Traktor
- 7.3K Traktor Software & Hardware
- Check out everything you can do
- Create an account
- See member benefits
- Answer questions
- Ask the community
- See product news
- Connect with creators