# 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 no on note, on release and on controller 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:

/Native Instruments/Kontakt/presets/multiscripts

The multi script has four callback types: on midi_in, on persistence_changed, on init and the various on ui_control callbacks. Each MIDI event like Note, Controller, Program Change etc. is triggering the on midi_in callback.

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 callback. 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.

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(), change_tune() etc. don't work in the multi script.

You should be familiar with the basic structure of MIDI messages when working with the multi script.

## ignore_midi

ignore_midi

Ignores events

#### 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 bytes, 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.

ignore_event()

## on midi_in

on midi_in

MIDI callback, triggered by every incoming MIDI event

#### Example

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


Monitoring various MIDI data

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 also use set_event_par().

#### 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

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 can go from 0 - 63 (four ports x 16 MIDI channels). $MIDI_COMMAND

The command type like 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, always in the range from 0 to 127

$MIDI_COMMAND_NOTE_ON  $MIDI_BYTE_1 = note number

$MIDI_BYTE_2 = velocity Note: a velocity value of 0 equals 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 = RPN/NRPN address

$MIDI_BYTE_2 = RPN/NRPN value Event Parameter Constants Event parameters to be used with set_event_par() and get_event_par(): $EVENT_PAR_MIDI_CHANNEL

$EVENT_PAR_MIDI_COMMAND  $EVENT_PAR_MIDI_BYTE_1

\$EVENT_PAR_MIDI_BYTE_2