is it possible to control a hidden ui_slider with another ui_slider?

Options
treynterrio
treynterrio Member Posts: 64 Member
edited September 2023 in Scripting Workshop

Hi there,

is it possible to control a hidden ui_slider with different effects with another ui_slider?

Thanks

«1

Comments

  • noY_T
    noY_T Member Posts: 37 Member
    Options

    For a question like this one would need to know when the slider is supposed to hide

  • treynterrio
    treynterrio Member Posts: 64 Member
    edited September 2023
    Options

    ___________________

  • treynterrio
    treynterrio Member Posts: 64 Member
    Options

    @noY_T the whole time it should be hidden

  • noY_T
    noY_T Member Posts: 37 Member
    Options
    on ui_control ($whateverName)
       // do stuff the control does
       // and:
       set_control_par(get_ui_id($controlToHide),$CONTROL_PAR_HIDE,$HIDE_WHOLE_CONTROL)
    end on
    
  • noY_T
    noY_T Member Posts: 37 Member
    Options

    Wait a second, what exactly are you trying to achieve with your script here?

  • treynterrio
    treynterrio Member Posts: 64 Member
    Options

    I want to control another different effect with it that I can't script to the one slider that shouldn't be hidden.

  • treynterrio
    treynterrio Member Posts: 64 Member
    Options

    I've read something that this doesn't work when callbacks scripted to the second slider

  • noY_T
    noY_T Member Posts: 37 Member
    Options

    Hm. Well if you want to control another slider with your slider so that another effect will be controlled, why not cut out the middle man of the hidden slider?

    You can actually just set both effects with one slider

    on ui_control (mySlider)
    set_engine_par(...1
    set_engine_par(...2
    ... 
    set_engine_par(...1000 
    end on
    
  • treynterrio
    treynterrio Member Posts: 64 Member
    Options

    the other slider should have different values for the effects

  • noY_T
    noY_T Member Posts: 37 Member
    Options

    Then scale it.

    mySlider * someNumber

    or

    mySlider / someNumber

  • treynterrio
    treynterrio Member Posts: 64 Member
    Options

    so it works for me like this but the $hidden slider goes very fast now.

    when I turn up $SLIDER1 to the half the $HIDDEN slider is already at 100%

    is it possible to get this to the same speed?

    on init

    declare ui_slider $SLIDER1(0, 795000)

    make_persistent($SLIDER1)

    declare $k_SLIDER1

    $k_SLIDER1 := get_ui_id($SLIDER1)

    set_control_par_str($k_SLIDER1, $CONTROL_PAR_PICTURE, "")

    set_control_par($k_SLIDER1, $CONTROL_PAR_POS_X, 100)

    set_control_par($k_SLIDER1, $CONTROL_PAR_POS_Y, 100)

    set_control_par($k_SLIDER1, $CONTROL_PAR_MOUSE_BEHAVIOUR, $mouse_resp)


    declare ui_slider $HIDDEN(165000*2,1)

    declare $value

    make_persistent($HIDDEN)

    declare $k_HIDDEN

    $k_HIDDEN := get_ui_id($HIDDEN)

    set_control_par_str($k_HIDDEN, $CONTROL_PAR_PICTURE, "")

    set_control_par($k_HIDDEN, $CONTROL_PAR_POS_X, 200)

    set_control_par($k_HIDDEN, $CONTROL_PAR_POS_Y, 200)

    set_control_par($k_HIDDEN, $CONTROL_PAR_MOUSE_BEHAVIOUR, $mouse_resp)

    set_control_par(get_ui_id($HIDDEN),$CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL)

    end on

    on ui_control ($SLIDER1)

    set_engine_par($ENGINE_PAR_VOLUME, $SLIDER1, 2, -1, 0)

    set_engine_par($ENGINE_PAR_VOLUME, $SLIDER1, 3, -1, 0)

    set_engine_par($ENGINE_PAR_VOLUME, $SLIDER1, 4, -1, 0)

    set_engine_par($ENGINE_PAR_VOLUME, $SLIDER1, 5, -1, 0)

    set_engine_par($ENGINE_PAR_VOLUME, abs($SLIDER1 - 795000), 0, -1, 0)

    $HIDDEN := $SLIDER1

    if ($HIDDEN < 165000)

    $value := $HIDDEN

    else

    $value := 165000 - ($HIDDEN - 165000)

    end if

    set_engine_par($ENGINE_PAR_GN_GAIN, 629961 + $value, -1, 2, $NI_MAIN_BUS)

    end on

  • noY_T
    noY_T Member Posts: 37 Member
    Options

    Yes, the hidden slider is supposed to go up faster if you set it up tat way.

    When you write a sliders name, you are simply using its value. So if a slider is set to 1000, and you then write the sliders name in your script, is is THE SAME THING AS WRITING 1000.

    Try this test

    on init 
     declare ui_slider valueTest (0, 1000000)
    end on
    
    on ui_control (valueTest)
     message(valueTest)
    end on
    

    Look at the little bar at the very botom of Kontakt while moving the slider.

    So right now you are plain and simple setting your hidden slider to the other slider. But your hidden slider only goes from 165000 * 2 and your other slider goes til 795000.

    It perfectly checks out that hidden slider is at its maximum when your other slider is at about half.

    You got to do some algebra to scale you slider value down before assigning that scales version to hidden. A simple example would be something like this inside the slider callback. I changed the numbers for demonstration to hidden always being 1/4 of slider1:

    on init
     declare ui_slider $SLIDER1(0,1000000)
     declare ui_slider $HIDDEN(0,250000)
     // This variable is a real number to make more precise math possible
     declare ~valueHelper
    end on
    
    on ui_control($SLIDER1)
     ~valueHelper := int_to_real($SLIDER1)/4.0
     $HIDDEN := real_to_int(~valueHelper)
     message("Slider1: " & $SLIDER1 & "Hidden Slider: " & $HIDDEN)
    end on
    
  • treynterrio
    treynterrio Member Posts: 64 Member
    Options

    THANKS 🙏🏼 its works know but the $SLIDER1 needs to go down from 6db that's this value (795000) to -init because the sound is very distorted at 1000000.

  • noY_T
    noY_T Member Posts: 37 Member
    Options

    Yeah as I said, I changed the numbers as an example. You can scale everyhing up or down by using math

  • treynterrio
    treynterrio Member Posts: 64 Member
    Options

    math is my biggest weakness but I try it

This discussion has been closed.
Back To Top