A FREE Script to Create Your GUI Automatically

Ever Struggled with Kontakt Scripting?

You are not alone!

One of the scariest parts of breaking into the Kontakt Sampling world is when you find out that the pretty GUI’s you’ve seen are created almost entirely by code. Learning a scripting language is hard, it’s almost like learning another language to speak and it feels stilted and unnatural at first. Slowly, as you try new things and start to get comfortable with scripting the basics, you build up your confidence and try more advanced controls and methods.

If you are looking to build your first Kontakt instrument and script your own interface, you can check out my whole YouTube video course to walk you through the whole process, from planning and recording the sample to building and scripting the instrument.

That said, I’d personally hate it if you were scared off from Kontakt simply because the scripting challenges seemed insurmountable. I know from personal experience, learning how to use Kontakt to build your library is time consuming enough at the beginning without having to then learn a scripting language on top of that. It can be hard to find resources (though you have stumbled across Cmd Shift New to help with that!) and it takes a while to wrap your head around how to structure the code to make it work the way you want it. That can seem like too much to begin with.

So, what if I told you that you could build your library and not even worry about the script?

This is why I’ve created the Kontakt Sample Script Template, a script that you can copy and past into your own instrument to give you a default GUI without you having to code a thing! You can download it below and throw it into your library now. Check out the details below to see how it works and what you can tweak yourself. There is also a “READ ME” section at the top of the Script if you need quick reference to what you can change or how to build your library.

 

Build a “Default Library” Build to Work Perfectly With The Script

When creating the script, I looked across many people’s first libraries on the Pianobook website to see what kind of controls people are likely to need. In doing that, I got to work designing a script that had all the basic controls ready to go; Up to 8 groups, volume controls for those groups, Attack and Release controls, a Low Pass Filter, a Replika Delay and a Convolution Reverb. If you are designing your library and you are happy with these controls, create a library that follows the same below structure to ensure the script works perfectly as soon as you load it in.

Groups

Most of the time, your first library will be a combination of a few different layers that you can blend together. So, to make this work, I have scripted up to 8 volume controls for up to 8 groups in the instrument that you can then blend together. You don’t have to use all 8 groups, the volume controls will only show for the number of groups you have used, but any group added will automatically have a control added for it.

This script isn’t set up for round robins, so avoid creating any round robin groups, and the limit is 8 groups. You can add additional groups, though they won’t have volume controls and will need to be set manually in the back end by you or the user.

Attack and Release

These two controls have been added to adjust the attack and release of all the groups at once. In order to make this work, you will need to add an AHDSR Envelope to every group. The fastest way to do this is to create all your groups first, then use the Edit All Groups button to add it once to all groups. You can find this under the Mod tab in the Amp section of the source module.

 

Attack and Release Controls: Add an AHDSR Envelope to all groups.

 

Low Pass Filter

To use a Low Pass Filter, you need to add this to the first slot of the Insert Effects section. Any filter can be used, but a Low Pass Filter with a resonance control is advised to avoid having to change the script at all.

 

Filter: Add a low pass filter to the first insert effects slot.

 

Delay and Reverb

The script is expecting any type of Reverb, but a specific type of delay. You will need to use a Replika Delay if you want to avoid changing the script. These two effects should be placed on the send effects slots, with the Delay in slot 1 and the Reverb in slot 2.

 

Delay and Reverb: Add a Replika Delay to Slot 1 of the Send Effects slots and any Reverb of your choice to Slot 2.

 
 

How to Add the Script to Your Kontakt Instrument

It is quick and easy to move the script over to your Kontakt Instrument. Simply copy the script, in its entirety, and past it into the Script Slot of the Kontakt Script Editor.

  1. Go to your instrument and click on the Script Editor (open the spanner if you haven’t already to find the Script Editor).

  2. Across the top you will see 5 “Script Slots”. Click on the 5th (last) one and then click Edit on the left. This will open up a large white text field. This will be where the script goes.

  3. Go to the Kontakt Sample Script Template.txt file and highlight the whole text (you can remove the Read Me section, but it is advised to keep it in case you need to make adjustments later). Copy the text.

  4. Go back to your Kontakt instrument’s Script Editor and paste the script text into the white text field.

  5. Hit Apply. You will see the script update the grey space above the script editor and when you click the Spanner again, you will see the full GUI.

  6. Note: If you get any errors, double check the way you have built your library and that you have copied all text across.

 
 
 

