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 engine parameter.
here goes the engine parameter variable. Basically you can consider the engine parameter variable like an address – house number or place – to tell Kontakt what to control at all. For example the variable $ENGINE_PAR_VOLUME addresses all volumes (see image). Via group, slot, generic you define exactly which volume you like to address of which more 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”.
here goes the value you “send” to the engine. In most cases it’s any integer between 0 to 1000000. Kontakt translates this value into any engine specific value. So 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.
Another example: with $ENGINE_PAR_PAN, 0 would be the very left and 1000000 the very right
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 white or light-gray areas. (see image below).
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.
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_mod(<group-idx>,<mod-name>) If we want to address LFO’s or Envelopes or other modulators we need to the find_mod() command. This will be explained in another tutorial.
-1 for any other applications like Volume or Pan (outside buses)
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
Attack Rate – AEG
this knob controls the Attack rate of the default AEG of the first group (with index 0). Simply create a new instrument and copy this code into your script tab
on init declare ui_knob $Attack (0,1000000,100) end on on ui_control ($Attack) set_engine_par($ENGINE_PAR_ATTACK,$Attack,0,find_mod(0,"ENV_AHDSR"),-1) end on