# Group insert effects and sliders



## sneakyalien (Sep 21, 2010)

Hi All,
Can anyone tell me how to reference a filter that I have in slot 0 in the GROUP INSERT EFFECTS?
I have set up a slider and want the slider to control cutoff.
Also is it possible to have a switch with say 5 different positions?
The reason I ask is I would like to set up a switch which when moved would select say 5 different LFO shapes from sin to random depending upon the position of the switch just like on a real synthesiser.
I still cannot find the manual for Kontact 4 scripting on NI's website,I have logged into my user area but cannot find it anywhere.
Thanks guys.
Steve.


----------



## sneakyalien (Sep 21, 2010)

Hi,I think I have figured it-I have set 3 parameter to 0 to denote group effects.
Still wondering about the 5 position switch.


----------



## EvilDragon (Sep 21, 2010)

set_engine_par($ENGINE_PAR_CUTOFF,$Cutoffslidervalue,$groupindex,-1,-1)

K4 KSP -> http://www.mediafire.com/?2tg2ijosccg883k

About LFO, take a look at this NKI and script I did (K4.1.1 monolith!) -> http://www.mediafire.com/?1650scul554ze0v




Take note that using find_mod() is kinda tricky, you have to rename the modulators if you use more of the same type (for ex. using a volume, pitch and pan LFO), and you rename them by right-clicking the modulator surface, but your Script Editor edit window MUST be open! Strange, I know, but that's Kontakt.


----------



## TechLo (Sep 21, 2010)

And don't be surprised if a few renamed modulators lose their names somewhere along the way, or if you lose the modulator itself, lol. If you have a modulator selected and then go back into the script editor and delete something, the modulator will be deleted. As a general rule, never have anything selected when you're done working with it when going back into your script. Better yet, never code in the K4 script window -- always use the KScript editor and paste your compile script in via the clipboard.


----------



## sneakyalien (Sep 21, 2010)

Thanks,will check it all out and hopefully be able to understand it all.
best regards,
Steve.


----------



## sneakyalien (Sep 21, 2010)

I don't seem to be able to download your script-Just get the green progress bar in windows explorer going about half way and then nothing happens.Is the file definitley still available for download?
Thanks


----------



## sneakyalien (Sep 21, 2010)

I have set up 3 switches with L.E.D pictures and named them lfo,manual and adsr and I have cobbled together this script.
on ui_control ($adsrfilter_switch)

$manfilter_switch :=0
$lfo_switch :=0
set_control_par_str(get_ui_id($lfo_switch),$CONTROL_PAR_TEXT,"")
set_control_par_str(get_ui_id($lfo_switch),$CONTROL_PAR_PICTURE,"pv_vintage_drums_led")
move_control_px($lfo_switch,($GRID_X * 1) +403, ($GRID_Y * 1) + 120)
set_control_par_str(get_ui_id($manfilter_switch),$CONTROL_PAR_TEXT,"")
set_control_par_str(get_ui_id($manfilter_switch),$CONTROL_PAR_PICTURE,"pv_vintage_drums_led")
move_control_px($manfilter_switch,($GRID_X * 1) +415, ($GRID_Y * 1) + 120)
end on

on ui_control ($lfo_switch)
$manfilter_switch :=0
$adsrfilter_switch :=0
set_control_par_str(get_ui_id($manfilter_switch),$CONTROL_PAR_TEXT,"")
set_control_par_str(get_ui_id($manfilter_switch),$CONTROL_PAR_PICTURE,"pv_vintage_drums_led")
move_control_px($manfilter_switch,($GRID_X * 1) +415, ($GRID_Y * 1) + 120)


set_control_par_str(get_ui_id($adsrfilter_switch),$CONTROL_PAR_TEXT,"")
set_control_par_str(get_ui_id($adsrfilter_switch),$CONTROL_PAR_PICTURE,"pv_vintage_drums_led")
move_control_px($adsrfilter_switch,($GRID_X * 1) +427, ($GRID_Y * 1) + 120)
end on


on ui_control ($manfilter_switch)
$adsrfilter_switch :=0
$lfo_switch :=0
set_control_par_str(get_ui_id($lfo_switch),$CONTROL_PAR_TEXT,"")
set_control_par_str(get_ui_id($lfo_switch),$CONTROL_PAR_PICTURE,"pv_vintage_drums_led")
move_control_px($lfo_switch,($GRID_X * 1) +403, ($GRID_Y * 1) + 120)

set_control_par_str(get_ui_id($adsrfilter_switch),$CONTROL_PAR_TEXT,"")
set_control_par_str(get_ui_id($adsrfilter_switch),$CONTROL_PAR_PICTURE,"pv_vintage_drums_led")
move_control_px($adsrfilter_switch,($GRID_X * 1) +427, ($GRID_Y * 1) + 120)
end on

This will display 3 leds and depending upon which one is pressed any remaining leds will show as off.
I don't know if there is a better way of doing this it basically just puts a new picture of an off LED on top of a lit LED picture.


----------



