K4 - About Modulators

VST, AU, AAX, CLAP, etc. Plugin Virtual Instruments Discussion
Locked New Topic
RELATED
PRODUCTS
Kontakt

Post

Hi

When a new instrument is created, on the "Amplifier" section, there's already a AHDSR mod (with name "ENV_AHDSR_VOLUME"). On the "Group InsertFX" section, I do insert a "2-pole LP" (LP 2) filter and then add a AHDSR mod to it, which has as name "ENV_AHDSR_CUTOFF".

Now I load the first example for find_mod that appear on the KSP manual reference:

Code: Select all

on init
	declare ui_knob $Intensity (-100,100,1)

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

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

on ui_control ($Intensity)
	if ($Intensity < 0)
		set_engine_par ($MOD_TARGET_INVERT_SOURCE, 1,0,$mod_idx,$target_idx)
	else
		set_engine_par ($MOD_TARGET_INVERT_SOURCE, 0,0,$mod_idx,$target_idx)
	end if
	set_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY, abs($Intensity*10000),0,$mod_idx,$target_idx)
end on
The thing here, is that the knob that it creates moves the slider of the mod on the Amplifier section "ENV_AHDSR_VOLUME", not the one on the Group InsertFX section, which has the name specified on target_idx variable, "ENV_AHDSR_CUTOFF".

It shows that the name thing doesn't work at all with "internal mods", but only with "external" (PB,VEL, etc.).

With internal ones, it sort them a number as they are added, like slots. The mod that is at the amplifer section is the number 0, and the new one is the 1. If its created another one on one of those sections, or another on the Source section, would have the number 2 and so on. Replacing "$mod_idx, $target_idx" with "number,-1" with give absolute control.

Example :

Code: Select all

on init
	declare ui_knob $Intensity (-100,100,1)
end on

on ui_control ($Intensity)
	if ($Intensity < 0)
		set_engine_par ($MOD_TARGET_INVERT_SOURCE, 1,0, 1,-1)
	else
		set_engine_par ($MOD_TARGET_INVERT_SOURCE, 0,0, 1,-1)
	end if
	set_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY, abs($Intensity*10000),0, 1,-1)
end on
That will control the intensity slider created on the "Group InsertFX". If that mod is deleted, the knob will move nothing, having that "slot" empty until a new mod be inserted on one of the sections, and then the number "1" will be assigned to it.

It can be applied on $ENGINE_PAR_MOD_TARGET_INTENSITY, $ENGINE_PAR_INTMOD_INTENSITY or $ENGINE_PAR_EXTMOD_INTENSITY (which is a parameter for use with external modulators that isn't mentioned on the KSP reference manual at all).
The thing here, is that using the $ENGINE_PAR_INTMOD_INTENSITY and $ENGINE_PAR_EXTMOD_INTENSITY you don't need the create the conditional

Code: Select all

if ($Intensity < 0)...
for turn on and off the invert button, it just do it automatic.

I would really loved to see the internal mods work with the names assigned, but for internal modulators, its totally useless as that example on the manual. At least its mentioned on the newer versions the paramenter $ENGINE_PAR_INTMOD_TYPE (which I find out by myself that existing a $ENGINE_PAR_INTMOD_SUBTYPE there should be a TYPE parameter!), because it doesn't appear at all on the K4's KSP pdf. With that, and $INTMOD_TYPE_NONE is possible to retrieve if internal mods are or not inserted.

That's all for now.
Cheers
Last edited by hellishvictor on Tue Apr 16, 2019 1:08 am, edited 1 time in total.

Post

I am sure that NI will not be updating Kontakt 4 or its scripting engine again.
DarkStar, ... Interesting, if true
Inspired by ...

Post

DarkStar wrote: Mon Apr 15, 2019 3:08 pm I am sure that NI will not be updating Kontakt 4 or its scripting engine again.
K4 not, for sure... they call it now K6 and its more powerful as far as I know :hihi:

Post

Internal mods do work with assigned names. Your code has some assumptions and because of them it might not work in all cases.

For example, in init callback, you have:

Code: Select all

	$mod_idx := find_mod(0,"FILTER_ENV")
This makes an assumption that the returned value for modulator named FILTER_ENV from group 1 will be the same across all groups, which most definitely doesn't have to always be the case. However your example only uses group ID 0 so at least for that case it should work. One other thing, you have this variable called $group but in the code you posted we don't see its value or declaration.

You need to query find_mod() in UI callback where you set a particular modulator's parameter. In short, just having the result of find_mod() stored in a variable done in init callback is not a complete solution for all cases.

When I do this, everything works just fine. To be more exact: load up a filter, add an envelope to it, rename the modulator to FILTER ENV, and rename mod amount strip to FILTER ENV -> CUTOFF. This code works perfectly fine:

Code: Select all

set_engine_par($ENGINE_PAR_INTMOD_INTENSITY, $value, 0, find_mod(0, "FILTER ENV"), find_target(0, find_mod(0, "FILTER ENV"), "FILTER ENV -> CUTOFF"))

Post

EvilDragon wrote: Mon Apr 15, 2019 9:23 pm FILTER_ENV from group 1
From group 0, not 1.
EvilDragon wrote: Mon Apr 15, 2019 9:23 pm One other thing, you have this variable called $group but in the code you posted we don't see its value or declaration.
Fixed, thank you for that! Now you know that is possible to know if there is or not internal modulators :)

Locked

Return to “Instruments”