What's new

How can I control different effects with one slider?

RFMSK

New Member
Good evening,

I‘m making an instrument where I have a reverb followed by a choral and a replika delay and I would like to have one slider that controls all three in the following way:
From 0 to 250000 only the wet of the reverb is controlled
From 250000 to 750000 the mix of the choral goes up
And from 750000 to 1000000 the wet of the delay goes up.
How can I achieve that? I‘ve been looking all over for ideas and couldn‘t find anything.
Something tells me it‘s not as easy as I thought. Maybe with a while loop?
Looking forward to your input!
 
something like this maybe?
Code:
on ui_control (slider)


    // reverb
    if in_range(slider, 0, 250000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, slider*4, -1, 0, $NI_MAIN_BUS)
    end if   

    // choral
    if in_range(slider, 250000, 750000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, (slider-250000)*2, -1, 1, $NI_MAIN_BUS)
    end if

    // delay
    if in_range(slider, 750000, 1000000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, (slider-750000)*4, -1, 2, $NI_MAIN_BUS)
    end if   

end on
 
something like this maybe?
Code:
on ui_control (slider)


    // reverb
    if in_range(slider, 0, 250000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, slider*4, -1, 0, $NI_MAIN_BUS)
    end if

    // choral
    if in_range(slider, 250000, 750000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, (slider-250000)*2, -1, 1, $NI_MAIN_BUS)
    end if

    // delay
    if in_range(slider, 750000, 1000000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, (slider-750000)*4, -1, 2, $NI_MAIN_BUS)
    end if

end on
+1 to this, just remember to declare your slider as having a (0, 250000) range and Uiroo put the reverb, choral and delay on the main bus on slots 0, 1 and 2 respectively.
 
something like this maybe?
Code:
on ui_control (slider)


    // reverb
    if in_range(slider, 0, 250000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, slider*4, -1, 0, $NI_MAIN_BUS)
    end if  

    // choral
    if in_range(slider, 250000, 750000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, (slider-250000)*2, -1, 1, $NI_MAIN_BUS)
    end if

    // delay
    if in_range(slider, 750000, 1000000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, (slider-750000)*4, -1, 2, $NI_MAIN_BUS)
    end if  

end on
Hi Uiroo,

here's my code. It's not working:

Code:
declare ui_slider $Shimmer(0,1000000)
    $Shimmer := 0
    declare $Shimmer_ID := get_ui_id ($Shimmer)
    set_control_par(get_ui_id($Shimmer),$CONTROL_PAR_MOUSE_BEHAVIOUR,-1000)
    set_control_par(get_ui_id($Shimmer),$CONTROL_PAR_POS_X, 700)
      set_control_par(get_ui_id($Shimmer),$CONTROL_PAR_POS_Y, 120)
    set_control_par_str(get_ui_id($Shimmer),$CONTROL_PAR_PICTURE,"bend_slider_hor_right_big")
    make_persistent($Shimmer)
    
    on ui_control ($Shimmer)

    {reverb}
    if in_range($Shimmer, 0, 250000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, $Shimmer * 4, -1, 0, $NI_BUS_OFFSET + 0)
    end if

    {choral}
    if in_range($Shimmer, 250000, 750000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, ($Shimmer-250000)*2, -1, 1, $NI_BUS_OFFSET + 0)
    end if

    {delay}
    if in_range($Shimmer, 750000, 1000000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, ($Shimmer-750000)*4, -1, 2, $NI_BUS_OFFSET + 0)
    end if

end on

