premium article

Last modifiedby & filed under Kontakt Scripting (KSP) - Basics, UIs, Tutorials, Scripts and Tools, Kontakt Scripting (KSP) :: Custom Scripts & Functions (Plugins).

In this tutorial we will learn how to dynamically change labels and display the knob’s current value for the time the knob gets moved. After releasing the knob the default label shows up again after a certain delay. See video

Also see these more conveniant solutions, using less code

Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

It is recommended to follow the User Interface with multiple Screens tutorial first.

Any Questions? Use the comments below

Requirements: no requirements, the script works without sublime 3 compiling

Unfortunately in Kontakt we can not receive any mouse event like “mouse over”, “on click”, “on release” etc which would have made this pretty easy. So instead of a mouse event, when a knob is tuned the “on ui_control” callback gets called which stubbornly “reels off” our code. On mouse release the “on ui_control” simply is not executed anymore so there’s no possibility to call any function or code on a mouse release. That’s why we have to make up a workaround using a watchdog or time monitoring and time delays.


  1. how it works (in simple words)

  2. setting ui space, wallpapers & global vars

  3. defining the labels for our Images

  4. setting variables for the watchdog timer (dynamic labels)

  5. defining all the other ui elements

  6. The actual watchdog timer function (Dynamic Knob Label’s)

  7. full code of all Knobs

Download all files to this tutorial premium

  • Open Resource Container: Buttons, Knobs, Wallpapers
  • NKI file: the working script
  • the script as txt file


Download this UI USING the NEWER CallBack ID method



MIT International License.
You may use this script, modify it, build upon it, as you like (also commercially), as long as you keep all credits within the code visible to others. You may put them into an extra open script tab or inside an about section of your instrument. But you may not hide them. If you would like to remove the credits or publish them somewhere else, please contact us

YOU MAY NOT commercialize, share, distribute, whatsoever the included image files and other media (© 2023 all rights reserved). 


 no requirements, the script works without sublime 3 compiling



1. This is how it works (in simple words)

Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

  1. a default label is displaying the knob’s units in words (like dB, Hz, Bits etc)
  2. while turning a knob, the label “swaps” and displays the knob’s live value now
  3. a certain wait period prevents the label to fall back to its original state when the knob is still turned
  4. when releasing the knob this prevention timer runs out and the default label gets restored

2. Setting ui space, wallpapers & global vars

This script is licensed under the MIT license

you must include the full license text & credits above the actual script: visible / accessible to anyone and closely together with the actual script code
(you may also put the license into another, unlocked script tab or into an about section of your instrument). If you want to put the license somewhere else or remove it please contact us

If you don’t know how to include the license, simply download the full script from above. The license is already placed in the right place

on init 
    {INIT UI}
        set_script_title("Dyanmic Labels")
    {DECLARE : Global Vars}
        declare $count
        declare const $TOTAL_KNOB_COUNT := 4 {set the total number of knobs in your UI}
        declare @wp_init
        declare @wp_about
        @wp_init := "bg_main"

First we define the ui area and make it visible outside the script tab (make_perfview). Also we set all global vars. You can read this chapter in detail in the User Interface with multiple Screens tutorial.

3. Defining the labels for our Images

{declare bottom knob label images & text vars}
            declare @display_val {holds the current knob value on mouse event}
            declare @lbl_blank 
            @lbl_blank := "lbl_blank" {set blank bg image when turning the knob}
            declare !arr_lbl_units[4] {declare array which holds allunit images}
            !arr_lbl_units[0] := "lbl_bits" 
            !arr_lbl_units[1] := "lbl_hz"
            !arr_lbl_units[2] := "lbl_db" 
            !arr_lbl_units[3] := "lbl_%"

labelnow we define the knob’s default labels which are holding the images showing the knob’s units. For this tutorial we only take a closer look at the LoFi FX, so  the knob’s units are: bits (bit crusher), Hz (sampling rate),  dB (noise level) and % (noise color). Of course you can use any units you like or even create icons.

We also need a blank image because when the the knob is turned we want to display the knob’s values suplied by the Kontakt engine.

Except the blank image we store all other label images (their filenames) into a string array !arr_lbl_units[] since it is easier to work with later on.

4. Setting variables for the watchdog timer (dynamic labels)


{SET : Watchdog Timer & dynamic labels}        
        {declare global vars}
            declare $wait_time := 2000 {ms}
            declare %arr_timestamp[$TOTAL_KNOB_COUNT] {array which holds the current engine uptime for each knob (in microseconds). Gets refreshed upon each mouse event}
            declare $wait_flag := 1
            $wait_time := $wait_time * 1000 {convert to milliseconds}

here we decalre and prepare alle the variables for our watchdog timer. When a knob is turned the current KSP clock time will be stored into a time stamp array (%arr_timestamp). Thereby each knob uses an individual time stamp.

With the $TOTAL_KNOB_COUNT constant above we can easily extend that array depending on how many knobs or dynamic labels we are using for our instrument.

The $wait_time and the $wait_flag  will be explained later

premium content

How useful was this article?

something you didn't like? Please tell us before you rate!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

NOTE: highly negative votes may be removed without any reasonable given feedback!

Tell us how we can improve this post?

2 Responses to “Kontakt Scripting (KSP) :: watchdog timer – change knob or slider labels on mouse events (on click, on release) [dynamic labels]”

    • YummyBeats

      Thx! No sorry, currently there's no raw material or templates (except the script) included. But the Kontakt resources are always open, so you can access and analyze any png files (like custom knobs, buttons etc) and maybe learn or utilize some techniques to build and design your own instruments. You know, these tutorials are rather about the scripting not about the graphic design, so the instrument design is always very rudimental and nothing you wanna copy :) But if you are missing some technical templates like for measuring and stuff, let me know.

Leave a Reply

use <pre> </pre> to wrap code blocks

use <code> </code> to wrap small code snippets

use basic html to style your comment

Your email address will not be published. Required fields are marked *