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

HOW TO: MODULATION IN KONTAKT VIA KSP

Discussion in 'Scripting Workshop' started by EvilDragon, Jan 6, 2016.

  1. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You don't use it properly in the while loop. First you have a mismatch between group IDs in set_engine_par and find_mod - first is 0 the second is 1. You should just use your loop counter here instead. Also make sure that the LFO exists in all groups and that it has the same name.

    Also please use CODE tags to retain indentation of the code you paste.
     
  2. Frederick Rae

    Frederick Rae NI Product Owner

    Messages:
    37
    Hey ED,

    Thanks for the quick response

    I've got it going, turns out I was right-clicking and renaming the LFO table directly under the filter and not the actual LFO in the modulation section as seen in the picture I posted. Rookie move,


    Either way, how would I use the looper counter? What's the difference?
     
    Last edited: May 3, 2020
  3. Frederick Rae

    Frederick Rae NI Product Owner

    Messages:
    37
    Update, I haven't sorted it, my setting of control parameters are off. Just like my LFO, I've been trying to assign a AHDSR to my filter and kontakt keeps saying that my module "ENV_CUTOFF" is not found and it is because of a faulty index. Please see the module right-clicked in the picture of example code... Apologies, I can't get the code tag to work as intended either.

    set_knob_label($Attack_FILTER, get_engine_par_disp($ENGINE_PAR_ATTACK, 0, find_mod(2,"ENV_CUTOFF"), -1))
     

    Attached Files:

  4. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You have group ID of 0 there but 2 in find_mod. This is not good, they have to match.

    In a while loop you would use your loop counter (you named it $count) instead of a literal number. But for setting knob labels, you don't need to do that in a loop, just picking up the display value from one of groups will do.
     
  5. Frederick Rae

    Frederick Rae NI Product Owner

    Messages:
    37
    I SEE! I just saw index and thought that it was the module index. Anyway, thank you sir! Really appreciate your help
     
  6. WocherMusic

    WocherMusic NI Product Owner

    Messages:
    35
    But is it possible to control a volume modulator with a UI slider? If yes, I think I am lacking a built-in engine variable that I can't find (also not in the manual). I want the UI slider's value to change the position in the modulator's curve, but I can't get it to do that. Is there a variable like $ENGINE_PAR_MOD_SHAPE or something like that?

    P.S.: I read the whole original post and the whole thread and couldn't find an answer to that.
     
  7. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    What are you modulating volume with? You change modulation amount with $ENGINE_PAR_MOD_TARGET_INTENSITY as mentioned. If you're talking about the modulation shaper table, this is not accessible via KSP.
     
  8. WocherMusic

    WocherMusic NI Product Owner

    Messages:
    35
    In the unscripted prototype version of my instrument, I have been controlling dynamics (assigned CC11) with my nanoKONTROL2. This is the curve: it has 6 bumps in total and each bump represents one dynamic (from pianissimo to fortissimo).
    1.png

    Now I would like to make this control accessible for people (including myself) when they don't have a midi controller available, so they can control the dynamics with a UI slider. When I use $ENGINE_PAR_MOD_TARGET_INTENSITY, what happens is the slider sets the intensity to zero, but the position in the shape (the "bumps") isn't altered:
    2.png

    The code looks like this:
    Code:
    on init
    
        { create Dynamic slider }
        declare ui_slider $dynamic_slider(0,1000000)
        $dynamic_slider := 815000
        set_control_par(get_ui_id($dynamic_slider),$CONTROL_PAR_HEIGHT,200)
        set_control_par(get_ui_id($dynamic_slider),$CONTROL_PAR_WIDTH,135)
        set_control_par(get_ui_id($dynamic_slider),$CONTROL_PAR_POS_X,870)
        set_control_par(get_ui_id($dynamic_slider),$CONTROL_PAR_POS_Y,250)
        set_control_par_str(get_ui_id($dynamic_slider),$CONTROL_PAR_PICTURE,"dynamicslider")
        set_control_par(get_ui_id($dynamic_slider),$CONTROL_PAR_MOUSE_BEHAVIOUR,-1000)
    
        declare $dyn_count
        declare $dyn_env_idx
        $dyn_count := 0
        while($dyn_count<$NUM_GROUPS)
            $dyn_env_idx := find_mod($dyn_count, "DYNAMIC_VOL")
            inc($dyn_count)
        end while
    
    end on
    
    on ui_control($dynamic_slider)
        $dyn_count := 0
        while($dyn_count<$NUM_GROUPS)
            set_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY, $dynamic_slider, $dyn_count, $dyn_env_idx, -1)
            inc($dyn_count)
        end while
    end on
     

    Attached Files:

    • 2.png
      2.png
      File size:
      47.6 KB
      Views:
      253
  9. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    So you would then just need to set_controller() to send that CC internally to the instrument.
     
  10. WocherMusic

    WocherMusic NI Product Owner

    Messages:
    35
    Thank you for your quick answer!
    So if I didn't misunderstand: using set_controller should make the UI slider send CC11 internally and thus trigger the modulation?

    I tried to place set_controller in a ui_control callback and then in a note callback, but I got a CPU overload and in the latter Kontakt actually crashed (which has never happened before). Of course I had deleted those while loops, counter and index variables I had posted in the code section above.
     
  11. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Yes you just need to send CC11 from ui_control() callback. Nothing else, no loops, nothing in note callback either.
     
  12. WocherMusic

    WocherMusic NI Product Owner

    Messages:
    35
    It's strange. Nothing happens when I then touch the sliders after inserting set_controller in a ui_control callback. If anything I managed to make Kontakt crash again... I have 42 groups, do you think Kontakt is just overwhelmed with the task?
     
  13. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Nah that shouldn't be it. Maybe you have some sort of MIDI feedback going on (i.e. MIDI learned the scripted knob to the same CC it's sending).

    It works over here with way more than 42 groups...
     
    • Like Like x 1
  14. WocherMusic

    WocherMusic NI Product Owner

    Messages:
    35
    Oh, I got it! Two things: I had to assign the values 0-127 to the slider (so obvious actually...) and had to deactivate the automation learnt MIDI assignment to the UI slider.
    By changing the nanoKONTROL's settings (CC number) I managed to assign a new MIDI number to the UI slider and now I can control it via the hardware fader AND by dragging the UI slider with the mouse.
    For future reference. :)
    Thank you, as ever, Evil Dragon!
     
  15. Cal545

    Cal545 New Member

    Messages:
    19
    Hi
    Could I get some advice please
    I've read through the intial bit by ED but somthing's not clicking and I can't work it out, tried looking on line and re reading the manual but nah not getting it and I'm sure its simple
    I've created a Slider looking to move the modulation intensity but its not finding it and keeps picking up the enerlope AHDSR in the amp section

    end on
    on ui_control ($INT_1)
    set_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY,$INT_1,0,find_mod(0,"LFO1"),find_target(0,find_mod(0,"LFO1"),"LFO1"))

    end on

    Picture shows the name of the modulation and groups etc

    Hope thats enough information, please put me out my misery lol

    Thanks
     

    Attached Files:

  16. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    What your screenshot shows is only the mod target (what find_target() is looking for). How is your LFO modulator named? They should have different names. Your modulator should be called LFO1, and your target something like LFO1 -> CUTOFF in this case.
     
  17. Cal545

    Cal545 New Member

    Messages:
    19
    Apologies my descriptions of areas within the kontakt Instrument are a bit rusty is this the LFO modulator? in the phone which is named LFO_Sine?
    Thanks
     

    Attached Files:

  18. Cal545

    Cal545 New Member

    Messages:
    19
    I've just tried a few things after your comment and this seems to work

    set_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY,$INT_1,0,find_mod(0,"LFO_SINE"),find_target(0,find_mod(0,"LFO_SINE"),"LFO_SINE"))

    presuming its right lol
     
  19. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    That's not correct. If your target is named LFO1, then the proper code would be:

    Code:
    set_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY,$INT_1,0,find_mod(0,"LFO_SINE"),find_target(0,find_mod(0,"LFO_SINE"),"LFO1"))
    But again, your naming should be more consistent. So rename your LFO from LFO_SINE to LFO 1, and your target from LFO1 to LFO 1 -> CUTOFF. Then your code will be:

    Code:
    set_engine_par($ENGINE_PAR_MOD_TARGET_INTENSITY,$INT_1,0,find_mod(0,"LFO 1"),find_target(0,find_mod(0,"LFO 1"),"LFO 1 -> CUTOFF"))
    Make sense?
     
  20. Cal545

    Cal545 New Member

    Messages:
    19
    Ah right, so something easy then lol, I think i tried every combination but that typical, thanks for the support as always great help and so apprecaite

    Thanks ED