Volume Groups Kontakt Script Problem

Sampler and Sampling discussion (techniques, tips and tricks, etc.)
Post Reply New Topic
RELATED
PRODUCTS

Post

Hello,
I have set up an instrument with 4 layers.
This script is to control the volume of each layer.
Everything works fine but the problem is that every volume layer control all layers.
Turning for example volume 2 , change the volume of all the all layers , not only of layer 2 as it should be and the same with all other layers.
Thanks in advance for any help!

-----

on init

set_ui_height_px(520)
make_perfview
message("")


declare $wait_time := 800

declare $a
declare $count
$count :=0
declare const $FONT_ID := 3
declare const $MAKE_AUTO_IDS := 1




declare ui_slider $mix_level1(0,1000000)
declare ui_slider $mix_level2(0,1000000)
declare ui_slider $mix_level3(0,1000000)
declare ui_slider $mix_level4(0,1000000)

declare ui_label $lb_mix_level1 (1,1)
declare ui_label $lb_mix_level2 (1,1)
declare ui_label $lb_mix_level3 (1,1)
declare ui_label $lb_mix_level4 (1,1)

set_text($lb_mix_level1,"LAYER1")
set_text($lb_mix_level2,"LAYER2")
set_text($lb_mix_level3,"LAYER3")
set_text($lb_mix_level4,"LAYER4")

declare $last_time_mix_level1
declare $last_time_mix_level2
declare $last_time_mix_level3
declare $last_time_mix_level4

$mix_level1 := _get_engine_par($ENGINE_PAR_VOLUME,0,-1,-1)
$mix_level2 := _get_engine_par($ENGINE_PAR_VOLUME,1,-1,-1)
$mix_level3 := _get_engine_par($ENGINE_PAR_VOLUME,2,-1,-1)
$mix_level4 := _get_engine_par($ENGINE_PAR_VOLUME,3,-1,-1)

set_control_par_str(get_ui_id($mix_level1),$CONTROL_PAR_LABEL,_get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1) & " dB")
set_control_par_str(get_ui_id($mix_level2),$CONTROL_PAR_LABEL,_get_engine_par_disp($ENGINE_PAR_VOLUME,1,-1,-1) & " dB")
set_control_par_str(get_ui_id($mix_level3),$CONTROL_PAR_LABEL,_get_engine_par_disp($ENGINE_PAR_VOLUME,2,-1,-1) & " dB")
set_control_par_str(get_ui_id($mix_level4),$CONTROL_PAR_LABEL,_get_engine_par_disp($ENGINE_PAR_VOLUME,3,-1,-1) & " dB")

$a := 1
while($a < $NUM_GROUPS)
_set_engine_par($ENGINE_PAR_VOLUME,$mix_level1,$a,-1,-1)
_set_engine_par($ENGINE_PAR_VOLUME,$mix_level2,$a,-1,-1)
_set_engine_par($ENGINE_PAR_VOLUME,$mix_level3,$a,-1,-1)
_set_engine_par($ENGINE_PAR_VOLUME,$mix_level4,$a,-1,-1)
inc($a)

declare %layers_id[8]
%layers_id[0] := get_ui_id($mix_level1)
%layers_id[1] := get_ui_id($mix_level2)
%layers_id[2] := get_ui_id($mix_level3)
%layers_id[3] := get_ui_id($mix_level4)
%layers_id[4] := get_ui_id($lb_mix_level1)
%layers_id[5] := get_ui_id($lb_mix_level2)
%layers_id[6] := get_ui_id($lb_mix_level3)
%layers_id[7] := get_ui_id($lb_mix_level4)

$count := 0
while($count < 4)
set_control_par_str(%layers_id[$count],$CONTROL_PAR_PICTURE,"knob1")
set_control_par(%layers_id[$count],$CONTROL_PAR_MOUSE_BEHAVIOUR,-500)
set_control_par(%layers_id[$count],$CONTROL_PAR_POS_X,($count*76)+236)
set_control_par(%layers_id[$count],$CONTROL_PAR_POS_Y,329)
inc($count)
end while

$count := 4
while($count < 8)
set_control_par(%layers_id[$count],$CONTROL_PAR_HIDE,$HIDE_PART_BG)
set_control_par(%layers_id[$count],$CONTROL_PAR_FONT_TYPE,$FONT_ID)
set_control_par(%layers_id[$count],$CONTROL_PAR_TEXT_ALIGNMENT, 1)
set_control_par(%layers_id[$count],$CONTROL_PAR_POS_X, ...
get_control_par(%layers_id[$count-4],$CONTROL_PAR_POS_X)-19)
set_control_par(%layers_id[$count],$CONTROL_PAR_POS_Y, ...
get_control_par(%layers_id[$count-4],$CONTROL_PAR_POS_Y)+43)
inc($count)
end while
end while
end on

