### Get Zone Sample Start Position Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Returns the sample start position for the specified zone. ```APIDOC ## get_zone_sample_start ### Description Returns the sample start position for the specified zone. ### Signature ``` get_zone_sample_start(instrument_idx: integer, zone_idx: integer) -> integer ``` ``` -------------------------------- ### Get Zone Sample Start Position Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Returns the sample start position for the specified zone. ```python get_zone_sample_start(instrument_idx: integer, zone_idx: integer) -> integer ``` -------------------------------- ### Get Group Start Options Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/group Retrieves the start options for a group, returned as a table. This can include conditions like key, controller, round robin, or random. ```lua get_group_start_options(instrument_idx: integer, group_idx: integer) -> table ``` -------------------------------- ### Set Sample Loop Start Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Sets the start of the specified zone's loop. ```APIDOC ## set_sample_loop_start ### Description Sets the start of the specified zone's loop. ### Signature ``` set_sample_loop_start(instrument_idx: integer, zone_idx: integer, loop_idx: integer, frame: integer) ``` ``` -------------------------------- ### Get Desktop Path Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/options Returns the absolute path to the operating system's Desktop folder. No setup is required. ```lua desktop_path: string ``` -------------------------------- ### Configure Group Start Options Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/group Set various modes for when a group should start playing, such as by key, controller, round robin, random, or slice trigger. Default values are used if options are omitted. ```lua set_group_start_options(instrument_idx: integer, group_idx: integer, options: table) ``` -------------------------------- ### Set Sample Loop Start Frame Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Sets the starting frame for a specified zone's loop. ```python set_sample_loop_start(instrument_idx: integer, zone_idx: integer, loop_idx: integer, frame: integer) ``` -------------------------------- ### Group Start Conditions Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/group Lists the available conditions that can trigger a group's playback. These are used in conjunction with start operators. ```lua group_start_conditions: table " controller" "key" "random" "round_robin" "slice_trigger" ``` -------------------------------- ### API Access Example Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/introduction-and-setup Demonstrates how to access Kontakt API functions by prefixing them with the global table 'Kontakt'. ```APIDOC ## API Access Kontakt Lua API is defined in the global table `Kontakt`, i.e. all constants and functions need to be prefixed with that name. For example: ```lua Kontakt.reset_multi() -- also works local kt = Kontakt kt.reset_multi() ``` ``` -------------------------------- ### Set Zone Sample Start Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Sets the sample start of the sample loaded in the specified zone, in sample frames. ```python set_zone_sample_start(instrument_idx: integer, zone_idx: integer, frame: integer) ``` -------------------------------- ### get_sample_loop_start Function Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Retrieves the start position of a specific loop within a zone of an instrument. ```lua get_sample_loop_start(instrument_idx: integer, zone_idx: integer, loop_idx: integer) -> integer ``` -------------------------------- ### Get Documents Path Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/options Returns the absolute path to the operating system's Documents folder. No setup is required. ```lua documents_path: string ``` -------------------------------- ### Access MIR API Example Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/music-information-retrieval--mir- Demonstrates how to access and use MIR functions by prefixing them with the global 'MIR' table. Requires importing Kontakt and Filesystem libraries. ```lua kt = Kontakt fs = Filesystem print(MIR.detect_pitch(fs.join(kt.script_path, 'samples/Sine440_1sec.wav'))) ``` -------------------------------- ### Get NI Content Path Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/options Returns the absolute path to the NI Content folder. No setup is required. ```lua ni_content_path: string ``` -------------------------------- ### Get Multi Name Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/multi Retrieves the name of the current Multi. No setup or imports are required. ```lua get_multi_name() ``` -------------------------------- ### Get Free Instrument Index Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Retrieves the index of the next available slot for loading a new instrument. This is useful for dynamically managing instruments in your Kontakt setup. ```lua get_free_instrument_index() -> integer? ``` -------------------------------- ### Get Zone Sample Start Modulation Range Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Returns the modulation range for the sample start position of the specified zone. ```python get_zone_sample_start_mod_range(instrument_idx: integer, zone_idx: integer) -> integer ``` -------------------------------- ### Get Non-Player Content Base Path Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/options Returns the non-Player content base path, which is optionally set in Kontakt's Options > Loading pane. No setup is required. ```lua non_player_content_base_path: string ``` -------------------------------- ### Get Zone Sample Start Modulation Range Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Returns the sample start modulation range for the specified zone. ```APIDOC ## get_zone_sample_start_mod_range ### Description Returns the sample start modulation range for the specified zone. ### Signature ``` get_zone_sample_start_mod_range(instrument_idx: integer, zone_idx: integer) -> integer ``` ``` -------------------------------- ### Get Snapshot Path Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/options Returns the User Content data path, which contains snapshots saved by the user. No setup is required. ```lua snapshot_path: string ``` -------------------------------- ### Get Factory Path Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/options Returns the Kontakt factory data path, which contains essential assets like wavetables and NKP presets. No setup is required. ```lua factory_path: string ``` -------------------------------- ### set_group_start_options Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/group Configures the starting conditions for a group based on key presses, controller input, or round-robin/random cycling. Supports various modes like 'key', 'controller', 'round_robin', 'random', and 'slice_trigger'. ```APIDOC ## set_group_start_options ### Description Configures the starting conditions for a group based on key presses, controller input, or round-robin/random cycling. ### Parameters - `instrument_idx` (integer) - Required - The index of the instrument. - `group_idx` (integer) - Required - The index of the group. - `options` (table) - Required - A table containing the start options. ### Options Table Details: **Start On Key** * `mode` : “key” * `key_min`: integer (default: 24) * `key_max`: integer (default: 24) * `next`: group_start_operators (default: “ and”) **Start On Controller** * `mode` : “controller” * `controller`: (default: 1) * `cc_min`: (default: 0) * `cc_max`: (default: 64) * `next`: group_start_operators (default: “ and”) **Cycle Round Robin** * `mode` : “round_robin” * `position`: integer (default: 1) * `next`: group_start_operators (default: “ and”) **Cycle Random** * `mode` : “random” * `next`: group_start_operators (default: “ and”) **Slice Trigger** * `mode` : “slice_trigger” * `zone`: integer (default: nil) * `slice`: integer (default: nil) * `internal`: boolean (default: false) * `next`: group_start_operators (default: “ and”) *Note: Individual entries of the options table can be omitted, in which case the default value is used. See also: group_start_conditions* ``` -------------------------------- ### Group Start Operators Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/group Defines logical operators for combining group start conditions. Used to specify how multiple conditions should be evaluated. ```lua group_start_operators: table " and" "and_not" "or" ``` -------------------------------- ### Find Loop Points - Kontakt API Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/music-information-retrieval--mir- Analyzes an audio file to detect loop start and end points. Allows specifying minimum start, maximum end, and minimum length for the loop. ```lua find_loop(file: string) -> start: integer?, end: integer? find_loop(file: string, min_start: float, max_end: float, min_length: float) -> start: integer?, end: integer? ``` -------------------------------- ### Get Property Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/multi Functions to retrieve information about the multi and its scripts. ```APIDOC ## Get Property ### get_multi_name ``` get_multi_name() -> string ``` Returns the name of the multi. ### get_multi_script_name ``` get_multi_script_name(multi_script_idx: integer) -> string ``` Returns the title of the multi script in the specified multi script slot. ### get_multi_script_source ``` get_multi_script_source(multi_script_idx: integer) -> string ``` Returns the complete multi script contained in the specified multi script slot. ### get_num_instruments ``` get_num_instruments() -> integer ``` Returns the number of instruments loaded in the multi. ### is_multi_script_bypassed ``` is_multi_script_bypassed(multi_script_idx: integer) -> bool ``` Returns true if the specified multi script slot is bypassed. ### is_multi_script_protected ``` is_multi_script_protected(multi_script_idx: integer) -> bool ``` Returns true if the specified multi script slot is protected with a password. ``` -------------------------------- ### set_zone_sample_start Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Sets the sample start of the sample loaded in the specified zone, in sample frames. ```APIDOC ## set_zone_sample_start ### Description Sets the sample start of the sample loaded in the specified zone. ### Method Signature `set_zone_sample_start(instrument_idx: integer, zone_idx: integer, frame: integer)` ### Parameters * **instrument_idx** (integer) - The index of the instrument. * **zone_idx** (integer) - The index of the zone. * **frame** (integer) - The sample start in sample frames. ``` -------------------------------- ### Get Instrument Options Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Retrieves a table containing various options for a specified instrument. This includes settings for key range, velocity, MIDI transpose, voice handling, DFD, controller behavior, snapshots, and info display. ```lua get_instrument_options(instrument_idx: integer) -> table ``` -------------------------------- ### Maximum Number of Group Start Criteria Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/group Constant indicating the maximum number of criteria that can define a group's start condition. As of Kontakt 7.5, this is 4. ```lua max_num_group_start_criteria: integer -- As of Kontakt 7.5, this constant returns**4**. ``` -------------------------------- ### Set Zone Sample Start Modulation Range Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Sets the sample start modulation range of the sample loaded in the specified zone, in sample frames. ```python set_zone_sample_start_mod_range(instrument_idx: integer, zone_idx: integer, frame: integer) ``` -------------------------------- ### Get Zone Sample Frames Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Returns the length of the sample loaded in the specified zone. ```APIDOC ## get_zone_sample_frames ### Description Returns the length of the sample loaded in the specified zone. ### Signature ``` get_zone_sample_frames(instrument_idx: integer, zone_idx: integer) -> integer? ``` ``` -------------------------------- ### find_loop Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/music-information-retrieval--mir- Analyzes an audio file to detect its loop points (start and end). Optional parameters can specify minimum loop start, maximum loop end, and minimum loop length. ```APIDOC ## find_loop ### Description Analyzes `file` and returns the detected loop points or **nil** if detection fails. ### Method Signature ``` find_loop(file: string) -> start: integer?, end: integer? find_loop(file: string, min_start: float, max_end: float, min_length: float) -> start: integer?, end: integer? ``` ``` -------------------------------- ### Get Property Functions Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Functions to retrieve various properties of zones and their associated sample loops within an instrument. ```APIDOC ## Get Property ### get_num_zones ``` get_num_zones(instrument_idx: integer) -> integer ``` Returns the total number of zones in the specified instrument. ### get_sample_loop_count ``` get_sample_loop_count(instrument_idx: integer, zone_idx: integer, loop_idx: integer) -> integer ``` Returns the loop count of the specified zone’s loop. ### get_sample_loop_length ``` get_sample_loop_length(instrument_idx: integer, zone_idx: integer, loop_idx: integer) -> integer ``` Returns the loop length of the specified zone’s loop. ### get_sample_loop_mode ``` get_sample_loop_mode(instrument_idx: integer, zone_idx: integer, loop_idx: integer) -> string ``` Returns the loop mode of the specified zone’s loop. See `sample_loop_modes`. ### get_sample_loop_start ``` get_sample_loop_start(instrument_idx: integer, zone_idx: integer, loop_idx: integer) -> integer ``` Returns the loop start of the specified zone’s loop. ### get_sample_loop_tune ``` get_sample_loop_tune(instrument_idx: integer, zone_idx: integer, loop_idx: integer) -> float ``` Returns the loop tuning of the specified zone’s loop in semitones. ### get_sample_loop_xfade ``` get_sample_loop_xfade(instrument_idx: integer, zone_idx: integer, loop_idx: integer) -> integer ``` Returns the loop crossfade time of the specified zone’s loop. ### get_zone_geometry ``` get_zone_geometry(instrument_idx: integer, zone_idx: integer) -> table ``` Returns a table containing the complete zone geometry (key and velocity ranges, root key, zone crossfades, etc.). See `set_zone_geometry`. ### get_zone_grid_bpm ``` get_zone_grid_bpm(instrument_idx: integer, zone_idx: integer) -> float ``` Returns the BPM of the specified zone. ### get_zone_grid_mode ``` get_zone_grid_mode(instrument_idx: integer, zone_idx: integer) -> string ``` Returns the grid mode of the specified zone. See `zone_grid_modes`. ### get_zone_group ``` get_zone_group(instrument_idx: integer, zone_idx: integer) -> integer ``` Returns the index of the group which contains the specified zone. ### get_zone_high_key ``` get_zone_high_key(instrument_idx: integer, zone_idx: integer) -> integer ``` Returns the high key of the specified zone. ### get_zone_high_key_fade ``` get_zone_high_key_fade(instrument_idx: integer, zone_idx: integer) -> integer ``` Returns the high key crossfade span of the specified zone. ### get_zone_high_velocity ``` get_zone_high_velocity(instrument_idx: integer, zone_idx: integer) -> integer ``` Returns the high velocity of the specified zone. ### get_zone_high_velocity_fade ``` get_zone_high_velocity_fade(instrument_idx: integer, zone_idx: integer) -> integer ``` Returns the high velocity crossfade span of the specified zone. ### get_zone_low_key ``` get_zone_low_key(instrument_idx: integer, zone_idx: integer) -> integer ``` Returns the low key of the specified zone. ### get_zone_low_key_fade ``` get_zone_low_key_fade(instrument_idx: integer, zone_idx: integer) -> integer ``` Returns the low key crossfade span of the specified zone. ### get_zone_low_velocity ``` get_zone_low_velocity(instrument_idx: integer, zone_idx: integer) -> float ``` Returns the low velocity of the specified zone. ### get_zone_low_velocity_fade ``` get_zone_low_velocity_fade(instrument_idx: integer, zone_idx: integer) -> float ``` Returns the low velocity crossfade span of the specified zone. ### get_zone_pan ``` get_zone_pan(instrument_idx: integer, group_idx: integer) -> float ``` Returns the panorama offset of the specified zone. ### get_zone_root_key ``` get_zone_root_key(instrument_idx: integer, zone_idx: integer) -> integer ``` Returns the root key of the specified zone. ### get_zone_sample ``` get_zone_sample(instrument_idx: integer, zone_idx: integer) -> string? ``` Returns the absolute file path of the sample loaded in the specified zone. ### get_zone_sample_channels ``` get_zone_sample_channels(instrument_idx: integer, zone_idx: integer) -> integer? ``` Returns the number of audio channels in the sample loaded in the specified zone. ``` -------------------------------- ### Get File Info Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/utility Extracts information from an instrument file on disk. Returns a table with details like file format, version, library name, and counts of instruments, groups, and zones. ```lua get_file_info(filename: string) -> table ``` -------------------------------- ### Get Zone Tune Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Returns the tuning offset of the specified zone in semitones. ```APIDOC ## get_zone_tune ### Description Returns the tuning offset of the specified zone in semitones. ### Signature ``` get_zone_tune(instrument_idx: integer, zone_idx: integer) -> float ``` ``` -------------------------------- ### Get Group Properties Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/group Methods for retrieving information about groups within an instrument. ```APIDOC ## Get Property ### get_group_name(instrument_idx: integer, group_idx: integer) -> string Returns the name of the specified group. ### get_group_pan(instrument_idx: integer, group_idx: integer) -> float Returns the amplifier panorama of the specified group. ### get_group_playback_mode(instrument_idx: integer, group_idx: integer) -> string Returns the playback mode of the specified group’s Source module. See `group_playback_modes`. ### get_group_start_options(instrument_idx: integer, group_idx: integer) -> table Returns specified group’s start options as a table with a maximum of 4 sub-tables: A certain group start option condition can be defined by passing a table. This table has different entries based on condition type: **Start On Key** * `mode` : “key” * `key_min`: integer (default: **24**) * `key_max`: integer (default: **24**) * `next`: group_start_operators (default: **“ and”**) **Start On Controller** * `mode` : “controller” * `controller`: (default: **1**) * `cc_min`: (default: **0**) * `cc_max`: (default: **64**) * `next`: group_start_operators (default: **“ and”**) **Cycle Round Robin** * `mode` : “round_robin” * `position`: integer (default: **1**) * `next`: group_start_operators (default: **“ and”**) **Cycle Random** * `mode` : “random” * `next`: group_start_operators (default: **“ and”**) **Slice Trigger** * `mode` : “slice_trigger” * `zone`: integer (default: **nil**) * `slice`: integer (default: **nil**) * `internal`: boolean (default: **false**) * `next`: group_start_operators (default: **“ and”**) Individual entries of this table can be omitted. In that case the default value is used. See also: `group_start_conditions` ### get_group_tune(instrument_idx: integer, group_idx: integer) -> float Returns the tuning of the specified group in semitones. ### get_group_volume(instrument_idx: integer, group_idx: integer) -> float Returns the amplifier volume of the specified group in dB. ### get_num_groups(instrument_idx: integer) -> integer Returns the total number of groups in the specified instrument. ### get_voice_group(instrument_idx: integer, group_idx: integer) -> integer? Returns the voice group assigned to a group. If no voice group is assigned, the returned value is **nil**. ``` -------------------------------- ### Get Zone Tuning Offset Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Returns the tuning offset for the specified zone in semitones. ```python get_zone_tune(instrument_idx: integer, zone_idx: integer) -> float ``` -------------------------------- ### Get Zone Sample Length Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Returns the total length in sample frames of the sample loaded into the specified zone. ```python get_zone_sample_frames(instrument_idx: integer, zone_idx: integer) -> integer? ``` -------------------------------- ### Get Multi Script Source Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/multi Retrieves the complete source code of a multi script. Requires the index of the multi script slot. ```lua get_multi_script_source(multi_script_idx: integer) ``` -------------------------------- ### Get Multi Script Name Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/multi Retrieves the title of a specific multi script. Requires the index of the multi script slot. ```lua get_multi_script_name(multi_script_idx: integer) ``` -------------------------------- ### Get Instrument Name Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Retrieves the name of a specified instrument. This is useful for identifying instruments in your project. ```lua get_instrument_name(instrument_idx: integer) -> string ``` -------------------------------- ### Access Filesystem API via Global Table Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/filesystem Demonstrates accessing Filesystem API functions and constants through the global 'Filesystem' table. Also shows an alternative way to reference global tables. ```lua print(Filesystem.exists(Kontakt.script_path)) ``` ```lua -- also works kt = Kontakt fs = Filesystem print(fs.exists(kt.script_path)) ``` -------------------------------- ### Get Number of Instruments Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/multi Returns the total count of instruments loaded within the current Multi. This function requires no arguments. ```lua get_num_instruments() ``` -------------------------------- ### Get Instrument Pan Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Retrieves the stereo panorama setting for a specified instrument. This controls the left-right balance of the instrument's audio output. ```lua get_instrument_pan(instrument_idx: integer) -> float ``` -------------------------------- ### Get Group Playback Mode Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/group Retrieves the playback mode of a group's Source module. Refer to `group_playback_modes` for possible values. ```lua get_group_playback_mode(instrument_idx: integer, group_idx: integer) -> string ``` -------------------------------- ### Group Playback Modes Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/group Defines the possible playback modes for a group's Source module. Use these string values when setting or getting the group's playback mode. ```lua group_playback_modes: table " beat_machine" "dfd" "mpc60_machine" "s1200_machine" "sampler" "time_machine_1" "time_machine_2" "time_machine_pro" "tone_machine" "wavetable" ``` -------------------------------- ### Kontakt API Preset Constants Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/presets These integer constants specify the target FX chain for preset loading functions. Use `bus_fx` for the first instrument bus FX, `group_fx` for the group FX, `insert_fx` for the insert FX, `main_fx` for the main FX, `output_fx` for the output FX, and `send_fx` for the send FX chain. For `bus_fx`, you can target other instrument buses by adding an integer from 1 to 15. ```lua bus_fx: integer ``` ```lua group_fx: integer ``` ```lua insert_fx: integer ``` ```lua main_fx: integer ``` ```lua output_fx: integer ``` ```lua send_fx: integer ``` -------------------------------- ### Using Lua Modules Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/introduction-and-setup Recommends organizing reusable functionality into Lua modules and including them using the `require` keyword. ```APIDOC ## Modules It is recommended to move reusable functionality into _Lua modules_ and include them via the `require` keyword. Lua's `package.path` is initialized with the folder pointing to the script. ``` -------------------------------- ### Get Zone Sample End Position Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Returns the sample end position for a zone. To match the Kontakt UI, add the result of `get_zone_sample_frames()` to this value. ```python get_zone_sample_end(instrument_idx: integer, zone_idx: integer) -> integer ``` -------------------------------- ### load_fx_chain_preset Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/presets Loads a complete effect chain preset file (.NKP) to the specified location. ```APIDOC ### load_fx_chain_preset ``` load_fx_chain_preset(filename: string, instrument_idx: integer, group_idx: integer, generic: integer) -> integer ``` Loads a complete effect chain preset file (.NKP) to the specified location based on the following arguments: * `instrument` : instrument index * `group`: only valid when `generic` argument is `group_fx`, else set to **-1** * `generic` : use one of FX chain location constants, except `output_fx` ``` -------------------------------- ### Create Resource Container Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/utility Creates a new resource container (with an 'Resources' folder) or updates an existing one. The '.nkr' extension is added automatically if not present. ```lua create_resource_container(instrument_idx: integer, filename: string) ``` -------------------------------- ### Load Multi Script Preset Function Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/presets Loads a multi script preset file (.NKP) to the specified multi script slot of an instrument. Provide the correct `filename`, `instrument_idx`, and `multi_script_idx`. ```lua load_multi_script_preset(filename: string, instrument_idx: integer, multi_script_idx: integer) -> integer ``` -------------------------------- ### Load Instrument from File Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Loads an instrument from a specified file into a given slot index. If the slot is occupied, it will be loaded into the next available slot. Returns the slot index where the instrument was loaded. ```Kontakt Script load_instrument(filename: string, instrument_idx: integer?) -> integer ``` -------------------------------- ### Version Constant Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/utility Returns the current version of the running Kontakt instance. ```lua version: string ``` -------------------------------- ### load_fx_preset Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/presets Loads an effect preset file (.NKP) to the specified location. ```APIDOC ### load_fx_preset ``` load_fx_preset(filename: string, instrument_or_output_idx: integer, group_idx: integer, generic: integer) -> integer ``` Loads an effect preset file (.NKP) to the specified location based on the following arguments: * `instrument_or_output` : if `generic` argument is `output_fx`, this is one of output channels in the Output panel (**0 … 127**), else it’s an instrument index * `group`: only valid when `generic` argument is `group_fx`, else set to **-1** * `slot` : index of the slot to which the effect preset should be loaded * `generic`: use one of FX chain location constants (`group_fx`, `send_fx`, etc.) ``` -------------------------------- ### Restore Loops from Sample Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Sets the loop points of a zone to the values stored in the sample metadata, if they exist. ```python restore_loops_from_sample(instrument_idx: integer, zone_idx: integer) ``` -------------------------------- ### Load Snapshot Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Loads a snapshot into the specified instrument index. ```Kontakt Script load_snapshot(instrument_idx: integer, filename: string) ``` -------------------------------- ### Save Multi with Options Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/multi Saves the current Multi to a file with customizable options. Options include save mode, path type, sample compression, and sample subdirectory. Defaults are applied if options are omitted. ```lua save_multi(filename: string, options: table) ``` -------------------------------- ### Get Zone Sample End Position Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Returns the sample end position for the specified zone. This is expressed in negative frames, by how far away the sample end marker is from the last sample frame. To get the value displayed in Kontakt's Wave Editor, use `get_zone_sample_frames() + get_zone_sample_end()`. ```APIDOC ## get_zone_sample_end ### Description Returns the sample end position for the specified zone. ### Signature ``` get_zone_sample_end(instrument_idx: integer, zone_idx: integer) -> integer ``` ``` -------------------------------- ### Get Zone Volume Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Returns the volume offset of the specified zone in dB. ```APIDOC ## get_zone_volume ### Description Returns the volume offset of the specified zone in dB. ### Signature ``` get_zone_volume(instrument_idx: integer, zone_idx: integer) -> float ``` ``` -------------------------------- ### load_multi_script_preset Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/presets Loads a multi script preset file (.NKP) to the specified multi script slot. ```APIDOC ### load_multi_script_preset ``` load_multi_script_preset(filename: string, instrument_idx: integer, multi_script_idx: integer) -> integer ``` Loads a multi script preset file (.NKP) to the specified multi script slot. ``` -------------------------------- ### Load Multi Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/multi Loads a specified Multi file. The instrument rack is reset before loading. Requires the filename as a string argument. ```lua load_multi(filename: string) ``` -------------------------------- ### remove_instrument Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Removes an instrument from the multi-instance setup based on its specified instrument index. ```APIDOC ## remove_instrument ### Description Removes the instrument at the specified instrument index from the multi. ### Parameters * `instrument_idx` (integer) - The index of the instrument to remove. ``` -------------------------------- ### desktop_path Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/options Returns the absolute path to the operating system's Desktop folder. ```APIDOC ## desktop_path ### Description Returns the absolute path to operating system’s Desktop folder. ### Type string ``` -------------------------------- ### load_script_preset Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/presets Loads a script preset file (.NKP) to the specified script slot of an instrument. ```APIDOC ### load_script_preset ``` load_script_preset(filename: string, instrument_idx: integer, script_idx: integer) -> integer ``` Loads a script preset file (.NKP) to the specified script slot of an instrument. ``` -------------------------------- ### Load Source Preset Function Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/presets Loads a source preset file (.NKP) to a specified group within an instrument. Ensure the `filename` is correct and the `instrument_idx` and `group_idx` are valid. ```lua load_source_preset(filename: string, instrument_idx: integer, group_idx: integer) -> integer ``` -------------------------------- ### Constants Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Provides access to predefined constants related to sample loops and zones. ```APIDOC ## Constants ### max_num_sample_loops ``` max_num_sample_loops: integer ``` As of Kontakt 7.5, this constant returns **8**. ### max_num_zones ``` max_num_zones: integer ``` As of Kontakt 7.5, this constant returns **98304**. ### sample_loop_modes ``` sample_loop_modes: table ``` Possible values: * " off" * "until_end" * "until_end_alt" * "until_release" * "until_release_alt" ### zone_grid_modes ``` zone_grid_modes: table ``` Possible values: * " auto" * "fixed" * "none" ``` -------------------------------- ### Set Sample Loop Playback Mode Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Sets the playback mode for a specified zone's loop. Refer to `sample_loop_modes` for available modes. ```python set_sample_loop_mode(instrument_idx: integer, zone_idx: integer, loop_idx: integer, mode: string) ``` -------------------------------- ### Load FX Chain Preset Function Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/presets Loads a complete effect chain preset file (.NKP) to the specified location. The `instrument_idx` and `group_idx` are used, and the `generic` argument specifies the location using FX chain constants, excluding `output_fx`. ```lua load_fx_chain_preset(filename: string, instrument_idx: integer, group_idx: integer, generic: integer) -> integer ``` -------------------------------- ### remove_instrument_bank Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Removes an instrument bank from the multi-instance setup using its specified instrument slot. ```APIDOC ## remove_instrument_bank ### Description Removes the instrument bank at the specified instrument slot from the multi. ### Parameters * `instrument_slot` (integer) - The instrument slot of the instrument bank to remove. ``` -------------------------------- ### preferred(path: string) -> string Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/filesystem Returns the path in its preferred format for the current operating system. ```APIDOC ## preferred ```lua preferred(path: string) -> string ``` ``` -------------------------------- ### Sublime Text Build System for Kontakt (macOS) Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/introduction-and-setup Set up Sublime Text to build and execute Kontakt Lua scripts on macOS. This configuration specifies the command to run Kontakt with the current script file. ```json { "shell_cmd": ["/Applications/Native Instruments/Kontakt 8/Kontakt 8.app/Contents/macOS/Kontakt 8", "$file"], } ``` -------------------------------- ### Get Zone Volume Offset Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Returns the volume offset for the specified zone in decibels (dB). ```python get_zone_volume(instrument_idx: integer, zone_idx: integer) -> float ``` -------------------------------- ### set_zone_sample_start_mod_range Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Sets the sample start modulation range of the sample loaded in the specified zone, in sample frames. ```APIDOC ## set_zone_sample_start_mod_range ### Description Sets the sample start modulation range of the sample loaded in the specified zone. ### Method Signature `set_zone_sample_start_mod_range(instrument_idx: integer, zone_idx: integer, frame: integer)` ### Parameters * **instrument_idx** (integer) - The index of the instrument. * **zone_idx** (integer) - The index of the zone. * **frame** (integer) - The sample start modulation range in sample frames. ``` -------------------------------- ### Get Group Tune Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/group Retrieves the tuning offset for a specified group in semitones. Returns a float value. ```lua get_group_tune(instrument_idx: integer, group_idx: integer) -> float ``` -------------------------------- ### Load Script Preset Function Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/presets Loads a script preset file (.NKP) to a specific script slot within an instrument. Ensure the `filename`, `instrument_idx`, and `script_idx` are accurate. ```lua load_script_preset(filename: string, instrument_idx: integer, script_idx: integer) -> integer ``` -------------------------------- ### Load FX Preset Function Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/presets Loads an effect preset file (.NKP) to a specified location. The `instrument_or_output_idx` and `group_idx` parameters vary in meaning based on the `generic` argument. Use FX chain location constants for `generic`. ```lua load_fx_preset(filename: string, instrument_or_output_idx: integer, group_idx: integer, generic: integer) -> integer ``` -------------------------------- ### get_zone_sample Function Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Retrieves the absolute file path of the sample loaded in the specified zone. ```lua get_zone_sample(instrument_idx: integer, zone_idx: integer) -> string? ``` -------------------------------- ### File I/O Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/multi Functions for saving and loading multis. ```APIDOC ## File I/O ### save_multi ``` save_multi(filename: string, options: table) ``` Save options can be defined by passing a table with one or more of the following entries: * `mode` : save_modes (default: " patch") * `absolute_paths`: boolean (default: false) * `compress_samples`: boolean (default: false) * `samples_sub_dir`: string Individual entries of this table can be omitted. In that case the default value is used. ### load_multi ``` load_multi(filename: string) ``` Loads the specified multi. The whole instrument rack is reset beforehand. ``` -------------------------------- ### Get Number of Groups Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/group Returns the total count of groups within a given instrument. Requires the instrument index. ```lua get_num_groups(instrument_idx: integer) -> integer ``` -------------------------------- ### Get Group Volume Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/group Retrieves the volume level of a specified group in decibels (dB). Returns a float value. ```lua get_group_volume(instrument_idx: integer, group_idx: integer) -> float ``` -------------------------------- ### Set Instrument Options Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Configure various instrument settings including key and velocity ranges, MIDI transpose, UI elements, voice handling, DFD, controller behavior, snapshots, and info display. Individual options can be omitted to use default values. ```lua set_instrument_options(instrument_idx: integer, options: table) ``` -------------------------------- ### load_source_preset Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/presets Loads a source preset file (.NKP) to the specified group of an instrument. ```APIDOC ## File I/O ### load_source_preset ``` load_source_preset(filename: string, instrument_idx: integer, group_idx: integer) -> integer ``` Loads a source preset file (.NKP) to the specified group of an instrument. ``` -------------------------------- ### Get Group Name Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/group Retrieves the name of a specific group within an instrument. Requires the instrument and group indices. ```lua get_group_name(instrument_idx: integer, group_idx: integer) -> string ``` -------------------------------- ### Get Voice Group Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/group Retrieves the voice group assigned to a specific group. Returns nil if no voice group is assigned. ```lua get_voice_group(instrument_idx: integer, group_idx: integer) -> integer? ``` -------------------------------- ### Get Group Pan Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/group Retrieves the stereo panorama setting for a specified group. Returns a float value representing the panorama. ```lua get_group_pan(instrument_idx: integer, group_idx: integer) -> float ``` -------------------------------- ### Sublime Text Build System for Kontakt (Windows) Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/introduction-and-setup Configure Sublime Text to execute Kontakt Lua scripts on Windows. This build system definition points to the Kontakt executable and passes the current file as an argument. ```json { "cmd": ["c:\\Program Files\\Native Instruments\\Kontakt 8\\Kontakt 8.exe", "$file"], } ``` -------------------------------- ### Script Executed From Instrument Constant Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/utility Indicates the index of the instrument slot from which the script was loaded. 'nil' signifies multiple instruments. ```lua script_executed_from_instrument: integer | nil ``` -------------------------------- ### Error Handling with pcall Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/introduction-and-setup Explains that all functions can fail and suggests using `_pcall_` for error handling. ```APIDOC ## Errors All functions potentially fail and print an error message pointing to the line causing the error. The reason is usually an invalid argument. Consider using `_pcall_` in order to handle errors. ``` -------------------------------- ### Get Instrument Mute State Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Checks whether a specified instrument is currently muted. Returns `true` if muted, `false` otherwise. ```lua get_instrument_mute(instrument_idx: integer) -> bool ``` -------------------------------- ### Get Instrument MIDI Channel Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Returns the MIDI channel assigned to a specific instrument. This is essential for routing MIDI input correctly. ```lua get_instrument_midi_channel(instrument_idx: integer) -> integer ``` -------------------------------- ### Get Instrument Indices Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Retrieves a table containing the indices of all currently loaded instruments. Pass these indices to other functions that require an `instrument_idx`. ```lua get_instrument_indices() -> table ``` -------------------------------- ### Constants Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/utility Constants provide configuration and information about the Kontakt environment. ```APIDOC ## Constants ### colored_output ``` colored_output: bool ``` Controls if terminal output is colored or not. ### edit_instrument ``` edit_instrument: integer | nil ``` Index of the currently edited instrument. ### script_executed_from_instrument ``` script_executed_from_instrument: integer | nil ``` Index of the instrument slot from which the script was loaded.**nil** is multi. ### script_file ``` script_file: string ``` Returns filename of the currently running Lua script, including the extension. ### script_path ``` script_path: string ``` Returns the absolute path to the folder containing the currently running Lua script. ### version ``` version: string ``` Returns the current version of the running instance of Kontakt. ``` -------------------------------- ### Set Zone Sample Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Sets the absolute path of the sample to be loaded in the specified zone. ```python set_zone_sample(instrument_idx: integer, zone_idx: integer, filename: string) ``` -------------------------------- ### File I/O Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/utility Functions for encoding and decoding audio samples. ```APIDOC ## File I/O ### ncw_decode ``` ncw_decode(source: string, target: string) ``` Decodes an NCW sample back to uncompressed WAV format. ### ncw_encode ``` ncw_encode(source: string, target: string) ``` Encodes a WAV or AIFF sample to losslessly compressed NCW format. ``` -------------------------------- ### Get Instrument Output Channel Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Returns the audio output channel assigned to a specific instrument. Use this to manage audio routing within Kontakt. ```lua get_instrument_output_channel(instrument_idx: integer) -> integer ``` -------------------------------- ### Save Instrument to File Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Saves the current instrument to a specified file. Options for saving, such as mode, path type, sample compression, and sample subdirectory, can be configured via a table. Default values are used for omitted options. ```Kontakt Script save_instrument(instrument_idx: integer, filename: string, options: table) ``` -------------------------------- ### sample_loop_modes Table Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Defines the possible modes for sample loops within a zone. ```lua sample_loop_modes: table ``` -------------------------------- ### Get Instrument Aux Level Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Returns the level of a specific auxiliary send for a given instrument. Use this to query the current send level for effects processing. ```lua get_instrument_aux_level(instrument_idx: integer, aux_index: integer) -> float ``` -------------------------------- ### get_instrument_options Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Retrieves all configurable options for a specified instrument, including instrument, voice handling, DFD, controller, and snapshot settings. ```APIDOC ### get_instrument_options ``` get_instrument_options(instrument_idx: integer) -> table ``` Returns specified instrument’s options as a table with the following entries: **Instrument** * `key_switch` : integer (default: **nil**) * `key_range_from`: integer (default: **0**) * `key_range_to`: integer (default: **127**) * `velocity_range_from`: integer (default: **0**) * `velocity_range_to`: integer (default: **127**) * `midi_transpose`: integer (default: **0**) * `wallpaper`: string (default: **nil**) * `komplete_ui_module_name`: string (default: **""**) * `komplete_ui_width`: integer (default: **633**) * `komplete_ui_height`: integer (default: **50**) **Voice Handling** * `voice_stealing_mode` : voice_stealing_modes (default: **“ oldest”**) * `voice_stealing_fadeout`: integer (default: **10**) * `time_machine_voice_limit`: integer (default: **8**) * `time_machine_voice_limit_hq`: integer (default: **4**) * `time_machine_use_legacy`: boolean (default: **false**) **DFD** * `dfd_buffersize` : integer (default: **60**) * `background_loading`: boolean (default: **true**) **Controller** * `cc_64_mode` : cc64_modes (default: **“ pedal_and_cc”**) * `use_cc_120_123`: boolean (default: **true**) * `use_cc_7_10`: boolean (default: **true**) * `cc_7_range`: integer (default: **0**) **Snapshots** * `show_factory_snapshots` : boolean (default: **true**) * `factory_snapshot_path`: string (default: depends on instrument, or **nil**) * `user_snapshot_path`: string (default: depends on instrument, or **nil**) **Info** * `info_icon` : integer (default: **28**) * `info`: string (default: **"(null)"**) * `info_author`: string (default: **“ Kontakt”**) * `info_url`: string (default: **“(null)”**) Individual entries of this table can be omitted. In that case the default value is used. ``` -------------------------------- ### get_zone_sample_channels Function Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Retrieves the number of audio channels in the sample loaded in the specified zone. ```lua get_zone_sample_channels(instrument_idx: integer, zone_idx: integer) -> integer? ``` -------------------------------- ### Filesystem API Access Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/filesystem The Filesystem API is accessed through the global `Filesystem` table. All functions and constants must be prefixed with `Filesystem.`. ```APIDOC ## Filesystem API Access The Filesystem API is defined in the global table `Filesystem`, i.e. all constants and functions need to be prefixed with that name. For example. ```lua print(Filesystem.exists(Kontakt.script_path)) -- also works kt = Kontakt fs = Filesystem print(fs.exists(kt.script_path)) ``` ``` -------------------------------- ### Link Resource Container Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/utility Links an existing resource container to an instrument. The '.nkr' extension is added automatically if not present. The 'Resources' folder does not need to exist for this command. ```lua link_resource_container(instrument_idx: integer, filename: string) ``` -------------------------------- ### Set Sample Loop Mode Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Sets the playback mode for the specified zone's loop. See `sample_loop_modes`. ```APIDOC ## set_sample_loop_mode ### Description Sets the playback mode for the specified zone's loop. ### Signature ``` set_sample_loop_mode(instrument_idx: integer, zone_idx: integer, loop_idx: integer, mode: string) ``` ``` -------------------------------- ### join(paths ... : string) -> string Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/filesystem Concatenates multiple path components using the platform-dependent separator. ```APIDOC ## join ```lua join(paths ... : string) -> string ``` ### Description Concatenating paths using the platform dependent separator. ### Example ```lua local fs = Filesystem local script = fs.join(Kontakt.script_path, Kontakt.script_file) assert(fs.exists(script)) ``` ``` -------------------------------- ### Set Multi Name Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/multi Sets a new name for the current Multi. Accepts a string representing the desired name. ```lua set_multi_name(name: string) ``` -------------------------------- ### Solo Instrument Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Enables or disables solo mode for the specified instrument. ```lua set_instrument_solo(instrument_idx: integer, value: bool) ``` -------------------------------- ### Join and Check Path Existence Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/filesystem Concatenates script path and file name using the platform-dependent separator and asserts its existence. Requires the 'Filesystem' module. ```lua local fs = Filesystem local script = fs.join(Kontakt.script_path, Kontakt.script_file) assert(fs.exists(script)) ``` -------------------------------- ### extension(path: string) -> string Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/filesystem Returns the extension of the given path. ```APIDOC ## extension ```lua extension(path: string) -> string ``` ``` -------------------------------- ### add_zone Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Adds a new zone to an instrument and returns its index. The new zone is initialized with the specified sample file. ```APIDOC ## add_zone ### Description Adds a new zone to an instrument and returns its index. ### Method Signature `add_zone(instrument_idx: integer, group_idx: integer, filename: string) -> integer` ### Parameters * **instrument_idx** (integer) - The index of the instrument. * **group_idx** (integer) - The index of the group to which the zone will be added. * **filename** (string) - The path to the sample file for the new zone. ### Returns * (integer) - The index of the newly added zone. ``` -------------------------------- ### Save Snapshot Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Saves the current state of the instrument as a snapshot to a specified absolute file path. ```Kontakt Script save_snapshot(instrument_idx: integer, filename: string) ``` -------------------------------- ### Set Sample Loop Tuning Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/zone Sets the tuning offset for a specified zone's loop in semitones. The range is -12.0 to 12.0. ```python set_sample_loop_tune(instrument_idx: integer, zone_idx: integer, loop_idx: integer, tune: float) ``` -------------------------------- ### factory_path Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/options Returns the Kontakt factory data path, which contains wavetables, NKP presets, and so on. ```APIDOC ## factory_path ### Description Returns the Kontakt factory data path (contains wavetables, NKP presets, and so on). ### Type string ``` -------------------------------- ### Detect Pitch - Kontakt API Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/music-information-retrieval--mir- Analyzes an audio file to detect its fundamental frequency (MIDI pitch). Returns the detected MIDI pitch or nil if detection fails. ```lua detect_pitch(file: string) -> float? ``` -------------------------------- ### Set Instrument Script Source Source: https://native-instruments.com/ni-tech-manuals/kontakt-api-reference-manual/en/instrument Assigns the script source code by providing an absolute file path. ```lua set_instrument_script_source(instrument_idx: integer, script_idx: integer, source: string) ```