Kontakt says it's expecting '(' on the following line:
Code:
    if in_range($Shimmer, 0, 250000)

Any ideas?
 
Hi Uiroo,

here's my code. It's not working:

Code:
declare ui_slider $Shimmer(0,1000000)
    $Shimmer := 0
    declare $Shimmer_ID := get_ui_id ($Shimmer)
    set_control_par(get_ui_id($Shimmer),$CONTROL_PAR_MOUSE_BEHAVIOUR,-1000)
    set_control_par(get_ui_id($Shimmer),$CONTROL_PAR_POS_X, 700)
      set_control_par(get_ui_id($Shimmer),$CONTROL_PAR_POS_Y, 120)
    set_control_par_str(get_ui_id($Shimmer),$CONTROL_PAR_PICTURE,"bend_slider_hor_right_big")
    make_persistent($Shimmer)
   
    on ui_control ($Shimmer)

    {reverb}
    if in_range($Shimmer, 0, 250000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, $Shimmer * 4, -1, 0, $NI_BUS_OFFSET + 0)
    end if

    {choral}
    if in_range($Shimmer, 250000, 750000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, ($Shimmer-250000)*2, -1, 1, $NI_BUS_OFFSET + 0)
    end if

    {delay}
    if in_range($Shimmer, 750000, 1000000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, ($Shimmer-750000)*4, -1, 2, $NI_BUS_OFFSET + 0)
    end if

end on

Kontakt says it's expecting '(' on the following line:
Code:
    if in_range($Shimmer, 0, 250000)

Any ideas?
if (in_range($Shimmer, 0, 250000))
 
Hi Uiroo,

here's my code. It's not working:

Code:
declare ui_slider $Shimmer(0,1000000)
    $Shimmer := 0
    declare $Shimmer_ID := get_ui_id ($Shimmer)
    set_control_par(get_ui_id($Shimmer),$CONTROL_PAR_MOUSE_BEHAVIOUR,-1000)
    set_control_par(get_ui_id($Shimmer),$CONTROL_PAR_POS_X, 700)
      set_control_par(get_ui_id($Shimmer),$CONTROL_PAR_POS_Y, 120)
    set_control_par_str(get_ui_id($Shimmer),$CONTROL_PAR_PICTURE,"bend_slider_hor_right_big")
    make_persistent($Shimmer)
   
    on ui_control ($Shimmer)

    {reverb}
    if in_range($Shimmer, 0, 250000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, $Shimmer * 4, -1, 0, $NI_BUS_OFFSET + 0)
    end if

    {choral}
    if in_range($Shimmer, 250000, 750000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, ($Shimmer-250000)*2, -1, 1, $NI_BUS_OFFSET + 0)
    end if

    {delay}
    if in_range($Shimmer, 750000, 1000000)
        set_engine_par(ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, ($Shimmer-750000)*4, -1, 2, $NI_BUS_OFFSET + 0)
    end if

end on

Kontakt says it's expecting '(' on the following line:
Code:
    if in_range($Shimmer, 0, 250000)

Any ideas?
Notice that some people will write vanilla KSP (the expected syntax in the Kontakt script editor)

for example:
Code:
 if ($variable < 10) 
{ do something }
end if

some people will write sublimeKSP, which in this case allow you to not need the parenthesis between the if condition and also allows you to omit the variable type identifier as
Code:
 if variable < 10
{ do something }
end if


and some people will write pseudo code like
Code:
if variable less than value 
    do something

just be aware of which case you are looking into and pay attention to the error warnings of Kontakt's script editor, in general they are very objective and easy to understand. In the case above it was a bit confusing because you had parenthesis, in these cases refer to KSP's manual to understand the basic syntax of each element in your line. In this case the if condition and the in_range function.
 
Yeah I figured, and you're right! That one I could've figured out if I would've read on when I looked up the "in_range" Boolean on the KSP Reference online Manual. Thanks for the explanation!

However I now think that the syntax is correct and I'm still getting an "expression expected" error on the line that follows.

Code:
on ui_control ($Shimmer)

    {reverb}
    if (in_range($Shimmer, 0, 250000))
        set_engine_par($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, $Shimmer*4, -1, 0, $NI_BUS_OFFSET + 0)
    end if

end on

What am I missing?
 
At home, it's work fine ...

Code:
on ui_control ($Shimmer)
    if (in_range($Shimmer, 0, 250000))
        set_engine_par($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, $Shimmer*4, -1, 0, $NI_BUS_OFFSET + 0)
     end if

    if (in_range($Shimmer, 250000, 750000))
        set_engine_par($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, ($Shimmer-250000)*2, -1, 1, $NI_BUS_OFFSET + 0)
     end if

    if (in_range($Shimmer, 750000, 1000000))
        set_engine_par($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, ($Shimmer-750000)*4, -1, 2, $NI_BUS_OFFSET + 0)
     end if
end on
 
Last edited:
At home, it's work fine ...

Code:
on ui_control ($Shimmer)
    if (in_range($Shimmer, 0, 250000))
        set_engine_par($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, $Shimmer*4, -1, 0, $NI_BUS_OFFSET + 0)
     end if

    if (in_range($Shimmer, 250000, 750000))
        set_engine_par($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, ($Shimmer-250000)*2, -1, 1, $NI_BUS_OFFSET + 0)
     end if

    if (in_range($Shimmer, 750000, 1000000))
        set_engine_par($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, ($Shimmer-750000)*4, -1, 2, $NI_BUS_OFFSET + 0)
     end if
end on
Weird I was applying the script from the Resources folder and updating it from Sublime. When you wrote this I went to Kontakt and applied from Editor/Patch and it worked :)

Thank you!
 
If you want to do more coding for Kontakt, you should absolutely install sublime with the sublimeKSP extension
I want! I have and I love it! There‘s still a long way to go and the learning curve is steep for someone with little coding knowledge, but I‘m enjoying this so much that if I wouldn‘t be a composer I‘d consider this for a career :)))
 
Weird I was applying the script from the Resources folder and updating it from Sublime. When you wrote this I went to Kontakt and applied from Editor/Patch and it worked :)

Thank you!
In addition, if you’re running Creator Tools alongside Kontakt, the script updates automatically, and Kontakt restarts the engine each time you compile the code from Sublime ;)
 
Top Bottom