on ui_control ($mix_level1)
$a := 0
while($a < $NUM_GROUPS)
_set_engine_par($ENGINE_PAR_VOLUME,$mix_level1,$a,0,-1)
inc($a)
end while
set_text ($lb_mix_level1,_get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1) & " DB")
set_control_par_str(get_ui_id($mix_level1),$CONTROL_PAR_LABEL,_get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1) & " DB")
$last_time_mix_level1 := $ENGINE_UPTIME
wait($wait_time * 1000)
if($ENGINE_UPTIME - $last_time_mix_level1 > $wait_time -5)
set_text ($lb_mix_level1, "LAYER1")
end if
end on

on ui_control ($mix_level2)
$a := 0
while($a < $NUM_GROUPS)
_set_engine_par($ENGINE_PAR_VOLUME,$mix_level2,$a,0,-1)
inc($a)
end while
set_text ($lb_mix_level2,_get_engine_par_disp($ENGINE_PAR_VOLUME,1,-1,-1) & " DB")
set_control_par_str(get_ui_id($mix_level2),$CONTROL_PAR_LABEL,_get_engine_par_disp($ENGINE_PAR_VOLUME,1,-1,-1) & " DB")
$last_time_mix_level2 := $ENGINE_UPTIME
wait($wait_time * 1000)
if($ENGINE_UPTIME - $last_time_mix_level2 > $wait_time -5)
set_text ($lb_mix_level2, "LAYER2")
end if
end on

on ui_control ($mix_level3)
$a := 0
while($a < $NUM_GROUPS)
_set_engine_par($ENGINE_PAR_VOLUME,$mix_level3,$a,0,-1)
inc($a)
end while
set_text ($lb_mix_level3,_get_engine_par_disp($ENGINE_PAR_VOLUME,2,-1,-1) & " DB")
set_control_par_str(get_ui_id($mix_level3),$CONTROL_PAR_LABEL,_get_engine_par_disp($ENGINE_PAR_VOLUME,2,-1,-1) & " DB")
$last_time_mix_level3 := $ENGINE_UPTIME
wait($wait_time * 1000)
if($ENGINE_UPTIME - $last_time_mix_level3 > $wait_time -5)
set_text ($lb_mix_level3,"LAYER3")
end if
end on

on ui_control ($mix_level4)
$a := 0
while($a < $NUM_GROUPS)
_set_engine_par($ENGINE_PAR_VOLUME,$mix_level4,$a,0,-1)
inc($a)
end while
set_text ($lb_mix_level4,_get_engine_par_disp($ENGINE_PAR_VOLUME,3,-1,-1) & " DB")
set_control_par_str(get_ui_id($mix_level3),$CONTROL_PAR_LABEL,_get_engine_par_disp($ENGINE_PAR_VOLUME,3,-1,-1) & " DB")
$last_time_mix_level4 := $ENGINE_UPTIME
wait($wait_time * 1000)
if($ENGINE_UPTIME - $last_time_mix_level4 > $wait_time -5)
set_text ($lb_mix_level4,"LAYER4")
end if
end on

Post

That's because you're doing the while loop in every volume control callback. You don't need it, you only need to point to ONE group for each of those callbacks (0, 1, 2, 3 instead of $a).

Post

Thanks a lot now it works.
But now I have a similar problem with the LFO controls (amount and rate).
When i turn the LFO amount knob it moves instead the ADSR amount and the LFO rate is not working....
What is wrong in my script?
Thanks in advance for any help!

on init

set_ui_height_px(520)
make_perfview
message("")


declare $wait_time := 800

declare $a
declare $count
$count :=0
declare const $FONT_ID := 3
declare const $MAKE_AUTO_IDS := 1


{ENV CONTROLS}

declare ui_slider $lfo_amount1(0,1000000)
declare ui_slider $lfo_freq1(0,1000000)


declare ui_label $lb_lfo_amount1 (1,1)
declare ui_label $lb_lfo_freq1 (1,1)


set_text($lb_lfo_amount1,"AMOUNT")
set_text($lb_lfo_freq1,"RATE")


declare $last_time_lfo_amount1
declare $last_time_lfo_freq1


$lfo_amount1 := _get_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY,0,0,-1)
$lfo_freq1 := _get_engine_par($ENGINE_PAR_INTMOD_FREQUENCY,0,0,-1)


set_control_par_str(get_ui_id($lfo_amount1),$CONTROL_PAR_LABEL,_get_engine_par_disp($ENGINE_PAR_MOD_TARGET_INTENSITY,0,0,-1)& " %")
set_control_par_str(get_ui_id($lfo_freq1),$CONTROL_PAR_LABEL,_get_engine_par_disp($ENGINE_PAR_INTMOD_FREQUENCY,0,0,-1) & " HZ")

$a := 1
while($a < $NUM_GROUPS)
_set_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY,$lfo_amount1,$a,0,-1)
_set_engine_par($ENGINE_PAR_INTMOD_FREQUENCY,$lfo_freq1,$a,0,-1)

