Skip to main content

The Script Editor

Abstract

This section describes loading and using scrips with Kontakt's Script Editor. A full KSP reference is available as a separate document.

Kontakt includes a powerful and flexible scripting language processor, which is designed to let third-party developers come up with custom and complex ways in which users can interact with their Instruments and Multis. Although Kontakt’s scripting language is easy enough to learn for anyone who has used a programming language before, a thorough reference would still go beyond the scope of this manual, so we’ve made it available as a separate PDF document that you’ll find in the Documentation folder of your Kontakt installation. In this section, we’ll keep to the basics of loading and using Scripts within the Script Editor.

There are some basic aspects of Scripts that you should be aware of, even if you’ll only use pre-made Scripts. Scripts in Kontakt work like small programs that hook into Kontakt’s way of processing notes, controller data, and user actions, enabling them to change Instrument parameters and MIDI data in a programmatic way. A very simple example would be a Script that alters incoming MIDI notes by transposing them up an octave, or creating a second voice that follows in octaves; more complex Scripts, though, can provide anything from powerful sequencer environments to realistic simulations of human instrument articulation.

Scripts are not only available on the Instrument level, but on the Multi level as well. This opens up a wide range of new possibilities in Script design; for instance, you can write Scripts that split and distribute MIDI data among multiple Instruments. For the most part, the scripting features that you can use on a global level are very similar to those on the Instrument level; there are some inherent differences, though, which are explained in the KSP Reference Manual.

Loading, editing and managing Scripts takes place in one of Kontakt’s Script Editors. You can access the global editor, which contains Scripts that affect the Multi, by clicking on the button labeled KSP on the right side of the Instrument Rack Header.

The KSP button in the instrument rack header.

The KSP button

In order to open the local editor of an Instrument, click the Script Editor button below its header when the Rack is in Edit mode. The Script Editors on the Multi and Instrument levels are mostly identical, and the explanations in the remainder of this chapter apply to both.

An empty Script Editor.

An empty Script Editor

At the top of the panel, you’ll notice five tabs, each of them with an empty label. These are slots that can take up a Script each; if a Script changes any events, another script in a slot to its right will “see” the modified events. In other words, the five slots act as a chain of event filters. Below the slot tabs, there’s an empty space; each script can provide its own user interface, which will appear here.

Loading a Script

To load a Script, click the Preset button. A drop-down menu will appear, allowing you to select an item from the preset scripts folder of your Kontakt installation.

The drop-down menu for preset scripts.

Loading a preset Script

After you’ve selected a Script, its user interface controls will appear in the space below the tabs. Most Scripts will work right away after loading; others might need you to do any meaningful adjustments first. You can always bypass a Script, thus temporarily deactivating it, by clicking on the Bypass button in the upper left corner of the Script Editor.

Whenever you’re using a Script that provides its own controls, you can automate these like any other control of the Kontakt user interface; select the Automation tab in the Side pane and drag either a MIDI controller or a host controller ID onto the knob whose parameter you’d like to automate. For more information on how this works, refer to section Automation Tab.

Saving Script Settings

Whenever you have made a setting that you particularly like, you can save the Script in its current state for later re-use. Just click the Script button, then select the Save Preset command from the drop-down menu. A dialog will appear, asking you to enter a new filename for the Script. We don’t recommend that you overwrite the original Script with your new settings, except if you want to change its default state for any later use.

Note that you don’t need to explicitly save your Script if its settings are unique to your current project; its state will be saved along with your session or Multi. Also, some more sophisticated Scripts provide a built-in facility for preset management within the Script’s user interface.

Editing and Saving a Script

If you’re into programming, you can browse and edit the source code of a Script via a built-in code editor. Click the Edit button in the lower left corner of the Script Editor; a text editor pane will open below the Script’s user interface. Within this editor, you can make changes to the current Script, or write your own Script from scratch. Whenever you’ve made any changes, they won’t affect the running Script right away; instead, the Apply button in the upper right corner of the source code editor will light up to remind you that you’ll have to commit the changes first. You do this by clicking the Apply button; if the Script interpreter does not find any errors in your Script, your changes will be made active. Keep in mind, though, that you still need to save your Script in order to make the changes permanent.

Locking a Script

If you want to protect the source code of your Script to keep others from browsing and editing it, you can lock it with a password while the source code editor is visible. To do this, click the Lock with Password button in the upper left corner of the source editor, enter a password twice, and click OK. Others can still use the script as it is, but the source code editor won’t show up if they don’t have the password.

Before you lock a Script, though, remember that there’s a helpful and friendly community of fellow Script authors out there; locking your Scripts will keep them from finding and fixing bugs you might have missed or enhancing them with new features.

Tip

Even if a thorough explanation of the scripting language is beyond the scope of this manual, here’s a neat trick we don’t want to keep back: you can turn any panel of an Instrument Script into a Performance View, thereby making it visible and accessible within the Rack, simply by adding the statement “make_perfview” in a new line somewhere between the lines “on init” and the following “end on”, which can usually be found at the top of Scripts. After you click the Apply button and return to the Multi Instrument view, the Script controls will appear below the Instrument Header in the Rack. You can read more about the Performance View feature in section Performance View of this manual.