Multiple control for a slider ...

corbo-billy
corbo-billy Member Posts: 83 Helper
edited April 2022 in Scripting Workshop

Hi _


I have a logic problem around a slider acting as a switch; I explain myself a little better.

This slider has 4 positions and depending on its position, I would have liked to give a different role to another slider; I tried with a function but it blocks me the other slider. For better understanding, here is my script:

Maybe I should try with an if ($tapeselector = 0...end if function ..?

on init
    set_ui_height(2)
    make_perfview

    declare ui_slider $tapeselector(0, 3)                             
            set_control_par(get_ui_id($TAPESELECTOR),$CONTROL_PAR_MOUSE_BEHAVIOUR,-1100)
            set_control_par_str(get_ui_id($TAPESELECTOR),$CONTROL_PAR_PICTURE,"pv_world_knob_small")                            
            move_control_px($tapeselector,98,8)
            make_persistent($tapeselector)    
            
            declare ui_slider $wear (0, 1000000)                        
            set_control_par(get_ui_id($wear),$CONTROL_PAR_MOUSE_BEHAVIOUR,-500)
            move_control_px($wear,215,18)
            
end on    

function control
    select ($tapeselector)
      case 0
         $wear := get_engine_par($ENGINE_PAR_PHASIS_AMOUNT, -1, 1, -1)
         $wear := get_engine_par($ENGINE_PAR_PHASIS_MOD_MIX/2, -1, 1, -1)
      case 1
          $wear := get_engine_par($ENGINE_PAR_TP_WARMTH,-1,1, $NI_MAIN_BUS)
          $wear := get_engine_par($ENGINE_PAR_TP_HF_ROLLOFF,-1,1, $NI_MAIN_BUS)
      case 2
        $wear := get_engine_par($ENGINE_PAR_TP_WARMTH,-1,1, $NI_MAIN_BUS)
          $wear := get_engine_par($ENGINE_PAR_TP_HF_ROLLOFF,-1,1, $NI_MAIN_BUS)
          $wear := get_engine_par($ENGINE_PAR_SK_DRIVE, -1, 0, -1)
       case 3
          $wear := get_engine_par($ENGINE_PAR_SK_DRIVE, -1, 0, -1)
          $wear := get_engine_par($ENGINE_PAR_BITS,-1,0, $NI_MAIN_BUS)
          $wear := get_engine_par($ENGINE_PAR_BITS,-1,0, $NI_MAIN_BUS)
          $wear := get_engine_par($ENGINE_PAR_FREQUENCY,-1,0, $NI_MAIN_BUS)   
          end select
end function

on ui_control($WEAR)
    call control
end on


Comments

  • EvilDragon
    EvilDragon Moderator Posts: 1,023 mod

    You probably want set_engine_par() not get_engine_par(). And you should call the same function from UI callback for $tapeselector.

  • corbo-billy
    corbo-billy Member Posts: 83 Helper

    Ok, I test it _

  • corbo-billy
    corbo-billy Member Posts: 83 Helper

    Hi _


    I finally adopted another solution, certainly less elegant. I have created four identical sliders and each is concerned with one or another position of the slider at ' positions .

    Those who are not concerned, I do not make them appear and that creates an illusion.


    on init
        set_ui_height(2)
        make_perfview
    
        declare ui_slider $tapeselector(0, 3)                             
                set_control_par(get_ui_id($TAPESELECTOR),$CONTROL_PAR_MOUSE_BEHAVIOUR,-1100)
                set_control_par_str(get_ui_id($TAPESELECTOR),$CONTROL_PAR_PICTURE,"pv_world_knob_small")                            
                move_control_px($tapeselector,98,8)
                make_persistent($tapeselector)    
                
                declare ui_slider $wear (0, 1000000)                        
                set_control_par(get_ui_id($wear),$CONTROL_PAR_MOUSE_BEHAVIOUR,-500)
                move_control_px($wear,215,18)
              
                declare ui_slider $WEAR2 (0, 1000000)   
                set_control_par(get_ui_id($WEAR2),$CONTROL_PAR_MOUSE_BEHAVIOUR,-500)
                move_control_px($WEAR2,215,18)
                set_control_par(get_ui_id($WEAR2),$CONTROL_PAR_HIDE,16)
                declare ui_slider $WEAR3 (0, 1000000)   
                set_control_par(get_ui_id($WEAR3),$CONTROL_PAR_MOUSE_BEHAVIOUR,-500)
                move_control_px($WEAR3,215,18)
                set_control_par(get_ui_id($WEAR3),$CONTROL_PAR_HIDE,16)
                declare ui_slider $WEAR4 (0, 1000000)   
                set_control_par(get_ui_id($WEAR4),$CONTROL_PAR_MOUSE_BEHAVIOUR,-500)
                move_control_px($WEAR4,215,18)
                set_control_par(get_ui_id($WEAR4),$CONTROL_PAR_HIDE,16)
    
         select($TAPESELECTOR)
                case 0
             set_control_par(get_ui_id($WEAR2),$CONTROL_PAR_HIDE,16)
             set_control_par(get_ui_id($WEAR3),$CONTROL_PAR_HIDE,16)
             set_control_par(get_ui_id($WEAR4),$CONTROL_PAR_HIDE,16)
             wait(1)
             set_control_par(get_ui_id($WEAR),$CONTROL_PAR_HIDE,0)
                case 1
             set_control_par(get_ui_id($WEAR3),$CONTROL_PAR_HIDE,16)
             set_control_par(get_ui_id($WEAR4),$CONTROL_PAR_HIDE,16)
             set_control_par(get_ui_id($WEAR),$CONTROL_PAR_HIDE,16)
              wait(1)
             set_control_par(get_ui_id($WEAR2),$CONTROL_PAR_HIDE,0)
                case 2
            set_control_par(get_ui_id($WEAR),$CONTROL_PAR_HIDE,16)
            set_control_par(get_ui_id($WEAR2),$CONTROL_PAR_HIDE,16)
            set_control_par(get_ui_id($WEAR4),$CONTROL_PAR_HIDE,16)
            wait(1)
            set_control_par(get_ui_id($WEAR3),$CONTROL_PAR_HIDE,0)
                case 3
            set_control_par(get_ui_id($WEAR),$CONTROL_PAR_HIDE,16)
            set_control_par(get_ui_id($WEAR2),$CONTROL_PAR_HIDE,16)
            set_control_par(get_ui_id($WEAR3),$CONTROL_PAR_HIDE,16)
            wait(1)
            set_control_par(get_ui_id($WEAR4),$CONTROL_PAR_HIDE,0)
        end select
    
        make_persistent($TAPESELECTOR)
        make_persistent( $wear) 
        make_persistent( $WEAR2) 
        make_persistent( $WEAR3) 
        make_persistent( $WEAR4) 
     
    end on    
    
    on ui_control($TAPESELECTOR)
        select($TAPESELECTOR)
                case 0
             set_control_par(get_ui_id($WEAR2),$CONTROL_PAR_HIDE,16)
             set_control_par(get_ui_id($WEAR3),$CONTROL_PAR_HIDE,16)
             set_control_par(get_ui_id($WEAR4),$CONTROL_PAR_HIDE,16)
             set_control_par(get_ui_id($WEAR),$CONTROL_PAR_HIDE,0)
                case 1
             set_control_par(get_ui_id($WEAR3),$CONTROL_PAR_HIDE,16)
             set_control_par(get_ui_id($WEAR4),$CONTROL_PAR_HIDE,16)
             set_control_par(get_ui_id($WEAR),$CONTROL_PAR_HIDE,16) 
             set_control_par(get_ui_id($WEAR2),$CONTROL_PAR_HIDE,0)
                case 2
            set_control_par(get_ui_id($WEAR),$CONTROL_PAR_HIDE,16)
            set_control_par(get_ui_id($WEAR2),$CONTROL_PAR_HIDE,16)
            set_control_par(get_ui_id($WEAR4),$CONTROL_PAR_HIDE,16)
            set_control_par(get_ui_id($WEAR3),$CONTROL_PAR_HIDE,0)
                case 3
            set_control_par(get_ui_id($WEAR),$CONTROL_PAR_HIDE,16)
            set_control_par(get_ui_id($WEAR2),$CONTROL_PAR_HIDE,16)
            set_control_par(get_ui_id($WEAR3),$CONTROL_PAR_HIDE,16)
            set_control_par(get_ui_id($WEAR4),$CONTROL_PAR_HIDE,0)
    end select
    
    on ui_control($wear)
       set_engine_par($ENGINE_PAR_PHASIS_AMOUNT,$WEAR,-1,1,1)
                set_engine_par($ENGINE_PAR_PHASIS_MIX,$WEAR/2,-1,1,1)
                 set_engine_par($ENGINE_PAR_PHASIS_FEEDBACK,$WEAR/3 ,-1,1,1)
    end on
    on ui_control($WEAR2)
              set_engine_par($ENGINE_PAR_TP_WARMTH,$WEAR2,-1,1,$NI_MAIN_BUS)
              set_engine_par($ENGINE_PAR_TP_HF_ROLLOFF,$WEAR2,-1,1,$NI_MAIN_BUS)
    end on
                   on ui_control($WEAR3)
              set_engine_par($ENGINE_PAR_TP_WARMTH,$WEAR3,-1,1,$NI_MAIN_BUS)
              set_engine_par($ENGINE_PAR_TP_HF_ROLLOFF,$WEAR3,-1,1,$NI_MAIN_BUS)
              set_engine_par($ENGINE_PAR_SK_DRIVE,$WEAR3,-1,0,1)
    end on
                   on ui_control($WEAR4)
              set_engine_par($ENGINE_PAR_SK_DRIVE,$WEAR4,-1,0,1)
              set_engine_par($ENGINE_PAR_BITS,750000 -($WEAR4*21/31),-1,0,$NI_MAIN_BUS)
              set_engine_par($ENGINE_PAR_FREQUENCY,990000 -($WEAR4*10/11),-1,0,$NI_MAIN_BUS)
    end on
    
  • EvilDragon
    EvilDragon Moderator Posts: 1,023 mod

    That's really not necessary, one slider for mode and one for amount is all you really need. This is overcomplicating.

Back To Top