Scripting Simple Instrument with 5 Knobs [HELP]

Discussion in 'Kontakt' started by m4xst4r2015, May 13, 2015.

  1. m4xst4r2015

    m4xst4r2015 Member

    Joined:
    May 13, 2015
    Messages:
    24
    Likes Received:
    10
    Hello.

    I have recently learnt somethings about scripting instruments in Kontakt 5.
    But I need just a few help from you guys like follow :
    A simple Instrument with 5 custom image knobs positioned in center of the instrument controlling the following :
    ( Volume - Pitch - Distortion - Cutoff - Resonance )
    If ( Distortion ) effect can`t be controlled then I will be satisfied with the other 4 ones.

    This is how it should be like :
    [​IMG]

    Recently I`ve worked on something like this :
    Script :
           on init
              make_perfview <---- I believe this is making everything visible
              set_script_title("Wallpaper")
              set_ui_height_px(96) <---- I believe this is controlling my instrument height
              declare ui_knob $knob_1 (0,1000,1) <---- I believe this is creating a knob
              move_control($knob_1,3,3) <---- I believe this is controlling the position of the knob i`ve created
           end on

    This script I`ve made let me create a Knob with 2 labels at the right side of it ( Knob Name Label & Knob Value Label )
    But I don`t like how it looks and the main thing that I can`t even control something with it.... so :
    Q1 - How to assign a custom image to this Knob to replace the exist one and remove the labels and stuff
    Q2 - How to make this Knob contorting "Cutoff" option as a example.
    I believe that once I know this I will just repeat this and let it controlling other things lile ( Volume - Pitch - Distortion - Resonance )

    I appropriate any help !

    Thanks in advance.
     
  2.  
  3. Clandestine

    Clandestine Platinum Record

    Joined:
    Nov 11, 2013
    Messages:
    717
    Likes Received:
    152
    Code:
    on init
    make_perfview {This command makes the performance view}
    set_ui_height_px(300) {This command sets the height of your performance view declare in pixels or by grid numbers}
    set_script_title("WHATEVER")  {Sets the Script title}
    message("") {clears any messages}
    
    {DECLARE GUI CONTROLS}
    
    declare ui_knob $knob_1 (0,1000000,1){Range from 0 - 1000000 in increments of 1}
    declare ui_knob $knob_2 (0,1000000,1)
    declare ui_knob $knob_3 (0,1000000,1)
    declare ui_knob $knob_4 (0,1000000,1)
    declare ui_knob $knob_5 (0,1000000,1)    
    
    set_knob_defval ($knob_1,500000) {Sets the Default Values}
    set_knob_defval ($knob_2,500000)
    set_knob_defval ($knob_3,500000)
    set_knob_defval ($knob_4,500000)
    set_knob_defval ($knob_5,500000)
    
    move_control_px($knob_1,50,25) {Moves the Knob by pixels to desired location}
    move_control_px($knob_2,150,25)
    move_control_px($knob_3,250,25)
    move_control_px($knob_4,350,25)
    move_control_px($knob_5,450,25)
    
    set_text($knob_1,"Volume") {sets the text on the knob}
    set_text($knob_2,"Pitch")
    set_text($knob_3,"Distortion")
    set_text($knob_4,"Cutoff") 
    set_text($knob_5,"Resonance")
    
    make_persistent($knob_1) {Sets Knob Persistency}
    make_persistent($knob_2)
    make_persistent($knob_3)
    make_persistent($knob_4)
    make_persistent($knob_5)
    
    _read_persistent_var($knob_1) {Reads Persistent}
    _read_persistent_var($knob_2)
    _read_persistent_var($knob_3)
    _read_persistent_var($knob_4)
    _read_persistent_var($knob_5)
    
    end on
    That's just your basc GUI setup.

    Can't do much more as u not said where u put your filters, distortion etc so can't include the relevant engine parameters.

    Depends on what level etc you want to place them *yes*


    EDIT 2 (Didn't quite fully answer your question so here goes)

    If u don't want to use knobs etc & don't like the way things look then u have to change things a little

    i.e Custom Knobs must be declared as ui_slider & different rules apply. To display a value you must declare a label & point it towards the relevant engine parameter etc.

    This is ALL Listed in KSP reference which u must learn if u are to progress.

    I will detail a working example below.

    Make a new instrument. Insert a filter in slot 1 of the Instrument Insert FX level. Remember slot numbers are zero based ie. Slot 1 must declared as zero, Slot 2 as 1 etc!

    Insert This code in your script

    Code:
    on init
    message(" ")
    make_perfview
    set_ui_height_px(366)
    set_control_par_str($INST_WALLPAPER_ID,$CONTROL_PAR_PICTURE,"BACKGROUND.NAME")
    set_control_par_str($INST_ICON_ID,$CONTROL_PAR_PICTURE,"ICONNAME")
    
    {declare constants}
    
    declare $FILTER_slot:=0
    
    {---BUILD GUI---}
    
    {---BUTTON TO BYPASS FILTER---}
    
    declare ui_switch $FILBY
    set_control_par(get_ui_id($FILBY),$CONTROL_PAR_HEIGHT,50)
    set_control_par(get_ui_id($FILBY),$CONTROL_PAR_WIDTH,50)
    set_control_par_str(get_ui_id($FILBY),$CONTROL_PAR_PICTURE,"PNG.NAME")
    _set_engine_par($ENGINE_PAR_EFFECT_BYPASS,1,-1,$FILTER_slot,1)
    hide_part($FILBY,$HIDE_PART_BG)
    move_control_px($FILBY,100,100)
    set_text($FILBY,"")
    
    {---KNOB TO CONTROL FILTER---}
    
    declare ui_slider $CUTTOF1(0,1000000) 
    set_knob_defval($CUTTOF1,500000)
    set_control_par_str(get_ui_id($CUTTOF1),$CONTROL_PAR_PICTURE,"PNG2.NAME")
    set_control_par(get_ui_id($CUTTOF1),$CONTROL_PAR_MOUSE_BEHAVIOUR,-500)
    $CUTTOF1:=get_engine_par($ENGINE_PAR_CUTOFF,-1,$FILTER_slot,1)
    move_control_px($CUTTOF1,100,180)
    make_persistent($CUTTOF1)
    read_persistent_var($CUTTOF1)
    
    {---LABEL TO DIPLAY VALUE---}
    
    declare ui_label $CUTOFF1val(1,1) 
    set_control_par_str(get_ui_id($CUTOFF1val),$CONTROL_PAR_TEXT,get_engine_par_disp($ENGINE_PAR_CUTOFF,-1,$FILTER_slot,1))
    set_control_par(get_ui_id($CUTOFF1val),$CONTROL_PAR_FONT_TYPE,18)
    move_control_px($CUTOFF1val,120,220)
    read_persistent_var($CUTOFF1val)
    make_persistent($CUTOFF1val)
    hide_part($CUTOFF1val,$HIDE_PART_BG)
    
    end on
    
    {---CALBACKS---}
    
    on ui_control($FILBY)
    if ($FILBY=1)
    set_engine_par($ENGINE_PAR_SEND_EFFECT_BYPASS,0,-1,$FILTER_slot,1)		
    else
    set_engine_par($ENGINE_PAR_SEND_EFFECT_BYPASS,1,-1,$FILTER_slot,1)
    end if
    end on
    
    {---KNOB & LABEL---}
    
    on ui_control($CUTTOF1)
    set_engine_par($ENGINE_PAR_CUTOFF,$CUTTOF1,-1,$FILTER_slot,1)
    set_control_par_str(get_ui_id($CUTOFF1val),$CONTROL_PAR_TEXT,get_engine_par_disp($ENGINE_PAR_CUTOFF,-1,$FILTER_slot,1))
    end on

    REMEMBER u must also have custom graphics with a relevant txt file stored in the pictures folder in the Resources folder. If u don't know hiw to make one consult the KSP reference manual.

    So in this example u would have a button "PNG.NAME" to Switch the filter on & off.

    Then u will see a slider with the cutoff displayed underneath when u move it will change in value.

    These images will not be displayed correctly until you have the relevant .png & text files for your custom graphics stored correctly in your resources folder which you must create for your instrument

    Good Luck :wink:
     
  4. m4xst4r2015

    m4xst4r2015 Member

    Joined:
    May 13, 2015
    Messages:
    24
    Likes Received:
    10
    Thank you very much @Clandestine :dancing:
    Look I`ve worked on this ,, Just tell me if I am going right or not :

    on init

    make_perfview
    set_ui_height_px(350)

    declare ui_button $power
    set_text($power, " ENABLE FILTER")

    { create the controls }
    declare ui_slider $switcher1(0, 1000000)
    declare ui_slider $switcher2(0, 1000000)
    declare ui_slider $switcher3(0, 1000000)

    { hide the visible slider parts }
    hide_part($switcher1, $HIDE_PART_BG .or. $HIDE_PART_MOD_LIGHT .or. $HIDE_PART_TITLE .or. $HIDE_PART_VALUE)
    hide_part($switcher2, $HIDE_PART_BG .or. $HIDE_PART_MOD_LIGHT .or. $HIDE_PART_TITLE .or. $HIDE_PART_VALUE)
    hide_part($switcher3, $HIDE_PART_BG .or. $HIDE_PART_MOD_LIGHT .or. $HIDE_PART_TITLE .or. $HIDE_PART_VALUE)

    { assign the image file }
    set_control_par_str(get_ui_id($switcher1), $CONTROL_PAR_PICTURE, "metal_orangeknob_2")
    set_control_par_str(get_ui_id($switcher2), $CONTROL_PAR_PICTURE, "metal_orangeknob_2")
    set_control_par_str(get_ui_id($switcher3), $CONTROL_PAR_PICTURE, "metal_orangeknob_2")

    { place it on the performance view using x and y coordinates }
    move_control_px($switcher1, 210, 250)
    move_control_px($switcher2, 260, 250)
    move_control_px($switcher3, 310, 250)
    move_control_px($power, 240, 300)

    { control how mouse movements should affect the control }
    set_control_par(get_ui_id($switcher1), $CONTROL_PAR_MOUSE_BEHAVIOUR, -500)
    set_control_par(get_ui_id($switcher2), $CONTROL_PAR_MOUSE_BEHAVIOUR, -500)
    set_control_par(get_ui_id($switcher3), $CONTROL_PAR_MOUSE_BEHAVIOUR, -500)

    { assign a neutral default value to the knob }
    $switcher1 := 500000
    $switcher2 := 500000
    $switcher3 := 500000
    end on

    on ui_control ($switcher1)
    set_engine_par($ENGINE_PAR_VOLUME,$switcher1, -1, 0, 1)
    end on
    on ui_control ($switcher2)
    set_engine_par($ENGINE_PAR_CUTOFF,$switcher2, -1, 0, 1)
    end on
    on ui_control ($switcher3)
    set_engine_par($ENGINE_PAR_RESONANCE,$switcher3, -1, 0, 1)
    end on

    on ui_control ($power)

    if ($power = 1)
    set_engine_par($ENGINE_PAR_EFFECT_BYPASS,0,-1,0,1)
    set_text($power, " DISABLE FILTER")
    end if

    if ($power = 0)
    set_engine_par($ENGINE_PAR_EFFECT_BYPASS,1,-1,0,1)
    set_text($power, " ENABLE FILTER")
    end if
    end on



    The only problem I still have is ( HOW TO CUSTOMIZE MY POWER ON/OFF BUTTON ) Customizing Size & Picture
     
  5. Clandestine

    Clandestine Platinum Record

    Joined:
    Nov 11, 2013
    Messages:
    717
    Likes Received:
    152
    Right firstly MUCH MUCH better however few problems *yes*

    1.) Forget about the hide parts for the moment.
    U need a custom animation for a slider with a text file stored in your resource contatiner. The text file needs to describe the number of animations etc (REFER to KSP REFERENCE)

    2.) Your filter is on by default which is ok if you want it that way but is probably better to BYPASS it by default so that pressing button enables the filter.

    3.) You have used the command $ENGINE_PAR_VOLUME for your switcher.
    IN effect what you are doing by this id changing the MASTER VOLUME not the output level of the filter.

    This will cause loads of problems later on when using several groups etc trust me *yes*

    Is better to use the relevant command which in this case would be $ENGINE_PAR_INSERT_EFFECT_OUTPUT_GAIN & direct it towards the filter slot.

    4.) Your labels are missing & if u use custom images for power buttons u will need to assign separate labels for text displays as you cannot set the text when using a slider so use separate text labels to display on off etc.

    5.) To resize the picture simply use an image editor & manipulate it u can then set the value of the width & height of the custom image using the commands

    set_control_par(get_ui_id($NAME),$CONTROL_PAR_HEIGHT,50)
    set_control_par(get_ui_id($NAME),$CONTROL_PAR_WIDTH,50)

    Just change the pixel size i.e change 50 to 75 etc *yes*

    A more sophisticated script for your filter would be something like the one below

    However set it up your own way etc as the way u do things is up to u *yes*

    Code:
    on init
    make_perfview
    set_ui_height_px(366)
    set_control_par_str($INST_WALLPAPER_ID,$CONTROL_PAR_PICTURE,"BACKGROUND.NAME")
    set_control_par_str($INST_ICON_ID,$CONTROL_PAR_PICTURE,"ICONNAME")
    message("")
    
    {declare constants}
    
    declare $LABEL_id:=14
    declare $FILTER_slot:=0
    
    {---BUILD GUI---}
    
    {---MASTER VOLUME---}
    
    declare ui_slider $volume(0,629959) 
    set_knob_defval($volume,500000)
    set_control_par_str(get_ui_id($volume),$CONTROL_PAR_TEXT,"MVolume")
    set_control_par_str(get_ui_id($volume),$CONTROL_PAR_PICTURE,"MVolume")
    set_control_par(get_ui_id($volume),$CONTROL_PAR_MOUSE_BEHAVIOUR,-350)
    $volume := get_engine_par($ENGINE_PAR_VOLUME,-1,-1,-1)
    move_control_px($Volume,500,15)
    make_persistent($volume)
    
    {---MASTER VOLUME LABEL---}
    
    declare ui_label $MASTER(1,1) 
    move_control_px($MASTER,505,0)
    set_text($MASTER,"MASTER VOL")
    set_control_par(get_ui_id($MASTER),$CONTROL_PAR_FONT_TYPE,$label_id)
    hide_part($MASTER,$HIDE_PART_BG)
    
    {---LABEL DISPLAY TO MASTER VOLUME DB---}
    
    declare ui_label $volumeval(1,1) 
    set_control_par_str(get_ui_id($volumeval),$CONTROL_PAR_TEXT,get_engine_par_disp($ENGINE_PAR_VOLUME,-1,-1,-1))
    set_control_par(get_ui_id($volumeval),$CONTROL_PAR_FONT_TYPE,18)
    move_control_px($volumeval,520,40)
    read_persistent_var($volumeval)
    make_persistent($volumeval)
    hide_part($volumeval,$HIDE_PART_BG)
    
    {---BUTTON TO BYPASS FILTER---}
    
    declare ui_switch $FILBY
    set_control_par(get_ui_id($FILBY),$CONTROL_PAR_HEIGHT,50)
    set_control_par(get_ui_id($FILBY),$CONTROL_PAR_WIDTH,50)
    set_control_par_str(get_ui_id($FILBY),$CONTROL_PAR_PICTURE,"PNG.NAME")
    _set_engine_par($ENGINE_PAR_EFFECT_BYPASS,1,-1,$FILTER_slot,1)
    hide_part($FILBY,$HIDE_PART_BG)
    move_control_px($FILBY,100,100)
    set_text($FILBY,"")
    
    {---FILTER ON/OFF LABEL---}
    
    declare ui_label $FILonoff(1,1) 
    move_control_px($FILonoff,80,80)
    set_text($FILonoff,"ENABLE FILTER")
    set_control_par(get_ui_id($FILonoff),$CONTROL_PAR_FONT_TYPE,$label_id)
    hide_part($FILonoff,$HIDE_PART_BG)
    
    {---KNOB TO CONTROL CUTOFF---}
    
    declare ui_slider $CUTTOF1(0,1000000) 
    set_knob_defval($CUTTOF1,500000)
    set_control_par_str(get_ui_id($CUTTOF1),$CONTROL_PAR_PICTURE,"PNG2.NAME")
    set_control_par(get_ui_id($CUTTOF1),$CONTROL_PAR_MOUSE_BEHAVIOUR,-500)
    $CUTTOF1:=get_engine_par($ENGINE_PAR_CUTOFF,-1,$FILTER_slot,1)
    move_control_px($CUTTOF1,100,180)
    make_persistent($CUTTOF1)
    read_persistent_var($CUTTOF1)
    
    {---CUTOFF LABEL---}
    
    declare ui_label $CUTlabl(1,1) 
    move_control_px($CUTlabl,100,160)
    set_text($CUTlabl,"CUTOFF")
    set_control_par(get_ui_id($CUTlabl),$CONTROL_PAR_FONT_TYPE,$label_id)
    hide_part($CUTlabl,$HIDE_PART_BG)
    
    {---LABEL TO DIPLAY CUTOFF---}
    
    declare ui_label $CUTOFF1val(1,1) 
    set_control_par_str(get_ui_id($CUTOFF1val),$CONTROL_PAR_TEXT,get_engine_par_disp($ENGINE_PAR_CUTOFF,-1,$FILTER_slot,1))
    set_control_par(get_ui_id($CUTOFF1val),$CONTROL_PAR_FONT_TYPE,18)
    move_control_px($CUTOFF1val,120,220)
    read_persistent_var($CUTOFF1val)
    make_persistent($CUTOFF1val)
    hide_part($CUTOFF1val,$HIDE_PART_BG)
    
    {---KNOB TO CONTROL RESONANCE---}
    
    declare ui_slider $RESONANCE1(0,1000000) 
    set_knob_defval($RESONANCE1,500000)
    set_control_par_str(get_ui_id($RESONANCE1),$CONTROL_PAR_PICTURE,"PNG2.NAME")
    set_control_par(get_ui_id($RESONANCE1),$CONTROL_PAR_MOUSE_BEHAVIOUR,-500)
    $RESONANCE1:=get_engine_par($ENGINE_PAR_RESONANCE,-1,$FILTER_slot,1)
    move_control_px($RESONANCE1,200,180)
    make_persistent($RESONANCE1)
    read_persistent_var($RESONANCE1)
    
    {---RESONANCE LABEL---}
    
    declare ui_label $RESlabl(1,1) 
    move_control_px($RESlabl,200,160)
    set_text($RESlabl,"RESONANCE")
    set_control_par(get_ui_id($RESlabl),$CONTROL_PAR_FONT_TYPE,$label_id)
    hide_part($RESlabl,$HIDE_PART_BG)
    
    {---LABEL TO DIPLAY RESONANCE---}
    
    declare ui_label $RESON1val(1,1) 
    set_control_par_str(get_ui_id($RESON1val),$CONTROL_PAR_TEXT,get_engine_par_disp($ENGINE_PAR_RESONANCE,-1,$FILTER_slot,1))
    set_control_par(get_ui_id($RESON1val),$CONTROL_PAR_FONT_TYPE,18)
    move_control_px($RESON1val,220,220)
    read_persistent_var($RESON1val)
    make_persistent($RESON1val)
    hide_part($RESON1val,$HIDE_PART_BG)
    
    {---KNOB TO FILTER GAIN---}
    
    declare ui_slider $FILGAIN1(0,500000) 
    set_knob_defval($FILGAIN1,500000)
    set_control_par_str(get_ui_id($FILGAIN1),$CONTROL_PAR_PICTURE,"PNG2.NAME")
    set_control_par(get_ui_id($FILGAIN1),$CONTROL_PAR_MOUSE_BEHAVIOUR,-500)
    $FILGAIN1:=get_engine_par($ENGINE_PAR_INSERT_EFFECT_OUTPUT_GAIN,-1,$FILTER_slot,1)
    move_control_px($FILGAIN1,300,180)
    make_persistent($FILGAIN1)
    read_persistent_var($FILGAIN1)
    
    {---FILTER GAIN LABEL---}
    
    declare ui_label $FILGlabl(1,1) 
    move_control_px($FILGlabl,300,160)
    set_text($FILGlabl,"FILTER GAIN")
    set_control_par(get_ui_id($FILGlabl),$CONTROL_PAR_FONT_TYPE,$label_id)
    hide_part($FILGlabl,$HIDE_PART_BG)
    
    {---LABEL TO DIPLAY FILTER GAIN---}
    
    declare ui_label $FILGAIN1val(1,1) 
    set_control_par_str(get_ui_id($FILGAIN1val),$CONTROL_PAR_TEXT,get_engine_par_disp($ENGINE_PAR_INSERT_EFFECT_OUTPUT_GAIN,-1,$FILTER_slot,1))
    set_control_par(get_ui_id($FILGAIN1val),$CONTROL_PAR_FONT_TYPE,18)
    move_control_px($FILGAIN1val,320,220)
    read_persistent_var($FILGAIN1val)
    make_persistent($FILGAIN1val)
    hide_part($FILGAIN1val,$HIDE_PART_BG)
    
    end on
    
    {---CALBACKS---}
    
    on ui_control($FILBY)
    if ($FILBY=1)
    set_engine_par($ENGINE_PAR_SEND_EFFECT_BYPASS,0,-1,$FILTER_slot,1)		
    else
    set_engine_par($ENGINE_PAR_SEND_EFFECT_BYPASS,1,-1,$FILTER_slot,1)
    end if
    end on
    
    {---MASTER VOLUME KNOB & LABEL---}
    
    on ui_control($volume)
    set_engine_par($ENGINE_PAR_VOLUME,$volume,-1,-1,-1)
    set_control_par_str(get_ui_id($volumeval),$CONTROL_PAR_TEXT,get_engine_par_disp($ENGINE_PAR_VOLUME,-1,-1,-1))
    end on
    
    {---CUTOFF KNOB & LABEL---}
    
    on ui_control($CUTTOF1)
    set_engine_par($ENGINE_PAR_CUTOFF,$CUTTOF1,-1,$FILTER_slot,1)
    set_control_par_str(get_ui_id($CUTOFF1val),$CONTROL_PAR_TEXT,get_engine_par_disp($ENGINE_PAR_CUTOFF,-1,$FILTER_slot,1))
    end on
    
    {---RESONANCE KNOB & LABEL---}
    
    on ui_control($RESONANCE1)
    set_engine_par($ENGINE_PAR_RESONANCE,$RESONANCE1,-1,$FILTER_slot,1)
    set_control_par_str(get_ui_id($RESON1val),$CONTROL_PAR_TEXT,get_engine_par_disp($ENGINE_PAR_RESONANCE,-1,$FILTER_slot,1))
    end on
    
    {---FILTER GAIN KNOB & LABEL---}
    
    on ui_control($FILGAIN1)
    set_engine_par($ENGINE_PAR_INSERT_EFFECT_OUTPUT_GAIN,$FILGAIN1,-1,$FILTER_slot,1)
    set_control_par_str(get_ui_id($FILGAIN1val),$CONTROL_PAR_TEXT,get_engine_par_disp($ENGINE_PAR_INSERT_EFFECT_OUTPUT_GAIN,-1,$FILTER_slot,1))
    end on
    
    Works fine but will need default values etc tweaking.

    Any problems give us a shout :wink:
     
  6. m4xst4r2015

    m4xst4r2015 Member

    Joined:
    May 13, 2015
    Messages:
    24
    Likes Received:
    10
    @Clandestine
    Thank you, and I really do appreciate your effort here .
    But your reply confused me a bit ...
    First of all I don`t wanna try the script you sent, since I don`t really understand anything from it, I wanted to use a script I`ve typed. :(
    Here is some points I want you to read :
    1 - The ( VOLUME - CUTOFF - RESO ) buttons I`ve made they have problems ,,,, they are enabled automatically at the beginning ( As you mentioned ), so should I add this line at initiation : " set_engine_par($ENGINE_PAR_EFFECT_BYPASS,1,-1,0,1) ", if not then what should I do to fix it ?
    2 - I wanted to replace ( VOLUME ) with ( TUNE ), so should I replace this " set_engine_par($ENGINE_PAR_VOLUME,$switcher1, -1, 0, 1) " with this " set_engine_par($ENGINE_PAR_TUNE,$switcher1, -1, 0, 1) " ?
    3 - I have no problem with ( VOLUME - CUTOFF - RESO ) labels , since I included them and typed them as text on the instrument skin .
    4 - I still have no idea how to assign an image to ( Filter ON / OFF ) button, is it okay if I add this line : " set_control_par_str(get_ui_id($power), $CONTROL_PAR_PICTURE, "my_image") ?
    5 - I don`t get the Re-size part ? should I just add this lines :
    set_control_par(get_ui_id($power),$CONTROL_PAR_HEIGHT,50)
    set_control_par(get_ui_id($power),$CONTROL_PAR_WIDTH,50) ?


    Additional things :
    1 - How to customize my instrument ICON ?
    2 - How to make some animation on the skin ? is it something related to make the skin picture file as " .gif " extension ?

    Please Next time you are helping me I would prefer you to explain the scripts you are giving me .

    Thanks in advance
     
  7. Clandestine

    Clandestine Platinum Record

    Joined:
    Nov 11, 2013
    Messages:
    717
    Likes Received:
    152
    I'm simply writing them as an example & not saying use them.

    As I mentioned there many ways of doing things & how u choose to do it is up to you.

    I could't see the image the first time I posted.

    From the image I can see u have volume, pitch, cutoff, Distortion & Resonance.

    That's cool but before I go any further it would be good if you could explain what samples your instrument is based on/how many groups it contains etc.

    There is reasoning behind this.

    As I mention when it comes to volume, well u have to decide what volume your knob is going to control.

    For example is it meant to control master volume or the output gain of a compressor or filter or an instrument grouping etc. This will dictate how you must write your script.

    You have a knob for distortion. How do you intend to distort your samples? Are u going to use the screamer, Distortion or saturation as insert FX or in a different way. Again this will affect your script.

    Two of your Knobs refer normally to a filter i.e cutoff & resonance. Again what filter do you intend to use. Kontakt 5 has 37 different filters! Which do u intend to use and on what level are you going to place it?

    Tuning can be changed in different ways. Normally thru certain commands etc & there are diferrent ways of doing it.

    I think you should start with making a resource folder, reading about what goes in the various folders etc & then choosing the images/animations you intend to use. Your background is not important really at this stage.

    Until you make these decisions the script cannot really proceed as what you want to accomplish will dictate the nature of the script itself.

    You can use various formats for graphics. Mainly .png & tga but others also.

    Your icon has to be a certain size i.e around 34x38 pixels or so & u have to manipulate these in an image editor. You should include an alpha channel. For every picture u need an accompanying text file that describes the picture. These should be encoded in ANSI & sit with the pictures in the pictures folder in the resources folder. These all eventually will be encoded and contained within the final .NKR

    For animations for example you have to describe in the text file how many animation frames there are whether they horizontal or vertical, resizable, alpha channel etc.

    I suggest also that u learn how to use the program Knobman as it excellent for making knobs, sliders etc & can be which can be made vertically or horizontally both of which Kontakt can utilise.

    Kontakt does not support GIF format. You can only use PNG or TGA but u can convert an animated GIF into a png sprite and declare it as a label.

    I would recommend u stick with png and learn how to use knobman. Also be aware that complicated animations can use up CPU which can sometime be better utilized somewhere else. However something pretty simple is no problem.

    You MUST read the KSP reference guide as it is really imortant & most of the relevant information is contained there.

    Also get hold of a copy of the kontakt player developer guide as there some good info there.

    If you give me some more info on what u intend to do I am more than happy to help. :wink:
     
  8. m4xst4r2015

    m4xst4r2015 Member

    Joined:
    May 13, 2015
    Messages:
    24
    Likes Received:
    10
    Thanks again @clandestine for responding .

    Let me explain all of your inquiries and answer them as a quotes, so you got clear point here :
    Answer : I am doing cinematic sound effects ( Impacts - Risers - Hits - .... etc ) a one hit wav, without looping.
    *********************************************************************
    Answer : I really feel ashamed to tell you I don`t know what dose groups means until now, I`ve read this word ( groups ) so many times around, but I don`t know what its related to until now :(.
    *********************************************************************
    *********************************************************************
    Answer : This is cool thing, because I don`t know about this things yet, so tell me what is different between the volume control types so I can decide which one should I choose :
    1 - output gain of a compressor volume ?
    2 - filter volume ?
    3 - instrument volume ?
    4 - I think master volume is the main instrument volume , so are (master volume) & (instrument volume) are same ?
    *********************************************************************
    Answer : at the first time I felt that I should add distortion since its related to cinematic sound effects but I found its kind a hard thing to do so due adding a lot of scripts.
    Therefore if adding a distortion will take me a long time, I will just be satisfied with ( TUNE – CUTOFF – RESONANCE )
    Anyway if you feel ok to explain to me what is the difference between ( Screamer - Distortion – Saturation ) and how hard to me to add their scripts just go on and give me a short brief about them.
    *********************************************************************
    Answer : My cutoff & resonance are working perfectly, what is the wrong with them ? I mean I don`t know what are you talking about ( the filter type & filter level ) ?
    *********************************************************************
    Answer : Well I just want the cinematic sound effects samples I am playing due the instrument keyboard just could be tuned or pitched little bit higher or lower so it gives a different sound. I don`t want anything complex.
    *********************************************************************
    Answer : I have a resource folder, I`ve created one already
    I press on ( Wrench icon / Instrument options button / on the Instrument tab I choose create resource container which is “resource.nkr” / then a folder have been created )
    You are saying “ Your background is not important really at this stage “ so I understand that I will forget about adding animations to my Instrument skin.
    *********************************************************************
    Answer : I can understand how knobs works, in the picture folder of Instrument resource folder , there is 2 files I have understand how they work, the knob picture and the knob txt, in the knob txt file I describe how the knob act in kontakt, so I have quite understanding about how knobs working, I even creating my own knobs with other softwares, so I am not facing any problems with knobs.
    But by the way ( I can see that the animated knob PNG file is 50px X 5050px contains 101 frame which are already described in the txt file, my the question is, what is the dimensions of the single frame ? “the knob it self in kontakt” )
    *********************************************************************
    Answer : I`ve downloaded the PDF file, and read a lot of things, but still confused that is why I am asking you. So I really appreciate your effort of helping me here.
    *********************************************************************
    At the ends of the quotes I would describe what is the summary of what I intend to do :
    A simple cinematic sound effects instrument can be affected by 3 or 4 konbs
    Maybe : Tune - Distortion - Cutoff - Resonance , and anything else that make my samples sound different, in intend to make different choices and unlimited affected sounds.
    Again I would like to make animations on my background but I would follow your command and forget about it if its not necessary as you mentioned.
    NOTE : IF YOU REPLIED TO ME PLEASE USE QUOTES SO I CAN UNDERSTAND WHERE YOU REFER
    Thanks again and sorry if I am making this heavy on you.

    MAX
     
  9. Clandestine

    Clandestine Platinum Record

    Joined:
    Nov 11, 2013
    Messages:
    717
    Likes Received:
    152
    Ok Cool.

    Will start firstly with GROUPS

    AN instrument on Kontakt can be made up of one or more GROUPS of samples.

    So for say example in your case u are using

    So u take your Wav file enter it in your mapping editor.

    U then will either extend the range of that wav sample up & down etc or load more samples that u have stored until u have mapped out the range u want.

    U have otions in that u could save each one hit individually as an NKI or u could say design an interface that plays certain groups of samples.

    For example in your case you could layer in more samples and have performance view controls to play certain groupings on demand etc.

    However to keep things simple just use an example where u use one wav file either extended up & down or mapped out with more samples.

    Be aware that if you increase the range up & down of the sample it will affect the speed in real time playback if u simply extend the range of one sample

    Your cutoff & resonance may work fine and that's cool. What I meant was which filter are u using? A simple Low pass filter, An effect filter such as a formant filter or say a 3x2 multi filter. If you are just using a simple low pass filter etc then cool but where u place your filter will affect the script.

    If you simply want to change the tuning up and down a couple of octaves then great, that's easy enough and you could even use some of the factory scripts to help u out.

    Right well that means that your image is 50 px wide by 5050px vertically and is made up of 101 animations for the knob. So if u divide 5050/101 it gives u exactly 50!! That means one instance of your png is exacly 50px by 50px.

    Therefore when you declare your slider to describe the knob u have to use the commands I wrote above to describe the size i.e 50x50

    i.e

    set_control_par(get_ui_id($NAME),$CONTROL_PAR_HEIGHT,50)
    set_control_par(get_ui_id($NAME),$CONTROL_PAR_WIDTH,50)

    That part is up to you & only u. Below is a script that declares a simple slider that controls master volume & also gives u a label to show the value & also displays the units. You can't normally set simple default values for units & values when declaring a slider so as stated u have to declare a label and use that instead. If you wanted it to control the output gain of a compressor u would have to use the relevant engine parameters to describe. They all referenced in the KSP reference manual *yes*

    Code:
    on init
    declare ui_slider $vol_slider (0,1000000)
    declare $vol_slider_id
    $vol_slider_id := get_ui_id ($vol_slider)
    set_control_par ($vol_slider_id,$CONTROL_PAR_DEFAULT_VALUE,630859)
    $vol_slider := get_engine_par ($ENGINE_PAR_VOLUME,-1,-1,-1)
    set_control_par_str ($vol_slider_id,$CONTROL_PAR_LABEL,...
    get_engine_par_disp($ENGINE_PAR_VOLUME,-1,-1,-1) & " dB")
    
    declare ui_label $vol_label (1,1)
    set_text ($vol_label,get_engine_par_disp($ENGINE_PAR_VOLUME,-1,-1,-1) & " dB")
    end on
    on ui_control ($vol_slider)
    set_engine_par($ENGINE_PAR_VOLUME,$vol_slider,-1,-1,-1)
    set_control_par_str ($vol_slider_id,$CONTROL_PAR_LABEL,...
    get_engine_par_disp($ENGINE_PAR_VOLUME,-1,-1,-1) & " dB")
    set_text ($vol_label,get_engine_par_disp($ENGINE_PAR_VOLUME,-1,-1,-1) & " dB")
    end on
    
    As I said earlier for animations Kontakt does not recognise GIF

    You can only use PNG or TGA format but u could convert an animated GIF into a png sprite.

    If you think about it a knob is just the same it's basically an animation. Therefore for every animation you will need a text file that accurately describes the animation.

    You will then need to decide what is going to trigger the animation i.e using the on note command so that it plays when you play a note or the on listener command. Your text file MUST be accurate in describing the number of animations etc. They both described in KSP reference.

    Again how u do things is up to u.

    If u need any help with a part of the script just put it down & will help if i able.

    Best of luck :wink:
     
  10. MarcoB

    MarcoB Newbie

    Joined:
    Mar 21, 2023
    Messages:
    2
    Likes Received:
    0
    @Clandestine: first time here, sorry I'm not so accustomed with forums tools , tried to quote your beautiful script posted before (here below after my explanation and inquiry). your script worked fine but left me a big not understandable question :) it's obvious that I'm doing something wrong and I'm ignoring something that's fundamental but still I can't get what this is.
    I'va tried to control the gain parameter according to your script, I've put a message command after the instructions and I can see the value changing in the status bar, also if I change the value and press the same midi KEY I can hear the effect in place, so basically it works but I can't explain while in the Kontakt backend GUI (not my front-end GUI) I can't see the GAIN knob moving according to the value of the gain slider that I have placed on my front-end GUI... :-( What' I am doing wrong ?
    I've also tried to control the gain parameter at group level, instrument send FX level or instrument insert FX level but I can't see those knobs moving...
    Can you teach me what I'm doing wrong or why this happens, please? Please look at the enclosed picture.
    PS: I have commented the bypass filter, of course and the remote control of cutoff and resonance at the same level are showing the knobs moving like expected, but not the gain one! I'm mad for this :)

    These are the points I've tried to control with the engine parameters and different coordinates <group><slot><generic> with no expected behaviour.

    Kontakt_controls_issue.jpg
     
    Last edited: Apr 2, 2023
Loading...
Similar Threads - Scripting Simple Instrument Forum Date
KSP Kontakt scripting issues with custom knob and velocity value to mirror on play note (visual FX) Kontakt Mar 21, 2023
Anyone familiar with scripting in Presence XT? Studio One Sep 22, 2019
Kontakt Scripting Kontakt Jul 27, 2017
Tutorials for Kontakt Scripting? Kontakt Jun 26, 2017
Kontakt Scripting - Building an Instrument From Scratch AudioSex Academy Aug 5, 2015
Loading...