Kontakt Script for controling midi channel by keyswitch range

Discussion in 'Kontakt' started by metaller, May 4, 2018.

  1. metaller

    metaller Platinum Record

    Joined:
    May 28, 2016
    Messages:
    398
    Likes Received:
    191
    Location:
    Persia
    I want to edit this kontakt multiscript to control several multi keyswitch instruments loaded in kontakt by one midi input.
    For example, If I send a keyswitch between C-2 to F-2, it will send the notes and keyswitch to midi channel 1. and if I send a keyswtich between F#-2 to C-1, it will send the notes to midi channel 2.
    I want to control the midi channel, and keyswitch. So I don't want to my keyswitch not be send to the instruments in kontakt, but sent to the correct midi channel.
    If anyone knows the Kontakt language, please help me.

    by the way, the GUI is not that much important
    Code:
    on init
    set_ui_height_px(65)
    set_script_title("KS Router, Input Ch. " & ($CURRENT_SCRIPT_SLOT+1))
    declare ui_value_edit $shzzf(0, 127, $VALUE_EDIT_MODE_NOTE_NAMES)
    declare ui_value_edit $zvhw5(1, 64, 1)
    declare ui_value_edit $ocls0(1, 64, 1)
    set_control_par(get_ui_id($shzzf),$CONTROL_PAR_WIDTH,200)
    set_control_par(get_ui_id($shzzf),$CONTROL_PAR_POS_X,60)
    set_control_par(get_ui_id($shzzf),$CONTROL_PAR_POS_Y,0)
    set_control_par(get_ui_id($zvhw5),$CONTROL_PAR_WIDTH,200)
    set_control_par(get_ui_id($zvhw5),$CONTROL_PAR_POS_X,60)
    set_control_par(get_ui_id($zvhw5),$CONTROL_PAR_POS_Y,20)
    set_control_par(get_ui_id($ocls0),$CONTROL_PAR_WIDTH,200)
    set_control_par(get_ui_id($ocls0),$CONTROL_PAR_POS_X,60)
    set_control_par(get_ui_id($ocls0),$CONTROL_PAR_POS_Y,40)
    declare ui_button $ys340
    set_control_par(get_ui_id($ys340),$CONTROL_PAR_WIDTH,58)
    set_control_par(get_ui_id($ys340),$CONTROL_PAR_POS_X,260)
    set_control_par(get_ui_id($ys340),$CONTROL_PAR_POS_Y,0)
    set_text($ys340,"MIDI Learn")
    declare ui_label $sdeud(0, 0)
    set_control_par(get_ui_id($sdeud),$CONTROL_PAR_WIDTH,200)
    set_control_par(get_ui_id($sdeud),$CONTROL_PAR_POS_X,260)
    set_control_par(get_ui_id($sdeud),$CONTROL_PAR_POS_Y,40)
    set_control_par(get_ui_id($sdeud),$CONTROL_PAR_HIDE,$HIDE_PART_BG)
    set_text($shzzf,"Starting Note")
    set_text($zvhw5,"Total Keyswitches")
    set_text($ocls0,"Starting Channel")
    make_persistent($shzzf)
    make_persistent($zvhw5)
    make_persistent($ocls0)
    read_persistent_var($shzzf)
    read_persistent_var($zvhw5)
    read_persistent_var($ocls0)
    declare !tn4mp[4]
    !tn4mp[0] := "A"
    !tn4mp[1] := "B"
    !tn4mp[2] := "C"
    !tn4mp[3] := "D"
    declare $mzttt
    declare $lxlj5
    declare $voil2
    $mzttt := $ocls0
    set_text($sdeud,"(Port " & !tn4mp[($ocls0-1)/16] & ", Channel " & (($ocls0-1) mod 16+1) & ")")
    message("")
    end on
    
    on ui_control($ocls0)
    set_text($sdeud,"(Port " & !tn4mp[($ocls0-1)/16] & ", Channel " & (($ocls0-1) mod 16+1) & ")")
    end on
    
    on midi_in
    if ($MIDI_COMMAND=$MIDI_COMMAND_NOTE_ON and ($MIDI_BYTE_2 # 0) and ($ys340=1))
    ignore_midi
    $ys340 := 0
    $shzzf := $MIDI_BYTE_1
    exit
    end if
    if ($MIDI_CHANNEL=$CURRENT_SCRIPT_SLOT)
    ignore_midi
    if ($MIDI_COMMAND=$MIDI_COMMAND_NOTE_ON and ($MIDI_BYTE_2 # 0) and in_range($MIDI_BYTE_1,$shzzf,$shzzf+($zvhw5-1)))
    $lxlj5 := $MIDI_BYTE_1-$shzzf
    $mzttt := $lxlj5+$ocls0
    message("Routing to MIDI Channel " & $mzttt)
    else
    if ($MIDI_COMMAND=$MIDI_COMMAND_NOTE_ON and ($MIDI_BYTE_2 # 0))
    set_midi($mzttt-1,$MIDI_COMMAND,$MIDI_BYTE_1,$MIDI_BYTE_2)
    else
    $voil2 := $ocls0
    while ($voil2<=($ocls0+($zvhw5-1)))
    set_midi($voil2-1,$MIDI_COMMAND,$MIDI_BYTE_1,$MIDI_BYTE_2)
    inc($voil2)
    end while
    end if
    end if
    end if
    end on
    


     

    Attached Files:

  2.  
  3. phloopy

    phloopy Audiosexual

    Joined:
    Jul 16, 2011
    Messages:
    2,581
    Likes Received:
    801
    Do you know about VI Control?

    That´s a good place for issues like this!
     
  4. metaller

    metaller Platinum Record

    Joined:
    May 28, 2016
    Messages:
    398
    Likes Received:
    191
    Location:
    Persia
    Best Answer
  5. safran5020

    safran5020 Platinum Record

    Joined:
    Dec 15, 2011
    Messages:
    328
    Likes Received:
    268
    Location:
    La Belle Province
Loading...
Similar Threads - Kontakt Script controling Forum Date
Does anybody have the Kontakt 5 factory scripts? Samplers Sep 18, 2017
Kontakt Scripting Kontakt Jul 27, 2017
Tutorials for Kontakt Scripting? Kontakt Jun 26, 2017
Wanted: Kontakt Scripter!! Collaborations Aug 6, 2016
How can I edit password protected script on Kontakt 5.5.2 R2R? Kontakt Jul 1, 2016
Loading...