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:

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.

References