1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

Macro Knob with Linkable Controls

Discussion in 'Scripting Workshop' started by Kalen Smith, Sep 6, 2019.

  1. Kalen Smith

    Kalen Smith NI Product Owner

    Messages:
    38
    Hi everyone,
    I seem to have run into a little conundrum. I'm attempting to make a Macro Knob, one that controls multiple effects at once. I want the user to be able to link any effects in the player to the knob, using a button, on/off.
    When the link button is off, the effect will not be triggered by the knob, but will remain on. When the button is on, it will be controlled by the big knob.
    Here's the script I've been working on (variables are declared before hand):

    declare ui_switch $lofi_bits_link
    make_persistent($lofi_bits_link)
    declare $lofi_bits_on := 0
    end on

    on ui_control ($lofi_bits_link)
    $lofi_bits_on := 1
    end on

    on ui_control($modwheel)
    if ($lofi_bits_on > 0)
    set_engine_par($ENGINE_PAR_BITS,$modwheel,0,3,-1)
    end if
    end on

    I've got it so that when the button is off when I first turn on the script, the knob does nothing. When I turn the button on , the effect is "linked" and it works. The only problem is that I won't unlink. I'm aware as to why (number is now constant in the script), I just don't know any good solutions to the problem. I'm guessing there needs to be a way for the button to change the variable value depending on its state.
    I'm rather new to this......
    Thanks for any suggestions!!!!
     
  2. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    There was no need for that extra variable. Should've just queried the state of $lofi_bits_link button.
     
  3. Kalen Smith

    Kalen Smith NI Product Owner

    Messages:
    38
    Right thanks for the reply. I figured there would be an easier way to do that, the only problem is I haven't found a function anywhere to check the state. I've scanned the new KSP Manuel, searched online, but nothing seems to be coming up. I'm sure it's something simple I'm missing.
    Sorry for all the questions.:)
    Edit: Right I've managed to figure it out....just needed to check the value,
    if ($lofi_bits_link = 1)
     
    Last edited: Sep 6, 2019
  4. Kalen Smith

    Kalen Smith NI Product Owner

    Messages:
    38
    Right so I've got it now and it seems to work. The only oddity I'm running into is that the Tone for skreamer is not being modulated. The modwheel can't control the tone, but works fine with the other parameters (ex: drive, bright, bass for the skreamer)

    declare ui_switch $skreamer_tone_link
    make_persistent($skreamer_tone_link)

    on ui_control($modwheel)
    if ($skreamer_tone_link = 1)
    set_engine_par($ENGINE_PAR_SK_TONE,$modwheel,0,1,-1) {It's the same values for the other variables which all work fine}
    end if
    end on

    Weird problem.....
     
  5. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    What's the declared range of $modwheel?
     
  6. Kalen Smith

    Kalen Smith NI Product Owner

    Messages:
    38
    Should be 0 - 1000000. Here's the scripting for it:

    declare ui_slider $modwheel(0, 1000000)
    make_persistent ($modwheel)

    declare $modwheelid
    $modwheelId := get_ui_id($modwheel)

    set_control_par_str($modwheelId, $CONTROL_PAR_PICTURE, "Bigger Knob")
    set_control_par($modwheelId, $CONTROL_PAR_POS_X, 210)
    set_control_par($modwheelId, $CONTROL_PAR_POS_Y, 80)
    set_control_par($modwheelId,$CONTROL_PAR_MOUSE_BEHAVIOUR, -500)
     
  7. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Hmmm, not sure. It works over here.
     
  8. medusa

    medusa NI Product Owner

    Messages:
    239
    Works here too. Have you got the right location for the Skreamer? You've written ,0,1,-1) above, which is the second group fx on the first group.
     
  9. Kalen Smith

    Kalen Smith NI Product Owner

    Messages:
    38
    That is rather odd, since I'm using the exact same values for the other parameters and they work fine......
    Another odd thing has happened with the code. I've gone ahead and added more of these buttons linking controls but now the modwheel no longer controls any of them....but it was working before.
    I've linked the file with all the code below. Hopefully that will allow for some solutions.
    I'm not seeing anything wrong, and have not changed anything; I'm very confused as to why it's not working...
     

    Attached Files:

  10. medusa

    medusa NI Product Owner

    Messages:
    239
    You can't have lots of different on ui_control($modwheel) calls. Just have one and put all the if statements inside the one.
     
  11. Kalen Smith

    Kalen Smith NI Product Owner

    Messages:
    38
    Oh...............yes it works now.
    It's still odd how it works up to a certain point then stopped. Thanks again.
    Hopefully the gang wouldn't mind a few more questions. ;)
    ED mentioned a new command called ui_panel which allows one to group controls together. How specifically does this work? Let's say I wanted to create a show / hide button that utilized that function with panels.
    Seems to be a rather new function, so there is not a lot of material online that points towards it.
     
  12. medusa

    medusa NI Product Owner

    Messages:
    239
    It's in the reference manual here, starts bottom of page 30
    https://www.native-instruments.com/.../kontakt/KONTAKT_610_KSP_Reference_Manual.pdf

    Essentially you declare a panel, and then attach objects to it (sliders, labels, whatever).
    set_control_par(get_ui_id(Mid_Range_Frequency),$CONTROL_PAR_PARENT_PANEL,get_ui_id(my_eq_panel_all))

    Then you just have to show/hide the panel and all those objects appear or dissappear.
    ie. my_eq_panel_all->hide:= HIDE_WHOLE_CONTROL or my_eq_panel_all->hide:= HIDE_PART_NOTHING
     
  13. Kalen Smith

    Kalen Smith NI Product Owner

    Messages:
    38
    Right I follow. I can get the panel to hide but the "show" function is being more illusive. How do I make the panel reappear? Here's what I've got so far:

    on init
    make_perfview

    declare ui_slider $volume (0, 1000000)
    make_persistent ($volume)

    declare $count

    declare ui_panel $main_knob_view
    set_control_par(get_ui_id($volume),$CONTROL_PAR_PARENT_PANEL,get_ui_id($main_knob_view))

    declare ui_switch $on
    make_persistent ($on)

    end on

    on ui_control ($on)
    if ($on = 0)
    set_control_par(get_ui_id($main_knob_view),$CONTROL_PAR_HIDE,$HIDE_WHOLE_CONTROL)
    else
    if ($on = 1)
    set_control_par(get_ui_id($main_knob_view),$CONTROL_PAR_SHOW,$SHOW_WHOLE_CONTROL) ?? can't find this in ksp manuel.

    end if
    end on
     
  14. medusa

    medusa NI Product Owner

    Messages:
    239
    set_control_par(get_ui_id($main_knob_view),$CONTROL_PAR_HIDE,$HIDE_PART_NOTHING)
     
  15. Kalen Smith

    Kalen Smith NI Product Owner

    Messages:
    38
    Oh I see..
    Odd they didn't just make it show.
    Wow sorry for all the questions. Thanks for both of your time!
    (might come up with some more in due time) :);)
     
  16. medusa

    medusa NI Product Owner

    Messages:
    239
    You can't invent your own commands... ;-) you have to use the ones in the reference guide.
     
  17. Kalen Smith

    Kalen Smith NI Product Owner

    Messages:
    38
    Right you are sir. Although I do have another question. Basically I want the 2 switches to toggle, so that when one is on, one can't turn the other one on and overlap the two panels.
    I found a tutorial online which detailed this process. The only problem is when I try to apply the script it does not work. Any suggestions? Is says boolean expression expected in the toggle function, but not sure what's missing....

    on init
    make_perfview
    declare ui_switch $swi1
    declare ui_switch $swi2
    end on

    function toggle_switches
    if (switch_1 = 1)
    switch_2 := 0
    end if

    end function

    on ui_control(swi1)
    toggle_switches(swi1, swi2)
    end on

    on ui_control(swi2)
    toggle_switches(swi2, swi1)
    end on
     
  18. medusa

    medusa NI Product Owner

    Messages:
    239
    The function needs the two inputs, see below, but you also need to compile this kind of code in Sublime KSP before pasting into Kontakt.
    Do you have that? You should definitely get it if you don't, since that's the only way to compile this kind of function.

    Code:
    on init
    make_perfview
    declare ui_switch $swi1
    declare ui_switch $swi2
    end on
    
    function toggle_switches(switch_1,switch_2 )
    if (switch_1 = 1)
    switch_2 := 0
    end if
    
    end function
    
    on ui_control(swi1)
    toggle_switches(swi1, swi2)
    end on
    
    on ui_control(swi2)
    toggle_switches(swi2, swi1)
    end on
    
     
  19. Kalen Smith

    Kalen Smith NI Product Owner

    Messages:
    38
    Well I have the Sublime Text 3 with the KSP Engine now it seems. So how do I compile the code? Under the compile menu in tools it is greyed out.
    Edit never mind....figured out how to switch it into ksp for the sublime text...
     
    Last edited: Sep 7, 2019
  20. Kalen Smith

    Kalen Smith NI Product Owner

    Messages:
    38
    Right so another question. Let's say I wanted to make a button that once on, could not be turned off unless another button was pressed, which would then turn it off.