Posted by & filed under KSP Scripting (NI Kontakt) - Tutorials, KSP: Basics.

To start scripting

  1. start Kontakt and create a new instrument
  2. click on the wrench symbol
  3. click on “Script Editor” and then “edit”
  4. in the window below you write your code
init_the-editor1

The Script Tabs

You can use all the 5 tabs to create independent UI’s or to separate different scripts (for better clarity). But be careful the code inside different tabs is not really independent from each other. There are commands or callbacks which are affecting each other (like the on note callback).

Executing your Script & Error Reporting

When you hit the apply button your script gets executed immediately. However if there are any errors, Kontakt will not execute the script but report the first error with a status message below. It also marks the affected line of code. However it will not report all kind of errors. Eg. it doesn’t show runtime errors. Furthermore you will probably find the whole error reporting and debugging very nerve-racking. However the automatic warnings are still a good help to quickly find typos and slips.

init_the-editor2

The “Title for The Script” field

The Text you put into the “Title for the Script” field is also visible on the respective UI tab outside the edit mode (wrench button). But only when using multiple tabs in combination with the “make_perfview” command. The “make_perfview” command just makes the actual script tab visible outside the edit mode. You need it whenever you make a custom UI with knobs, buttons etc (of which more in later tutorials). Try it yourself by putting the following code into 2 or more tabs and enter some text into the “Title for the Script” field:

on init
  make_perfview
end on
init_the-editor3

“External” Editors

However for code writing you should rather use an “external” editor which makes coding much easier like coloring your code working with indents and offering great additional features like syntax checks, macros etc.  When you are done writing simply copy your code from your external editor, paste it into Kontakt and click apply . Nil’s Liberg’s K Script Editor and Sublime Text are great tools. Of course you can also use any text editor which already simplifies a lot because of the much bigger working space … scrolling sucks 😉

 

2 Responses to “KSP Scripting (NI Kontakt) – BASICS :: The Editor”

    • YummyBeats

      basically it’s like an advanced text editor but with a lot of helpful extra features (like coloring your code) which makes coding a lot easier.
      Especially with sublime text you get tons of intelligent ksp features like macros or functions where you can pass parameters. You can get sublime text at https://www.sublimetext.com/

      reply

Leave a Reply

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