Skip to main content

Engine Parameter Commands

get_mod_idx()

get_mod_idx(<group-index>, <mod-name>)

Returns the slot index of an internal modulator or external modulation slot

<group-index>

The index of the group

<mod-name>

The name of the internal (LFO, envelope, step modulator...) or external (velocity, key position, mono aftertouch...) modulator.

Each modulator has a predefined name, based on its type.

This name can be changed when the Script Editor's text edit area is opened, then right-clicking on the modulator.

Examples

on init
    declare $grp_idx := 0
    declare $env_idx

    $env_idx := get_mod_idx($grp_idx, "VOL_ENV")

    declare ui_knob $Attack (0, 1000000, 1)

    $Attack := get_engine_par($ENGINE_PAR_ATTACK, $grp_idx, $env_idx, -1)

    set_knob_unit($Attack, $KNOB_UNIT_MS)
    set_knob_label($Attack, get_engine_par_disp($ENGINE_PAR_ATTACK, $grp_idx, $env_idx, -1))
end on

on ui_control ($Attack)
    set_engine_par($ENGINE_PAR_ATTACK, $Attack, $grp_idx, $env_idx, -1)
    set_knob_label($Attack, get_engine_par_disp($ENGINE_PAR_ATTACK, $grp_idx, $env_idx, -1))
end on

Controlling the attack time of the volume envelope of the first group. Note: the envelope has been manually renamed to "VOL_ENV"

on init
    declare $count
    declare $mod_idx

    $mod_idx := get_mod_idx(0, "VEL_VOLUME")

    declare ui_slider $VelAmt (0, 1000000)

    if ($mod_idx # $NI_NOT_FOUND)
        $VelAmt := get_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY, 0, $mod_idx, -1)
    end if

    make_persistent($VelAmt)
end on

on ui_control ($VelAmt)
    $count := 0
    while($count < $NUM_GROUPS)
        $mod_idx := get_mod_idx($count, "VEL_VOLUME")

        if ($mod_idx # $NI_NOT_FOUND)
            set_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY, $VelAmt, $count, $mod_idx, -1)
        end if

        inc($count)
    end while
end on

Creating a slider which controls the velocity to volume modulation intensity of all groups, if they exist

See Also

get_target_idx()

set_engine_par()

get_target_idx()

get_target_idx(<group-index>, <mod-index>, <target-name>)

Returns the modulation target slot index of an internal modulator

<group-index>

The index of the group

<mod-index>

The slot index of an internal modulator (LFO, envelope, step modulator...). Can be retrieved with get_mod_idx(<group-idx>, <mod-name>)

<target-name>

The name of the modulation target slot. Each modulation target slot has a predefined name, based on its type and the parameter it targets.

This name can be changed when the Script Editor's text edit area is opened, then right-clicking on the modulation target slot.

Examples

on init
    declare $mod_idx
    declare $target_idx

    $mod_idx := get_mod_idx(0, "FILTER_ENV")
    $target_idx := get_target_idx(0, $mod_idx, "FILTER_ENV > CUTOFF")

    declare ui_knob $FilterEnv (-1000, 1000, 10)

    set_knob_unit($FilterEnv, $KNOB_UNIT_PERCENT)

    make_persistent($FilterEnv)
end on

