Welcome to the CKSP Compiler

Modern KSP Scripting for Kontakt

cksp is a compiler and transpiler built in C++, designed to convert cKSP syntax into KSP syntax for Native Instruments' Kontakt.

Its goal is to bring the feel of modern programming languages to Kontakt scripting, introducing modularity and abstractions while ensuring fast compilation. This makes writing and maintaining KSP scripts easier and more approachable—even for those new to Kontakt instrument development.

The CKSP ecosystem

At a Glance

Real-world benchmarks

Up to x48 faster Compilation!

Since almost all SublimeKSP features are supported, cksp can also compile existing sksp projects with minimal changes.

And it does so in seconds with an up to × speed-up compared to SublimeKSP. Below are some real-world projects that have been benchmarked with both compilers (big thanks to Sonuscore for providing these!):

    Benchmarks: 2021 MacBook Pro (M1 Max, 64 GB RAM). SublimeKSP: Optimize Compiled Code and Additional Branch Optimization; cKSP: #pragma optimize("aggressive").

    VS Code → Kontakt
    CKSP Tools for VS Code

    Stay in your editor.
    Ship straight to Kontakt.

    CKSP Tools turns Visual Studio Code into a complete Kontakt scripting workspace: write with rich language support, compile in one shortcut, launch Kontakt, and inspect its filtered log output without breaking your flow.

    One-shortcut builds Smart editor tooling Kontakt log filtering
    Leaner generated output

    Up to 47% Smaller Generated KSP Code!

    Besides faster compilation, cksp also emits smaller, more efficient KSP output reducing parsing and loading work for the Kontakt runtime. The source column describes the size of each original project in non-empty, non-comment source lines. The chart shows that source baseline next to the generated code size produced by SublimeKSP and cKSP 0.1.0.

      Source size: non-empty, non-comment lines in the original codebase. SublimeKSP: Optimize Compiled Code and Additional Branch Optimization; cKSP: #pragma optimize("aggressive").

      Good to know

      Frequently Asked Questions

      The most important questions about CKSP, the compiler, migration from SublimeKSP, and the VS Code workflow.

      What is CKSP?

      CKSP is a compiler for Native Instruments Kontakt scripts. You write your script in the CKSP language, a superset of KSP with local variables, functions, structs and modules, and the compiler turns it into plain KSP that Kontakt loads like any hand-written script.

      It reads both *.cksp and vanilla *.ksp files, is written in C++, and is available in two forms:

      • CKSP Tools, a VS Code extension that bundles the compiler with completion, KSP documentation and Kontakt integration.
      • A standalone command-line executable for macOS and Windows, for Sublime Text or your own build scripts.

      Getting started walks you through a first script in a few minutes.

      Is CKSP free?

      Yes. Both the CKSP compiler and the CKSP Tools extension are free to download and use. The extension is on the VS Code Marketplace, and the compiler binaries are on the GitHub releases page.

      Why use CKSP instead of vanilla KSP?

      Vanilla KSP only has global variables declared in on init, no function parameters or return values, and no way to group data. That works for small scripts, but large instruments become hard to read and maintain. CKSP adds what you know from other languages:

      • Local variables and lexical scope: declare a variable in any block. It only exists there, so names no longer clash across the script.
      • Real functions with parameters, return values and optional types, which can also be called inside conditions.
      • Structs with methods, operator overloading, generic type parameters like List<T> and dynamic allocation with new.
      • Modern loops: for ... in range(...), for-each over arrays, plus break and continue.
      • Imports and namespaces for splitting a project into files.

      Kontakt only ever sees the generated KSP, so none of this requires anything from Kontakt itself. All features are covered in The CKSP Syntax.

      Does CKSP stay compatible with Kontakt?

      Yes. The output is ordinary KSP text. Kontakt loads it like a hand-written script, and anyone who opens your instrument, whether a colleague or a customer, does not need CKSP installed.

      The usual workflow is to write the output straight into your instrument's resource container with #pragma output_path("Samples/Resources/scripts/main.txt") and load that file as a resource script in the script slot. Kontakt then picks up every new build without copy and paste. You can also paste the generated *.txt into an empty script slot and click Apply.

      The CKSP Tools project initializer sets this up for you and requires Kontakt 7 or newer. See Kontakt Integration for details.

      Can CKSP compile existing KSP or SublimeKSP projects?

      Usually yes. Vanilla KSP compiles as is, and CKSP supports most features of nojanath's SublimeKSP fork, so many projects build with few or no changes. The differences you are most likely to run into:

      • Parameter passing: SublimeKSP passes every function parameter by reference. CKSP passes int, real and string parameters by value. Mark single parameters with ref, or switch the default with #pragma pass_by("reference"). The compiler warns where a value parameter is modified.
      • Output path: {#pragma save_compiled_source ...} becomes #pragma output_path(...). Written as //#pragma output_path(...), it works with both compilers.
      • Task functions are no longer needed and can become normal functions. The editor offers a quick fix.
      • Not supported: property blocks, concat() and list_add(). Structs use a different syntax.

      To try it without switching, add cksp as a second Build System in Sublime Text next to SublimeKSP. If a build fails, the error message names the construct and what to replace it with. The full comparison is in Adopted Features.

      Which SublimeKSP preprocessor features are supported?

      All of the commonly used ones:

      • macro ... end macro with #param# text replacement, also inside strings
      • define constants and function-like defines such as define POINT(x, y) := x, y
      • iterate_macro and literate_macro, including the one-line shorthand with #n# and #l#, plus the _post_ variants
      • START_INC / END_INC number incrementers
      • The built-in defines, plus __CKSP_VER__ for the compiler version

      Beyond the preprocessor, families, constant blocks, UI arrays, multidimensional arrays, the pers / read shorthands, control -> param syntax, set_*_properties() and import_nckp() are supported too. Examples for each are in Adopted Features.

      How do I compile a CKSP file?

      In VS Code with CKSP Tools:

      • Compile the project's main file with Shift+Cmd+R on macOS or Shift+Ctrl+R on Windows, or with the play button in the CKSP Sidebar.
      • Compile the file you are editing with Shift+Alt+R.

      All open files are saved first, and compiler errors in the cksp terminal link to the exact source line.

      In Sublime Text, once cksp is set up as a Build System, press Cmd+B on macOS or Ctrl+B on Windows.

      From the command line, run cksp -o path/to/output.txt path/to/main.cksp. Without -o, the compiler writes out.txt next to the input file. Use -O3 for the most aggressive optimization and cksp --help for all options. Setup for each route is in Installation.

      What does the VS Code extension add?

      CKSP Tools turns VS Code into an IDE for Kontakt scripting, for both *.cksp and *.ksp files:

      • Editor: highlighting, completion, signature help, go to definition, find references and inlay hints. Hovering a built-in KSP command shows its official documentation, so you rarely need the KSP manual.
      • Compiler: download and switch compiler versions per project, compile with one shortcut, and click errors to jump to the source.
      • Project setup: New Project creates the .nki, resource folders and a starter main.cksp, already linked to the script slot.
      • Kontakt: start Kontakt from the editor, read and filter the Kontakt log, jump from a log entry to its source, and see script errors in the Problems tab.
      • Project awareness: resource file paths and performance view (.nckp) controls show up as completions.

      It requires VS Code 1.87 or newer. The full feature tour is in VS Code Extension.

      How fast is CKSP compared with SublimeKSP?

      On six real-world Kontakt libraries provided by Sonuscore, CKSP compiles 13 to 48 times faster than SublimeKSP: between 0.4 and 2.3 seconds, where SublimeKSP takes 12 to 100 seconds. The largest project, Time Textures Expanded, drops from 100 s to about 2 s.

      The output is also smaller, by up to 47%: the same project compiles to about 61,000 lines of KSP instead of 115,000, which means less code for Kontakt to parse and load.

      Measured on an M1 Max MacBook Pro, with both compilers at their highest optimization settings. The per-project numbers are in the benchmark charts above.

      Is CKSP still under active development?

      Yes. The compiler and CKSP Tools both get regular releases. Next to the stable versions, alpha pre-releases ship features early. CKSP Tools can install several compiler versions side by side, so you can try a pre-release in one project and keep another on stable.

      Recent releases added generic structs, recursive data structures, booleans with ternary expressions and import ... as. Classes with polymorphism and recursion are next, as listed under Planned Features. Changelogs are on the releases page.

      Where can I find the latest release or report issues?

      When you report a bug, include the compiler version (cksp --version) and, if possible, a small snippet that reproduces it.