## EvilDragon (Sep 21, 2010)

The file is still definitely there to download... Try again until it works. It should work, totally.


You can have several images coaxed into one PNG file, and then you can use $CONTROL_PAR_PICTURE_STATE to switch between the states. It's a bit more elaborate. Your way isn't wrong either, but having all states of a particular control in one image is totally worth it.


BTW, this is the correct code to use in your situation (I didn't involve placement of controls for clarity):


```
on init
    declare ui_switch $adsrfilter_switch
    declare ui_switch $lfo_switch
    declare ui_switch $manfilter_switch

    set_control_par_str(get_ui_id($lfo_switch),$CONTROL_PAR_TEXT,"")
    set_control_par_str(get_ui_id($lfo_switch),$CONTROL_PAR_PICTURE,"pv_vintage_drums_led")
    set_control_par_str(get_ui_id($manfilter_switch),$CONTROL_PAR_TEXT,"")
    set_control_par_str(get_ui_id($manfilter_switch),$CONTROL_PAR_PICTURE,"pv_vintage_drums_led")
    set_control_par_str(get_ui_id($adsrfilter_switch),$CONTROL_PAR_TEXT,"")
    set_control_par_str(get_ui_id($adsrfilter_switch),$CONTROL_PAR_PICTURE,"pv_vintage_drums_led")
end on

on ui_control ($adsrfilter_switch)
    $manfilter_switch := 0
    $lfo_switch := 0
end on

on ui_control ($lfo_switch)
    $manfilter_switch := 0
    $adsrfilter_switch := 0
end on

on ui_control ($manfilter_switch)
    $adsrfilter_switch := 0
    $lfo_switch := 0
end on
```


----------



## sneakyalien (Sep 21, 2010)

Hi,yeah your script for LED switching is a lot neater and to the point than mine,there is a lot of repitition in mine.
Thanks for your help-Will try downloading your script again.
Thanks,
Steve.


----------



## sneakyalien (Sep 22, 2010)

Hi Evil Dragon,
Downloaded your script and was wondering if it was possible to update multiple groups with it by using a while loop.
I experimented with it but cannot get it to work I ammended the following to it but it does not work .
on ui_control($shape)
select ($shape)
case -1 
$count := 0
while ( $count < $NUM_GROUPS )

inc ($count )


set_engine_par($ENGINE_PAR_LFO_SINE,500000,0,find_mod($count,"LFO_MULTI"),-1)
set_engine_par($ENGINE_PAR_LFO_TRI,500000,0,find_mod($count,"LFO_MULTI"),-1)
set_engine_par($ENGINE_PAR_LFO_RECT,500000,0,find_mod($count,"LFO_MULTI"),-1)
set_engine_par($ENGINE_PAR_LFO_SAW,500000,0,find_mod($count,"LFO_MULTI"),-1)
set_engine_par($ENGINE_PAR_LFO_RAND,500000,0,find_mod($count,"LFO_MULTI"),-1)
end while

I repeated that for all the wave shapes but cannot get it to change the other groups I think it just changes group 0.
I see what you mean about modulators dissapearing,I thought I was going mad last night when looking for a modulator I had set up that had dissapeared. :lol:


----------



## EvilDragon (Sep 22, 2010)

set_engine_par($ENGINE_PAR_LFO_RAND,500000,$count,find_mod($count,"LFO_MULTI"),-1) 

You had set_engine_par directed to group 0 always, but referencing modulators from other groups.

Always have in mind the structure of set_engine_par and what each variable in parentheses does!


----------



## polypx (Sep 22, 2010)

Mario... nice tidy method of controlling the LFO shapes and mod depth. Thanks for a great example!

However, if I assign the same LFO to modulate more than one thing, say Pitch, Filter, and Amplitude... and then want three "depth" knobs.... I get all kinds of errors, and can't seem to find a way to resolve it.

My only solution seems to be to use three LFOs, but I only really want the one.

Have you tried this? Maybe you have a solution?

cheers
Dan


----------



## EvilDragon (Sep 22, 2010)

The modulation intensities have their own assigned name (right-click on a modulator intensity strip when script edit is open)! You should try using those names instead of generic LFO_MULTI here.

I must say I didn't try this out. I would use a separate LFO for everything :D


----------



## sneakyalien (Sep 23, 2010)

Hi all,if a switch was to be implemented to switch off a modulation source should the following code do it?

on ui_control($adsrfilter_switch)
$count := 0
while ($count < $NUM_GROUPS)
set_engine_par($ENGINE_PAR_INTMOD_BYPASS,$adsrfilter_switch,$count,find_mod($count,"filterenvcutoff"),-1)
inc ($count)
end while
end on

I have assigned an ahdsr to a filter and want to be able to switch it off with a switch.
Have downloaded your Script Evil Dragon and it is a cool as fc#k way of controlling LFO's.

Steve.


----------



## EvilDragon (Sep 23, 2010)

That code seems to work, yes. Although I would do it by directly setting the modulation intensity to 0, but this is a good solution as well.


----------

