How to Add Custom Knobs to a Kontakt Instrument
Introduction
It’s relatively easy to make a custom Kontakt instrument by dragging in samples and mapping them to keys. It gets more complex when you want to create custom knobs and sliders because you have to edit KSP script code. Here is a basic example of the code needed to create knobs and link them to effects and other parameters.
Always keep the official KSP Reference Manual close as it has all the latest information.
Example KSP script
Here is a heavily commented example of a script that creates a knob linked to the cutoff. The knob position will also be stored as part of any snapshot taken for the instrument. This would go into the script editor in your Kontakt instrument. This script assumes you have some sort of filter on the first slot of Insert FX.
You can also download the script here and copy/paste it into your Kontakt.
{ Initialization when first loaded }
on init
{ Sets a message in Kontakt status bar }
message("Initializing my script")
{ Turn on performance view and set size }
make_perfview
set_ui_height(1)
{ Create the knob UI element with its ranges }
declare ui_knob $myCutoffKnob(0, 1000000, 1)
{ Position the knob X/Y (0-6/0-16) }
move_control($myCutoffKnob, 6, 1)
{ Get the current value of parameter and display it }
set_knob_label($myCutoffKnob, get_engine_par_disp($ENGINE_PAR_CUTOFF, -1, 0, 1))
{ Have the knob position stored as part of the instrument snapshot }
make_persistent($myCutoffKnob)
end on
{ Callback when knob is twisted }
on ui_control($myCutoffKnob)
{ ENGINE_PAR_CUTOFF is for a filter effect, so
the first INSERT effect needs to be a filter }
set_engine_par($ENGINE_PAR_CUTOFF, $myCutoffKnob, -1, 0, 1)
{ set_engine_par(<parameter>, <value>, <group>, <slot>, <generic>)
-1 = no specific group, apply to instrument
0 = 1st effect in the list (slot 0)
1 = insert effect (0 would be send effect) }
{ Update the UI label now that the value has changed }
set_knob_label($myCutoffKnob, get_engine_par_disp($ENGINE_PAR_CUTOFF, -1, 0, 1))
end on
Here is a short description and a link to the official documentation for every piece:
- make_perfview – Turns on performance view allowing you to add UI elements
- message() – Show text in the status bar of Kontakt
- set_ui_height() – Performance view height in grid units (1-8)
- move_control() – Position the UI element in the X/Y grid (0-6/0-16)
- declare – Creates a new variable. Also see variables.
- ui_knob – One of the many types of UI widgets available. Also see list of UI controls.
- set_knob_label() – Set the text next to the custom knob
- get_engine_par_disp() – Get the human readable string for an engine parameter
- make_persistent() – Sets the variable to be stored with instrument snapshot.
- on ui_control() – Callback when a UI element is interacted with
- ENG_PAR_CUTOFF – Also see list of Engine Parameters.
- set_engine_par() – Update a parameter in the Kontakt engine
Conclusion
From here, you can experiment with other UI widgets like sliders, x-y pads, file selectors, menus, and tables. Link the widgets to different engine parameters to create the desired interface for your instrument.