Posted by & filed under KSP Scripting (NI Kontakt) - Tutorials, KSP: Basics.

The set_engine_par() command is used to control or set almost any engine parameters like volume, pan, tune, fx, lfo’s, envelopes and more. It is mostly used in combination with the on ui_control callback whenever we use custom knobs or buttons to control any FX.

Mechanics

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

<parameter>

here goes the engine parameter variable. Basically you can consider the engine parameter variable like an address – house number – to tell Kontakt what to control at all. For example the variable $ENGINE_PAR_VOLUME addresses the volume either inside the amplifier module, inside the bus module or the main volume – depending on the other settings like group, slot and generic (see below). All engine parameters start with the prefix “$ENGINE_PAR_” There are many many engine parameter variables and you find them all listed in your KSP reference guide under  “Engine Parameter Variables” so there’s no need to list them here.

 

<value>

here goes the value you “send” to the engine. It’s any integer between 0 to 1000000 in most of the cases. Kontakt translates this value into any engine specific value. So in our example 0 would set the Volume to -inf and 1000000 sets the volume to +12.0 dB any other value can in this case also produce decimals like 6.3 dB. Sometimes it is required to do some calculations e.g. if you want to set the volume to exactly 0 dB. (For $ENGINE_PAR_PAN, 0 would be the very left and 1000000 the very right)

 

<group>

this can also be considered as an address. This time it tells Kontakt on which level to look for the engine parameter.

Any value >= 0 addresses a group you have created (inside the groups tab). It’s also any brown area inside the edit mode. LFOs or envelopes are also on a group level.

-1 addresses an Instrument FX or any Bus parameter. It’s all whitish or gray areas. (see image below).

<slot>

addresses the slot in which the FX resides.

“0 – 7”  to address a FX slot. There are always 8 slots on each level (group, bus or instrument level), starting with zero. So if we want to set a parameter in the first FX slot, the slot value would be “0”.

find_mod() if we want to address LFOs, Envelopes  or other modulators.

-1 for any other application like the Volume which is not in any FX slot.

<generic>

this parameter finally distinguishes between the engine types and addresses send FX, insert FX, modulators, any paramter inside buses or other paramters outside like vol, pan, tune..

1 for insert FX

0 for send FX

$NI_BUS_OFFSET + [0-15] to address the paramters inside buses. $NI_BUS_OFFSET is a variable given by Kontakt. You simply need to add the bus number then. Like “$NI_BUS_OFFSET + 0” addresses the first bus.

find_target(group-idx,mod-idx,target-name) for internal modulators like LFOs, envelopes etc.

-1 for any other applications like Volume or Pan (outside buses)

Examples

Bypass Button

this button bypasses all instrument insert FX in any slot.

on init 
    declare ui_switch $bypass
    declare $count
    make_perfview
end on

on ui_control($bypass)
    $count := 0
    while ($count < 8)
        set_engine_par($ENGINE_PAR_EFFECT_BYPASS,$bypass,-1,$count,-1)
        inc($count)
    end while
end on

Volume Knob (all groups)

this knob changes the volume of all groups simultaneously

on init 
    declare ui_knob $volume(0, 1000000,10000)
    declare $count
    make_perfview
end on
on ui_control($volume)
    $count := 0
    while ($count < $NUM_GROUPS)
        set_engine_par($ENGINE_PAR_VOLUME,$volume,$count,-1,-1)
        inc($count)
    end while
end on

Volume Knob (main Volume)

this knob changes the main volume of our instrument

on init 
    declare ui_knob $volume(0, 1000000,10000)
    declare $count
    make_perfview
end on
on ui_control($volume)
    set_engine_par($ENGINE_PAR_VOLUME,$volume,-1,-1,-1)
end on

Volume Knob (Bus 1)

this knob changes the volume of bus 1

on init 
    declare ui_knob $volume(0, 1000000,10000)
    declare $count
    make_perfview
end on
on ui_control($volume)
    set_engine_par($ENGINE_PAR_VOLUME,$volume,-1,-1,$NI_BUS_OFFSET + 0)
end on
 

Leave a Reply

Your email address will not be published. Required fields are marked *