Adding Your Own Background, Adjusting the UI Size and Moving the Controls

You can place your own background image in the UI space and adjust the size of the UI as well as the position of all the controls. All of this can be done without changing any of the code, simply through changing a few variables/constants at the top of the script.

Creating the Background

You can create an image with standard editing software like Adobe’s Photoshop and Illustrator or Affinity’s Designer or Photo. If you want to create an image that fits perfectly in the default UI size, you will need to create an image that is 418px heigh by 900px wide. Just remember, the control panel at the top of the interface is 68px heigh, so don’t put anything you want to see on your UI in the top 68px area.

 

Default Dimensions

 

If you want to adjust the height or width of the UI, you can! This way you can include more background if you need to. Kontakt 6 can accept background of up to 750px high and 1000px wide. The height is in addition to the 68px height of the control bar, so when you create your image, change this to 818px to include a background to the control bar and a background to your 750px height UI.

By default, the UI is set to 350px by 900px. You can change this by going down to the Declared Constants & Variables section at the top of the script and change the values attached to the constants’ UI Height and UI Width. Just remember, the height value doesn’t include the 68px for the header. So, if your image is 818, you will type in 750.

	{********************************
	Declared Constants & Variables
	********************************}

	{General UI Constants}
	declare const $UI_HEIGHT := 350          {<---- Change this to adjust the height of your UI.}
	declare const $UI_WIDTH := 900          {<---- Change this to adjust the width of your UI.}

Adding the Background

You can easily add the background, not in the script, but through the Instrument Options. In Instrument options, go to the Instrument tab and load a file into the Instrument Wallpaper section. This file needs to be a PNG file type, so make sure you export your wallpaper background as a PNG file.

 

Add an Instrument Wallpaper/UI Background

 

Adjusting the Control Location

You can move the controls section up and down, or left and right, to suite your background the best. You can do this in pixels, by changing the X Offset and Y Offset constants in the Declared Constants & Variables section at the top of the script.

  1. To move the controls down, add a positive value to the Y Offset.

  2. To move the controls up, add a negative value to the Y Offset.

  3. To move the controls right, add a positive value to the X Offset.

  4. To move the controls left, add a negative value to the X Offset.

	declare const $Y_OFFSET := 0          {<---- Change this to offset height of the controls. Positive for down, negative for up.}
	declare const $X_OFFSET := 0          {<---- Change this to offset width of the controls. Positive for right, negative for left.}

Changing the GUI Background Colour

If you don’t want an image as a background, you can change the colour of the GUI.

  1. Go to the Declared Constants & Variables section and find the UI Colour Hex constant.

  2. Find the Hex Code of the colour you want, this should be a 6 character code.

  3. Set the value for the UI Colour Hex constant to 9<hex-code>h. The 9 must be at the start to tell Kontakt to expect a number and the h at the end to tell Kontakt to interpret it as a Hex Code. For example, change to 9FFFFFFh for White or 9000000h for Black.

	declare const $UI_COLOUR_HEX := 9767676h     
 

How to Change the Script to Your Preference

The script has a number of quick ways you can adjust the script to your preference. For example, you may have a filter without a resonance knob, have a High Pass filter instead of a Low Pass, want to use the Legacy Delay instead of the Replika delay and put it on an Insert Slot, not a send slot. The possibilities are up to you. The script can adapt quickly to some of these basic changes with only a few minor tweaks at the top of the script.

Showing and Hiding Controls

Group volume controls are automatically hidden and shown based on how many groups you have from 1 to 8. However, the effects controls can be hidden if you need them to be as well. For example, you may want to hide the delay controls as you don’t have a delay, or hide the Resonance knob because your filter doesn’t have one. You can do this with any of the “Present” Constants at the top of the script. Change any of the following constants to “0” if you want to hide the controls.

	{********************************
	Declared Constants & Variables
	********************************}

	declare const $FILTER_PRESENT := 1 {Hide Filter Controls}
	declare const $RES_PRESENT := 1 {Hide Resonance Knob}
	declare const $DELAY_PRESENT := 1 {Hide Delay Controls}
	declare const $REVERB_PRESENT := 1 {Hide Reverb Controls}

Change FX Locations