inc($a)

declare %adsr_id[4]
%adsr_id[0] := get_ui_id($lfo_amount1)
%adsr_id[1] := get_ui_id($lfo_freq1)

%adsr_id[2] := get_ui_id($lb_lfo_amount1)
%adsr_id[3] := get_ui_id($lb_lfo_freq1)


$count := 0
while($count < 2)
set_control_par_str(%adsr_id[$count],$CONTROL_PAR_PICTURE,"knob1")
set_control_par(%adsr_id[$count],$CONTROL_PAR_MOUSE_BEHAVIOUR,-500)
set_control_par(%adsr_id[$count],$CONTROL_PAR_POS_X,($count*76)+236)
set_control_par(%adsr_id[$count],$CONTROL_PAR_POS_Y,329)
inc($count)
end while

$count := 2
while($count < 4)
set_control_par(%adsr_id[$count],$CONTROL_PAR_HIDE,$HIDE_PART_BG)
set_control_par(%adsr_id[$count],$CONTROL_PAR_FONT_TYPE,$FONT_ID)
set_control_par(%adsr_id[$count],$CONTROL_PAR_TEXT_ALIGNMENT, 1)
set_control_par(%adsr_id[$count],$CONTROL_PAR_POS_X, ...
get_control_par(%adsr_id[$count-2],$CONTROL_PAR_POS_X)-19)
set_control_par(%adsr_id[$count],$CONTROL_PAR_POS_Y, ...
get_control_par(%adsr_id[$count-2],$CONTROL_PAR_POS_Y)+43)
inc($count)
end while
end while
end on

on ui_control ($lfo_amount1)
$a := 0
while($a < $NUM_GROUPS)
_set_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY,$lfo_amount1,$a,0,-1)
inc($a)
end while
set_text ($lb_lfo_amount1,_get_engine_par_disp($ENGINE_PAR_MOD_TARGET_INTENSITY,0,0,-1) & " %")
set_control_par_str(get_ui_id($lfo_amount1),$CONTROL_PAR_LABEL,_get_engine_par_disp($ENGINE_PAR_MOD_TARGET_INTENSITY,0,0,-1) & " %")
$last_time_lfo_amount1 := $ENGINE_UPTIME
wait($wait_time * 1000)
if($ENGINE_UPTIME - $last_time_lfo_amount1 > $wait_time -5)
set_text ($lb_lfo_amount1, "AMOUNT")
end if
end on

on ui_control ($lfo_freq1)
$a := 0
while($a < $NUM_GROUPS)
_set_engine_par($ENGINE_PAR_INTMOD_FREQUENCY,$lfo_freq1,$a,0,-1)
inc($a)
end while
set_text ($lb_lfo_freq1,_get_engine_par_disp($ENGINE_PAR_INTMOD_FREQUENCY,0,0,-1) & " HZ")
set_control_par_str(get_ui_id($lfo_freq1),$CONTROL_PAR_LABEL,_get_engine_par_disp($ENGINE_PAR_INTMOD_FREQUENCY,0,0,-1) & " HZ")
$last_time_lfo_freq1 := $ENGINE_UPTIME
wait($wait_time * 1000)
if($ENGINE_UPTIME - $last_time_lfo_freq1 > $wait_time -5)
set_text ($lb_lfo_freq1, "RATE")
end if
end on

Post

You're not doing modulation amount adjustment correctly. Please read this:

http://vi-control.net/community/threads ... ksp.50854/

Post

Thanks again.
My LFO operate on all groups at the same time, what I have to indicate instead of the "3" for group 4 in your example in order to change the parameter for all groups at the same time?

set_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY,$PitchEnv,3,find_mod(3,"ENV 2"),find_target(3,find_mod(3,"ENV 2"),"ENV 2 -> PITCH"))

Post

This is all explained in KSP reference. See descriptions of find_mod() and find_target() commands.

Post

done it, it works! thanks

Post

claud9 wrote: Fri Aug 12, 2016 3:03 pm done it, it works! thanks
I know is passed some times but I'm doing a similar thing and I need your help @claud9 since you solved it.
Could you be so kind to spend some time for me?
I'm developing a drum library and I'm trying to control all into kontakt.
Basically I've in the same zone 4 samples for drum.
the DRY, the ROOM, the COMP, and the TRIG..so ideally are different layer one over the other cause in the same variation (I've 20 groups, so 20 variations).
I want to create a knob per each "layer" in the way to manipulate the volume of the samples...so if someone play the note 36 which is the C1 so the KICK, will be played all that 4 samples/layers.
Is possible through scripting?
Cause is not a bus because I've the sample in the same group because of the same variation..
I've tried your script and yes it lower the volume of all layer, I tried to delete the loop suggested by @EvilDragon but I think I did a mess :)

Could you help me :)?
thanks
Fabio

Post Reply

Return to “Samplers, Sampling & Sample Libraries”