# Inserting an FX into Instrument (Send or Insert) FX with a script



## jkleban (Dec 13, 2016)

I have read the manual, scoured the internet and came up with nothing. I have figured out how to bypass a effect in a group, change paramaters of an effect already loaded into a slot but not how to add or remove effects from a slot.

The code I am using to insert an effect is as follows:

on ui_control ( $FX_T1_S1)
$group_fx_slot := 1
$count := 0
while ($count < ($num_of_groups/$num_of_sources))
$ cur_group := %mic_groups[$count}]
set_engine_par($ENGINE_PAR_EFFECT_TYPE,14,$cur_group,$group_fx_slot,-1) 
inc($count)
end while 
end on

The control $FX_T1_S1 is a menu for slot 1, set engine par, effect type was hardcoded for the test of putting effect 14 into slot 1 for the groups contained in the array %mic_groups.

I get NO effects inserted into 0 relative slot 1 of the group inserts.

Thanks in advance for any insights or help.

PS - I assume that I will be able to remove an effect using 0 as the value of $ENGINE_PAR_EFFECT_TYPE.


----------



## d.healey (Dec 13, 2016)

As far as I'm aware you can't insert fx via scripts, unless this is a recent addition to Kontakt


----------



## jkleban (Dec 13, 2016)

Dan, thanks for your answer. Not what I wanted to hear but at least I can stop chasing a GHOST. That puts the cabash on my mixer script. I want to disable the wrench completely and let the user insert FX into slots so that the end user could control the order in which effects were applied. The mixer idea had to be on groups, since I used different sources for groups of instruments, I needed this feature for FX on these groups. So, now it looks like I will have to pre load the effects into these slots and just provide the ability to bypass effect slots.

Plus, I am developing in 4.2 and not 5 for folks who hadn't upgraded yet. In studying the literature, I assume that an instrument insert is for all groups and perhaps in version 5, I can work something out using busses (but that will be at a later date).


----------



## EvilDragon (Dec 13, 2016)

d.healey said:


> As far as I'm aware you can't insert fx via scripts, unless this is a recent addition to Kontakt



Yes, you can, and yes, it is. Since version 5.5.

This is one of a bit more complex parts of KSP and is not for the faint of heart (one needs to know how to work with async callback and take care on how FX are initialized, take care about automation labels if they're used, FX bypass states, etc.) Much less a beginner. There is an example in KSP Reference, though.


----------



## d.healey (Dec 13, 2016)

EvilDragon said:


> Yes, you can, and yes, it is. Since version 5.5


That makes sense, I haven't kept up with the new scripting stuff, I'm still in K4 land most of the time


----------



## jkleban (Dec 13, 2016)

Well,

This news is making me re-think my strategy of dev in 4.2.... I guess if someone owns Kontakt, they really wouldn't have a reason not to upgrade for free to the latest and greatest?

Thanks for the info.


----------



## EvilDragon (Dec 13, 2016)

I think that by now majority of Kontakt population is on K5...


----------



## jkleban (Dec 14, 2016)

Yes ED, I concur about K5.... so, the following code does NOTHING when executed, I was expecting a PHASER to show up in GROUP 0, SLOT 1 in the GROUP INSERTFX section.

set_engine_par($ENGINE_PAR_EFFECT_TYPE, $EFFECT_TYPE_PHASER, 0,1,-1)

I am testing this in Kontakt 5.6.5. I am missing something? Is there some prerequisites that need to be fulfilled. Do I need the ASYNC CB just for this test?

Thanks for taking a look.


----------



## EvilDragon (Dec 14, 2016)

Phaser is a send effect and as such cannot be loaded into group FX. Nor can any other send effect. You can only load it in an instrument bus, or main insert FX, or (naturally) send FX.


And yes, async callback should be used every time when loading FX from KSP, similarly to how it's shown in an example for async_complete callback in KSP reference (page 3).


----------



## jkleban (Dec 14, 2016)

OK, thanks I got it now. Realize I need to better understand the signal routing scheme of the KONTAKT engine.


----------



## jkleban (Dec 14, 2016)

OK then I would expect the following to insert the REVERB into the first slot of the instrument SEND FX:

set_engine_par($ENGINE_PAR_EFFECT_TYPE,$EFFECT_TYPE_REVERB, -1,0,0)

Do I have this right now?


----------



## EvilDragon (Dec 14, 2016)

That should work yeah.


----------



## jkleban (Dec 14, 2016)

I do feel foolish. I get nothing with that statement. The FX slot stays empty?


----------



## polypx (Dec 14, 2016)

$ENGINE_PAR_SEND_EFFECT_TYPE,,, you need the "SEND" for sends


----------



## jkleban (Dec 14, 2016)

Why did NI have to make this so confusing? I am sure that you old timers find this second nature, but trying to learn at version 5.6.5 creates a huge learning curve to get up to speed.

Thanks!!!!!


----------



## EvilDragon (Dec 14, 2016)

Nobody said scripting was easy.


----------



## olmerk (Jul 3, 2020)

Is it a known bug? Actual image of a loaded FX in the slot doesn't appear or renew until I load/eject manually any other FX in any other slot. I was confused why my simple script loaded effects like randomly, until I found this issue with FX image.


----------



## EvilDragon (Jul 3, 2020)

That sounds more like a scripting error than anything else, to me.


----------



## olmerk (Feb 28, 2021)

Is it necessary after loading FX via script to restart it by clicking the exclamation mark? Because right now after pressing GUI button I don't see that a chosen effect is inserted in an empty slot. This happens only after script restart.


----------



## EvilDragon (Mar 1, 2021)

No. This is just a GUI refresh bug. The effect does get loaded.


----------