on ui_control ($FilterEnv)
    if ($mod_idx # $NI_NOT_FOUND and $target_idx # $NI_NOT_FOUND)
        set_engine_par($ENGINE_PAR_MOD_TARGET_MP_INTENSITY, 500000 + ($FilterEnv * 500), 0, $mod_idx, $target_idx)
    end if
end on

Controlling the envelope to filter cutoff modulation amount in the first group. Note: the filter envelope has been manually renamed to "FILTER_ENV", and the target to "FILTER_ENV > CUTOFF".

See Also

get_mod_idx()

set_engine_par()

get_engine_par()

get_engine_par(<parameter>, <group>, <slot>, <generic>)

Returns the value of a specific engine parameter

<parameter>

Specifies the engine parameter by using one of the built in engine parameter variables.

<group>

The index (zero-based) of the group in which the specified parameter resides.

If the specified parameter resides on an Instrument level, enter -1.

<slot>

The slot index (zero-based) of the specified parameter. It applies only to group/instrument effects, modulators and modulation intensities.

For group/instrument effects, this parameter specifies the slot in which the effect resides (zero-based).

For modulators and modulation intensities, this parameters specifies the index which you can retrieve by using:

get_mod_idx(<group-idx>, <mod-name>)

For all other applications, set this parameter to -1.

<generic>

For instrument effects, this parameter distinguishes between:

$NI_SEND_BUS: Send Effect

$NI_INSERT_BUS: Insert Effect

$NI_MAIN_BUS: Main Effect

For buses, this parameter specifies the actual bus:

$NI_BUS_OFFSET + [0-15] one of the 16 buses

For internal modulators, this parameter specifies the modulation slider which you can retrieve by using:

get_target_idx(<group-idx>, <mod-idx>, <target-name>)

For Step Modulator, this parameter specifies the step whose value is to be retrieved by using $ENGINE_PAR_STEPMOD_STEP_VALUE.

For all other applications, set this parameter to -1

Examples

on init
    declare $i

    declare ui_label $label (2, 6)
    set_text($label,"Release Trigger Groups:")

    while ($i < $NUM_GROUPS)
        if (get_engine_par($ENGINE_PAR_RELEASE_TRIGGER, $i, -1, -1) = 1)
            add_text_line($label, group_name($i) & " (Index: " & $i & ")")
        end if

        inc($i)
    end while
end on

Output the name and index of release trigger group

on init
    declare ui_label $label (2, 6)
    declare ui_button $Refresh

    declare $i
    declare !effect_name[128] 
    !effect_name[$EFFECT_TYPE_NONE] := "None"
    !effect_name[$EFFECT_TYPE_PHASER] := "Phaser" 
    !effect_name[$EFFECT_TYPE_CHORUS] := "Chorus" 
    !effect_name[$EFFECT_TYPE_FLANGER] := "Flanger" 
    !effect_name[$EFFECT_TYPE_REVERB] := "Reverb" 
    !effect_name[$EFFECT_TYPE_DELAY] := "Delay" 
    !effect_name[$EFFECT_TYPE_IRC] := "Convolution"
    !effect_name[$EFFECT_TYPE_GAINER] := "Gainer"

    while ($i < 8)
        add_text_line($label, "Slot: " & $i + 1 & ": " & ...
                      !effect_name[get_engine_par($ENGINE_PAR_SEND_EFFECT_TYPE, -1, $i, -1)])

        inc($i)
    end while
end on

on ui_control ($Refresh)
    set_text($label, "")

    while ($i < 8)
        add_text_line($label, "Slot: " & $i + 1 & ": " & ...
                      !effect_name[get_engine_par($ENGINE_PAR_SEND_EFFECT_TYPE, -1, $i, -1)])

        inc($i)
    end while

    $Refresh := 0
end on

Output the effect types of all eight send effect slots

See Also

Module Status Retrieval

get_engine_par_disp()

get_engine_par_disp(<parameter>, <group>, <slot>, <generic>)

Returns the displayed string of a specific engine parameter

<parameter>

Specifies the engine parameter.

<group>

The index (zero-based) of the group in which the specified parameter resides.

If the specified parameter resides on an Instrument level, enter -1.

<slot>

The slot index (zero-based) of the specified parameter. It applies only to group/instrument effects, modulators and modulation intensities.

For group/instrument effects, this parameter specifies the slot in which the effect resides (zero-based).

For modulators and modulation intensities, this parameters specifies the index which you can retrieve by using:

get_mod_idx(<group-idx>, <mod-name>)

For all other applications, set this parameter to -1.

<generic>

This parameter applies to instrument effects and to internal modulators.

For instrument effects, this parameter distinguishes between:

$NI_SEND_BUS: Send Effect

$NI_INSERT_BUS: Insert Effect

$NI_MAIN_BUS: Main Effect

For buses, this parameter specifies the actual bus:

$NI_BUS_OFFSET + [0-15] one of the 16 buses

For internal modulators, this parameter specifies the modulation slider which you can retrieve by using:

get_target_idx(<group-idx>, <mod-idx>, <target-name>)

For Step Modulator, this parameter specifies the step whose value is to be read by using $ENGINE_PAR_STEPMOD_STEP_VALUE.

For all other applications, set this parameter to -1

Examples

on init
    declare $i

    declare ui_label $label (2, 6)
    set_text($label, "Group Volume Settings:")

    while ($i < $NUM_GROUPS)
        add_text_line($label, group_name($i) & ": " & get_engine_par_disp($ENGINE_PAR_VOLUME, $i, -1, -1) & " dB")

        inc($i)
    end while
end on

Query the group volume settings in an instrument

get_voice_limit()

get_voice_limit(<voice-type>)

Returns the voice limit for the Time Machine Pro mode of the source module

<voice-type>

The voice type, can be one of the following:

$NI_VL_TMPRO_STANDARD {Standard Mode}

$NI_VL_TMRPO_HQ {High Quality Mode} 

Examples

on init
    declare ui_label $label (3, 2)

    add_text_line($label, "Standard Voice Limit: " &  get_voice_limit($NI_VL_TMPRO_STANDARD))
    add_text_line($label,"HQ Voice Limit: " & get_voice_limit($NI_VL_TMPRO_HQ))
end on

Displaying TM Pro voice limits

See Also

set_voice_limit()

output_channel_name()

output_channel_name(<output-number>)

Returns the channel name for the specified output

<output-number>

The number of the output channel (zero-based, i.e. the first output is 0)

Examples

on init
    declare $i

    declare ui_menu $menu
    add_menu_item($menu, "Default", -1)

    $i := 0
    while ($i < $NUM_OUTPUT_CHANNELS)
        add_menu_item($menu, output_channel_name($i), $i)

        inc($i)
    end while

    $menu := get_engine_par($ENGINE_PAR_OUTPUT_CHANNEL, 0, -1, -1)
end on

on ui_control ($menu)
    set_engine_par($ENGINE_PAR_OUTPUT_CHANNEL,$menu, 0, -1, -1)
end on

Mirroring the output channel assignment menu of the first group

See Also

General: $NUM_OUTPUT_CHANNELS, $ENGINE_PAR_OUTPUT_CHANNEL

set_engine_par()

set_engine_par(<parameter>, <value>, <group>, <slot>, <generic>)

Control various KONTAKT parameters and buttons

<parameter>

The engine parameter to be modified, e.g. $ENGINE_PAR_CUTOFF

<value>

The value to which the specified parameter is set.

The range of values is always 0 to 1000000, except for switches in which case it is 0 or 1.

<group>

The index (zero-based) of the group in which the specified parameter resides.

If the specified parameter resides on an Instrument level, enter -1.

Buses and Main FX also reside on Instruments level, so you must set <group> to -1 if you want to address a bus.

<slot>

The slot index (zero-based) of the specified parameter. This applies only to group/instrument effects, modulators and modulation intensities.

For group/instrument effects, this parameter specifies the slot in which the effect resides (zero-based).

For modulators and modulation intensities, this parameters specifies the index which you can retrieve by using:

get_mod_idx(<group-idx>, <mod-name>)

For all other applications, set this parameter to -1.

<generic>

This parameter applies to instrument effects and to internal modulators.

For instrument effects, this parameter distinguishes between:

$NI_SEND_BUS: Send Effect

$NI_INSERT_BUS: Insert Effect

$NI_MAIN_BUS: Main Effect

For buses, this parameter specifies the actual bus:

$NI_BUS_OFFSET + [0-15] one of the 16 buses

For internal modulators, this parameter specifies the modulation slider which you can retrieve by using:

get_target_idx(<group-idx>, <mod-idx>, <target-name>)

For Step Modulator, this parameter specifies the step whose value is to be changed by using $ENGINE_PAR_STEPMOD_STEP_VALUE.

For all other applications, set this parameter to -1

Examples

on init
    declare ui_knob $Volume (0, 1000000, 1000000)
end on

on ui_control ($Volume)
    set_engine_par($ENGINE_PAR_VOLUME, $Volume, -1, -1, -1)
end on

A knob controls the instrument volume

on init
    declare ui_knob $Freq (0, 1000000, 1000000)
    declare ui_button $Bypass
end on

on ui_control ($Freq)
    set_engine_par($ENGINE_PAR_CUTOFF, $Freq, 0, 0, -1)
end on

on ui_control ($Bypass)
    set_engine_par($ENGINE_PAR_EFFECT_BYPASS, $Bypass, 0, 0, -1)
end on

Controlling the cutoff and bypass button of any filter module in the first slot of the first group

on init
    declare ui_knob $Knob (-1000, 1000, 10)

    declare $mod_idx
    $mod_idx := get_mod_idx(0, "FILTER_ENV")

    declare $target_idx
    $target_idx := get_target_idx(0, $mod_idx, "ENV_AHDSR_CUTOFF")
end on

on ui_control ($Knob)
    set_engine_par($ENGINE_PAR_MOD_TARGET_MP_INTENSITY, $Knob * 1000, 0, $mod_idx, $target_idx)
end on

Controlling the filter envelope amount of an envelope to filter cutoff modulation in the first group. Note: the filter envelope has been manually renamed to "FILTER_ENV".

on init
    declare ui_knob $Vol (0, 1000000, 1000000)
end on

on ui_control ($Vol)
    set_engine_par($ENGINE_PAR_VOLUME, $Vol, -1, -1, $NI_BUS_OFFSET + 15)
end on

Controlling the amplifier volume of 16th bus

set_voice_limit()

set_voice_limit(<voice-type>, <value>)

Sets the voice limit for the Time Machine Pro mode of the source module

<voice-type>

The voice type, can be one of the following:

$NI_VL_TMPRO_STANDARD {Standard Mode}

$NI_VL_TMRPO_HQ {High Quality Mode}

<value>

The voice limit of the Time Machine Pro mode

Remarks

  • Changing voice limits is an asynchronous operation. This means, that one cannot reliably access the newly allocated voices immediately after instantiation. To resolve this, the set_voice_limit() command returns an $NI_ASYNC_ID and triggers the on async_complete callback.

Examples

on init
    declare $change_voices_id

    declare ui_value_edit $Voices (1, 8, 1)

    make_persistent($Voices)
end on

on ui_control ($Voices)
    $change_voices_id := set_voice_limit($NI_VL_TMPRO_STANDARD, $Voices)
end on

on async_complete
    if ($NI_ASYNC_ID = $change_voices_id)
        message("New TMPro Std Voice Limit: " & get_voice_limit($NI_VL_TMPRO_STANDARD))
    end if
end on

Changing TM Pro voice limits

See Also

get_voice_limit()