Kontakt Scripting - Best way to create Wet / Dry FX?

TVCulture
TVCulture Member Posts: 3 Member
edited August 2022 in Scripting Workshop

Hey! First time poster. Apologies if this has been asking before, I did look!

I'm making a Kontakt instrument with a few different FX dry/web knobs such as reverb, phaser etc. I have the knob mapped to $ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN and $ENGINE_PAR_SEND_EFFECT_DRY_LEVEL on the FX, reducing and increasing the appropriate dry or wet volume as needed. However I've noticed the volume seems quite inconsistent. While it sounds fine at 100% dry or 100% wet, I'm finding at 50% of both, it generally sounds quieter, almost as if the volume curve is exponential for each with the movement of the knob... if that makes sense?

on ui_control($Verb)

set_engine_par($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, $Verb, -1, 0, 1)

set_engine_par($ENGINE_PAR_SEND_EFFECT_DRY_LEVEL, 500000 - $Verb, -1, 0, 


Help much appreciated, sorry if this is a known issue, I am a noob

Comments

  • Kaiwan_NI
    Kaiwan_NI Administrator Posts: 2,525 admin

    @EvilDragon Pretty sure you know an answer to this? 🙂

  • TVCulture
    TVCulture Member Posts: 3 Member

    Thanks both that's so helpful :) I have it set up.

    As a follow up question if possible, I noticed that Retro Machines MK2 seems to have quite a smooth setup for FX (Reverb and Echo) but for the life of me I can't figure out exactly how it works. There seems to be something automating the send levels of the effects, based on the knob position... as if when the key is triggered, the FX send level on the source module turns to zero. It doesn't seem to be modulated by any ADSRs I can see

    (A). Is this superior in some way to automating the dry/wet as discussed above?

    (B). IF SO - would someone mind explaining exactly how the FX work in Retro machines?

    Thank you - again apologies for the noob question, I genuinely spent a while trying to find an article that would answer it but haven't found anything as of yet. Is it Midi CC related?

  • test189278367
    test189278367 Member Posts: 1 Member

    Hey guys, unfortunately the link to the old forum posts directs you to the native instrument community website and not to the old forum... does anyone know a way how to still access the old forum posts?

  • LucidStorm
    LucidStorm Member Posts: 4 Newcomer

    Hi, I am also trying to figure this out. I am very new to KSP or any scripting, I've just started creating an instrument for the first time about a week ago, so apologies if I'm missing something obvious.

    If I have a convolution reverb, and want a single knob for wet/dry control, how would i go about keeping the level consistent throughout the whole sweep. I'm experiencing the same thing as the OP, at 0% or 100%, the level seems fine, but its significantly quieter at 50%.

    This is what I have in the script editor:

      on init
       declare ui_knob $tele (0,396484,1)
       make_persistent ($tele)
       move_control_px ($tele,690,320)
       set_text ($tele,"Filter")
    end on
    on ui_control ($tele)
    
       set_engine_par($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN,$tele,-1,2,1)
       set_engine_par($ENGINE_PAR_SEND_EFFECT_DRY_LEVEL,396484 - $tele,-1,2,1)
    
    end on
    

    I was able to find the page linked on wayback machine , and at the end of the thread EvilDragon posted this code which i think would address this problem:

    on init
        declare pers ui_slider fatknob (583000, 1000000)
        declare ~gain
    end on
    
    on ui_control (fatknob)
        gain := 367000.0 + (int_to_real(fatknob - 583000) * 0.46522782)
        set_engine_par(ENGINE_PAR_TP_GAIN, fatknob, -1, 2, NI_INSERT_BUS)
        set_engine_par(ENGINE_PAR_INSERT_EFFECT_OUTPUT_GAIN, real_to_int(gain), -1, 2, NI_INSERT_BUS)
    end on
    

    I'm not sure if wayback machine changed the text for some reason, or if I'm just missing something. Kontakt doesnt seem to recognize "pers" in this example:

    declare pers ui_slider fatknob
    

    Also shouldn't "fatknob" be "$fatknob"?

    Appreciate any info on what to do here. Thanks.

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

    You must write:

    declare ui_slider $fatknob (O, 1000000)
    
  • LucidStorm
    LucidStorm Member Posts: 4 Newcomer

    Ok, thanks. So I have modified the code in a test project to the following:

    on init
    
       declare ui_slider $fatknob (0,1000000)
       make_persistent ($fatknob)
       declare ~gain
    
    end on
    
    on ui_control ($fatknob)
       gain := 367000.0 + (int_to_real($fatknob - 583000) * 0.46522782)
       set_engine_par($ENGINE_PAR_TP_GAIN, $fatknob, -1,0,NI_INSERT_BUS)
       set_engine_par($ENGINE_PAR_INSERT_EFFECT_OUTPUT_GAIN, real_to_int(gain), -1,0,NI_INSERT_BUS)
    
    end on
    

    I am not sure if i modified it correctly. I changed (-1,2,NI_INSERT_BUS) to (-1,0,NI_INSERT_BUS) on the two "set_engine_par" lines because the effect is in the first slot (0).

    I am getting an "end on" error with this line:

     gain := 367000.0 + (int_to_real($fatknob - 583000) * 0.46522782)
    

    But it is as I pasted here with the "end on" line so I'm not sure that that's the problem.

    Does "declare ~gain" make sense here? I haven't been able to find anything about this in the manual or elsewhere online.

  • LucidStorm
    LucidStorm Member Posts: 4 Newcomer
    edited March 2023

    Alright so I finally have it figured out. First of all I didn't realize that code was intended for sublimeKSP which i hadn't messed with until now, I realize now there are several things i did not grasp at all that I now have a slight understanding of, lol. With a lot of trial and error and some help from AI i figured out that having dry gain use an exponential function while having wet gain use a logarithmic function resulted in a smooth sweep.

    Here is my updated compiled code:

    on init
     declare ui_knob $tele(0,396482,1)
     make_persistent($tele)
     move_control_px($tele,690,320)
     declare ~gain
     declare ~wet_gain
    end on
    
    on ui_control($tele)
     ~gain := int_to_real(396482)*(1.0-((exp(5.0*int_to_real($tele)/int_to_real(396482))-1.0)/(exp(5.0)-1.0)))
     set_engine_par($ENGINE_PAR_SEND_EFFECT_DRY_LEVEL,real_to_int(~gain),-1,2,1)
     ~wet_gain := int_to_real(396482)*log(int_to_real($tele)+1.0)/log(int_to_real(396482)+1.0)
     set_engine_par($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN,real_to_int(~wet_gain),-1,2,1)
    end on
    
Back To Top