Skip to main content

Multi Script

General Information

The multi script utilizes the same KSP syntax as the instrument scripts. Here are the main differences:

  • The multi script works on a pure MIDI event basis, i.e., you're working with raw MIDI data.

  • There are only four callback types available: on init, on persistence_changed, on midi_in, and the various on ui_control callbacks.

  • Every MIDI event triggers the on midi_in callback.

  • There are various built-in variables for the respective MIDI bytes.

The new multi script tab is accessed by clicking on the KSP button in the multi header.

Just as instrument scripts are saved with the instrument, multi scripts are saved with the multi. In relation to GUIs, everything is identical with the instrument script. The scripts are stored in a folder called Multiscripts, which resides next to the already existing Scripts folder inside the Presets folder in the factory data:

macOS: /Library/Application Support/Native Instruments/Kontakt 8/Presets/Multiscripts

Windows: C:\Program Files\Common Files\Native Instruments\Kontakt 8\Presets\Multiscripts

It is very important to understand the different internal structure of the event processing in the multi script, as opposed to the instrument script.

On the instrument level, you can retrieve the event IDs of notes only, i.e., $EVENT_ID only works in the on note and on release callbacks. On the multi level, any incoming MIDI event has a unique ID which can be retrieved with $EVENT_ID. This means, $EVENT_ID can be a note event, a controller message, a Program Change command etc.

This brings us to the usage of change_note(), change_velo() etc. commands. Since $EVENT_ID does not necessarily refer to a note event, these commands will not work in the multi script either. However, it is possible to modify aspects of the incoming event using the set_event_par() command.

And most important of all, remember that the multi script is nothing more than a MIDI processor, whereas the instrument script is an event processor. A note event in the instrument script is bound to a voice, whereas MIDI events from the multi script are translated into note events on the instrument level. This simply means that play_note(), note_off() etc. don't work in the multi script.

It is beneficial to be familiar with the basic structure of MIDI messages when working with the multi script.

ignore_midi

ignore_midi

Ignores the event which triggered the callback.

Remarks

  • Like ignore_event(), ignore_midi is a very "strong" command. Keep in mind that ignore_midi will ignore all incoming events.

  • If you just want to change the MIDI channel and/or any of the MIDI bytes of incoming events, you can also use set_event_par().

Example

on midi_in
    if ($MIDI_COMMAND = $MIDI_COMMAND_NOTE_ON and $MIDI_BYTE_2 > 0)
        ignore_midi
    end if

    if ($MIDI_COMMAND = $MIDI_COMMAND_NOTE_OFF or ($MIDI_COMMAND = $MIDI_COMMAND_NOTE_ON and $MIDI_BYTE_2 = 0))
        ignore_midi
    end if
end on

Ignoring Note On and Note Off messages. Note that some keyboards use a Note On command with a velocity of 0 to designate a Note Off command.

See Also 

ignore_event()

on midi_in

on midi_in

MIDI callback, triggered by every incoming MIDI event.

Example

on midi_in
    select ($MIDI_COMMAND)
        case $MIDI_COMMAND_NOTE_ON
            if ($MIDI_BYTE_2 > 0)
                message("Note On")
            else
                message("Note Off")
            end if
        case $MIDI_COMMAND_NOTE_OFF
            message("Note Off")
        case $MIDI_COMMAND_CC
            message("Controller")
        case $MIDI_COMMAND_PITCH_BEND
            message("Pitch Bend")
        case $MIDI_COMMAND_MONO_AT
            message("Channel Pressure")
        case $MIDI_COMMAND_POLY_AT
            message("Poly Pressure")
        case $MIDI_COMMAND_PROGRAM_CHANGE
            message("Program Change")
    end select
end on

Monitoring various incoming MIDI messages.

See Also

ignore_midi

set_midi()

set_midi(<channel>, <command>, <byte-1>, <byte-2>)

Create any type of MIDI event.

Remarks

  • If you simply want to change the MIDI channel and/or any of the MIDI bytes, you can use set_event_par() command.

Example

on midi_in
    if ($MIDI_COMMAND = $MIDI_COMMAND_NOTE_ON and $MIDI_BYTE_2 > 0)
        set_midi($MIDI_CHANNEL, $MIDI_COMMAND_NOTE_ON, $MIDI_BYTE_1 + 4, $MIDI_BYTE_2)
        set_midi($MIDI_CHANNEL, $MIDI_COMMAND_NOTE_ON, $MIDI_BYTE_1 + 7, $MIDI_BYTE_2)
    end if

    if ($MIDI_COMMAND = $MIDI_COMMAND_NOTE_OFF or ($MIDI_COMMAND = $MIDI_COMMAND_NOTE_ON and $MIDI_BYTE_2 = 0))
        set_midi($MIDI_CHANNEL, $MIDI_COMMAND_NOTE_ON, $MIDI_BYTE_1 + 4, 0)
        set_midi($MIDI_CHANNEL, $MIDI_COMMAND_NOTE_ON, $MIDI_BYTE_1 + 7, 0)
    end if
end on	

A simple harmonizer – note that you also have to supply the correct Note Off commands!

See Also

set_event_par()

Events and MIDI: $EVENT_PAR_MIDI_CHANNEL, $EVENT_PAR_MIDI_COMMAND, $EVENT_PAR_MIDI_BYTE_1, $EVENT_PAR_MIDI_BYTE_2

Multi Script Command Arguments

$MIDI_CHANNEL

The MIDI channel of the received MIDI event. Since Kontakt can handle four different MIDI ports, this number is in 0 ... 63 range (4 ports, 16 MIDI channels).

$MIDI_COMMAND

The command type, i.e Note, CC, Program Change etc. of the received MIDI event. There are various constants for this variable (see below).

$MIDI_BYTE_1

$MIDI_BYTE_2

The two MIDI bytes of the message, can be 0 ... 127.

$MIDI_COMMAND_NOTE_ON

$MIDI_BYTE_1: note number

$MIDI_BYTE_2: velocity

Note: a velocity value of 0 is equivalent to a Note Off command

$MIDI_COMMAND_NOTE_OFF

$MIDI_BYTE_1: note number

$MIDI_BYTE_2: release velocity

$MIDI_COMMAND_POLY_AT

$MIDI_BYTE_1: note number

$MIDI_BYTE_2: polyphonic key pressure value

$MIDI_COMMAND_CC

$MIDI_BYTE_1: controller number

$MIDI_BYTE_2: controller value

$MIDI_COMMAND_PROGRAM_CHANGE

$MIDI_BYTE_1: program number

$MIDI_BYTE_2: not used

$MIDI_COMMAND_MONO_AT

$MIDI_BYTE_1: channel pressure value

$MIDI_BYTE_2: not used

$MIDI_COMMAND_PITCH_BEND

$MIDI_BYTE_1: LSB value

$MIDI_BYTE_2: MSB value

$MIDI_COMMAND_RPN

$MIDI_COMMAND_NRPN

$MIDI_BYTE_1: address

$MIDI_BYTE_2: value

Event Parameter Constants

Event parameters which can be used with get_event_par() and set_event_par():

$EVENT_PAR_MIDI_CHANNEL

$EVENT_PAR_MIDI_COMMAND

$EVENT_PAR_MIDI_BYTE_1

$EVENT_PAR_MIDI_BYTE_2