If you change the location of an effect in the effect slots, you can update the “Local” and “Insert” Constants to reflect this change. For the filter, you can change the Filter Local to a number from 1-8 to represent whichever slot you placed the filter on (doesn’t matter what filter type it is). For the Delay and Reverb, you can change the Local constant to a number from 1-8 to represent the slot, but also change the Insert constant to reflect whether it is on the Insert or Send Effects slots. Set to 1 for Insert Effects and 0 for Send Effects.

	{********************************
	Declared Constants & Variables
	********************************}

	declare const $FILTER_LOCAL := 1 {Filter Location 1-8}
	declare const $DELAY_LOCAL := 1 {Delay Location 1-8}
	declare const $DELAY_INSERT := 0 {Delay Insert (1) or Send (0)} 
	declare const $REVERB_LOCAL := 1 {Reverb Location 1-8}
	declare const $REVERB_INSERT := 0 {Reverb Insert (1) or Send (0)} 

While the Filter and the Reverb doesn’t care what type you add to the slot, the Delay does need to be specified also. There are only two choices, Replika Delay (default for this script) and Legacy Delay. They both have the same controls that are on the UI, its just which delay is being used that is the question.

	{********************************
	Declared Constants & Variables
	********************************}

	declare const $DELAY_TYPE := 1          {<---- Set the Delay type. Replika Delay = 1, Legacy Delay = 2.}

Change the Label Names

Sometimes, you will need to change the label names on the UI. For example, if you have used a High Pass Filter instead of a Low Pass, you want the label to be updated accordingly. You can do this with a number of string variables that have been set at the top of the script.

	{********************************
	Declared Constants & Variables
	********************************}

	{Label Names}
	declare @GROUP_LABEL_NAME
	@GROUP_LABEL_NAME := "Layers Mixer"          {<---- Change this to the name of your layer/group volume control in quotations (eg. "Name").}
	declare @FILTER_LABEL_NAME
	@FILTER_LABEL_NAME := "Low Pass Filter"          {<---- Change this to the name of your Filter Type (eg. Low Pass or High Pass) in quotations (eg. "Name").}
	declare @DELAY_LABEL_NAME
	@DELAY_LABEL_NAME := "Replika Delay"          {<---- Change this to the name of your Delay Type (eg. Replika Delay) in quotations (eg. "Name").}
	declare @REVERB_LABEL_NAME
	@REVERB_LABEL_NAME := "Conv Reverb"          {<---- Change this to the name of your Reverb Type (eg. Replika Delay) in quotations (eg. "Name").}

You may also want to update the names of each of your groups from the standard Layer 1, Layer 2, etc.

	{********************************
	Declared Constants & Variables
	********************************}

	{Group Names}
	declare @GROUP_1_NAME
	@GROUP_1_NAME := "Layer 1"          {<---- Change this to your Layer/Group 1 name in quotations (eg. "Name").}
	declare @GROUP_2_NAME
	@GROUP_2_NAME := "Layer 2"          {<---- Change this to your Layer/Group 2 name in quotations (eg. "Name").}
	declare @GROUP_3_NAME
	@GROUP_3_NAME := "Layer 3"          {<---- Change this to your Layer/Group 3 name in quotations (eg. "Name").}
	declare @GROUP_4_NAME
	@GROUP_4_NAME := "Layer 4"          {<---- Change this to your Layer/Group 4 name in quotations (eg. "Name").}
	declare @GROUP_5_NAME
	@GROUP_5_NAME := "Layer 5"          {<---- Change this to your Layer/Group 5 name in quotations (eg. "Name").}
	declare @GROUP_6_NAME
	@GROUP_6_NAME := "Layer 6"          {<---- Change this to your Layer/Group 6 name in quotations (eg. "Name").}
	declare @GROUP_7_NAME
	@GROUP_7_NAME := "Layer 7"          {<---- Change this to your Layer/Group 7 name in quotations (eg. "Name").}
	declare @GROUP_8_NAME
	@GROUP_8_NAME := "Layer 8"          {<---- Change this to your Layer/Group 8 name in quotations (eg. "Name").}
 

An Example Interface

Below is a picture of the sample instrument I created in the video at the top of this article, to demo the script’s use. With some minor adjustments made to the script constants and variables, I was able to quickly get a working interface. This could be a great way to overcome your fears of scripting for your first library or even be used for quick tests of sampled sounds you have just captured.

 

A demo instrument made with the Template Script.

 
Previous
Previous

Adding a Knob to Your UI

Next
Next

Variables, Constants, and Arrays