"Multiscript" Kontakt 6 for switching instruments in the "instrument bank" on midi controller.

Andrey
Andrey Member Posts: 21 Member
edited September 2022 in Scripting Workshop

Please tell me multiscript Kontakt 6 for switching instruments in the "instrument bank" on my midi controller (midi commander - meloaudio).

All my instruments are on midi channel "A": 1,2,3,4,5,6,7,8 channels.

Multiscript should disable all other instruments (midi channels) when switching to the next instrument, and the solo instrument should sound (because the CPU can't handle it).

I use the buttons on the foot switch: CC # 22, 25, 24, 26, 101, 113, 114, 115 (this is in 127).

Please suggest the best solution for my case.

I'm using Windows 10 Pro 64-bit. I use Kontakt 6.2.2 via "Midi bass 2" (Jam Origin).

«1

Comments

  • Kaiwan_NI
    Kaiwan_NI Administrator Posts: 2,546 admin

    Hi @EvilDragon maybe something for you? 😀

  • Andrey
    Andrey Member Posts: 21 Member

    Thank you Kaiwan_NI!

    Yes, I have heard about this legend! A man whose wings can dispel any problems with music software!

    Thanks for the contact  @EvilDragon!
    


  • Kaiwan_NI
    Kaiwan_NI Administrator Posts: 2,546 admin

    Did you two get in touch already?

  • Andrey
    Andrey Member Posts: 21 Member

    Yes, I wrote personally to @EvilDragon. Unfortunately, he hasn't answered me yet. 

    I have studied a lot of scripts, including on the old forum. This one suits me best:

  • Andrey
    Andrey Member Posts: 21 Member
    edited August 2022
    on init
      set_script_title("MIDI Channel Redirect")
    
      declare ui_button $Channel1
      declare ui_button $Channel2
      declare ui_button $Channel3
      declare ui_button $Channel4
      declare ui_button $Channel5
      declare ui_button $Channel6
      declare ui_button $Channel7
      declare ui_button $Channel8
      declare ui_button $Channel9
      declare ui_button $Channel10
      declare ui_button $Channel11
      declare ui_button $Channel12
      declare ui_button $Channel13
      declare ui_button $Channel14
      declare ui_button $Channel15
      declare ui_button $Channel16
      declare $i
      declare $prev_ch
      declare $sel_ch := -1
    
      make_persistent($Channel1)
      make_persistent($Channel2)
      make_persistent($Channel3)
      make_persistent($Channel4)
      make_persistent($Channel5)
      make_persistent($Channel6)
      make_persistent($Channel7)
      make_persistent($Channel8)
      make_persistent($Channel9)
      make_persistent($Channel10)
      make_persistent($Channel11)
      make_persistent($Channel12)
      make_persistent($Channel13)
      make_persistent($Channel14)
      make_persistent($Channel15)
      make_persistent($Channel16)
      make_persistent($sel_ch)
    
      $i := 0
      while ($i < 16)
       set_control_par_str(get_ui_id($Channel1) + $i,$CONTROL_PAR_TEXT,"Channel " & $i + 1)
       set_control_par(get_ui_id($Channel1) + $i,$CONTROL_PAR_GRID_X,($i mod 4) + 1)
       set_control_par(get_ui_id($Channel1) + $i,$CONTROL_PAR_GRID_Y,($i / 4) + 1)
       inc($i)
      end while
    
      message("")
    end on
    
    function SelChannel()
      if ($prev_ch # -1)
       $i := 0
       while ($i < 16)
        if ($i = $sel_ch)
         set_control_par(get_ui_id($Channel1) + $i,$CONTROL_PAR_VALUE,1)
        else
         set_control_par(get_ui_id($Channel1) + $i,$CONTROL_PAR_VALUE,0)
        end if
        inc($i)
       end while
    
       set_midi($prev_ch,$MIDI_COMMAND_CC,64,0)
       $i := 0
       while ($i < 128)
        set_midi($prev_ch,$MIDI_COMMAND_NOTE_ON,$i,0)
        inc($i)
       end while
      end if
    end function
    
    on ui_control ($Channel1)
      $prev_ch := $sel_ch
      $sel_ch := -1 + $Channel1
      call SelChannel()
    end on
    
    on ui_control ($Channel2)
      $prev_ch := $sel_ch
      $sel_ch := -1 + (2 * $Channel2)
      call SelChannel()
    end on
    
    on ui_control ($Channel3)
      $prev_ch := $sel_ch
      $sel_ch := -1 + (3 * $Channel3)
      call SelChannel()
    end on
    
    on ui_control ($Channel4)
      $prev_ch := $sel_ch
      $sel_ch := -1 + (4 * $Channel4)
      call SelChannel()
    end on
    
    on ui_control ($Channel5)
      $prev_ch := $sel_ch
      $sel_ch := -1 + (5 * $Channel5)
      call SelChannel()
    end on
    
    on ui_control ($Channel6)
      $prev_ch := $sel_ch
      $sel_ch := -1 + (6 * $Channel6)
      call SelChannel()
    end on
    
    on ui_control ($Channel7)
      $prev_ch := $sel_ch
      $sel_ch := -1 + (7 * $Channel7)
      call SelChannel()
    end on
    
    on ui_control ($Channel8)
      $prev_ch := $sel_ch
      $sel_ch := -1 + (8 * $Channel8)
      call SelChannel()
    end on
    
    on ui_control ($Channel9)
      $prev_ch := $sel_ch
      $sel_ch := -1 + (9 * $Channel9)
      call SelChannel()
    end on
    
    on ui_control ($Channel10)
      $prev_ch := $sel_ch
      $sel_ch := -1 + (10 * $Channel10)
      call SelChannel()
    end on
    
    on ui_control ($Channel11)
      $prev_ch := $sel_ch
      $sel_ch := -1 + (11 * $Channel11)
      call SelChannel()
    end on
    
    on ui_control ($Channel12)
      $prev_ch := $sel_ch
      $sel_ch := -1 + (12 * $Channel12)
      call SelChannel()
    end on
    
    on ui_control ($Channel13)
      $prev_ch := $sel_ch
      $sel_ch := -1 + (13 * $Channel13)
      call SelChannel()
    end on
    
    on ui_control ($Channel14)
      $prev_ch := $sel_ch
      $sel_ch := -1 + (14 * $Channel14)
      call SelChannel()
    end on
    
    on ui_control ($Channel15)
      $prev_ch := $sel_ch
      $sel_ch := -1 + (15 * $Channel15)
      call SelChannel()
    end on
    
    on ui_control ($Channel16)
      $prev_ch := $sel_ch
      $sel_ch := -1 + (16 * $Channel16)
      call SelChannel()
    end on
    
    on midi_in
      if ($sel_ch # -1)
       ignore_midi
       set_midi($sel_ch,$MIDI_COMMAND,$MIDI_BYTE_1,$MIDI_BYTE_2)
      end if
    end on
    
  • Andrey
    Andrey Member Posts: 21 Member

    But this script is not for my buttons: CC # 22, 25, 24, 26, 101, 113, 114, 115

  • Andrey
    Andrey Member Posts: 21 Member
    edited September 2022

    Help me....

  • EvilDragon
    EvilDragon Moderator Posts: 1,023 mod

    Hmmm, if I understood the issue, it might be something like this:

    on init
        declare %buttonCC[128]
        %buttonCC[22] := 1
        %buttonCC[25] := 1
        %buttonCC[24] := 1
        %buttonCC[26] := 1
        %buttonCC[101] := 1
        %buttonCC[113] := 1
        %buttonCC[114] := 1
        %buttonCC[115] := 1
        declare %state[128]
        declare %progchange[128] := (-1)
        %progchange[22] := 0
        %progchange[25] := 1
        %progchange[24] := 2
        %progchange[26] := 3
        %progchange[101] := 4
        %progchange[113] := 5
        %progchange[114] := 6
        %progchange[115] := 7
    
        make_persistent(%state)
    end on
    
    on midi_in
        if ($MIDI_CHANNEL = 0)
            if ($MIDI_COMMAND = $MIDI_COMMAND_CC and %buttonCC[$MIDI_BYTE_1] = 1)
                if ($MIDI_BYTE_2 / 64 # %state[$MIDI_BYTE_1])
                    %state[$MIDI_BYTE_1] := 1 - %state[$MIDI_BYTE_1]
    
                    if (%state[$MIDI_BYTE_1] = 1)
                        set_midi($MIDI_CHANNEL, $MIDI_COMMAND_PROGRAM_CHANGE, %progchange[$MIDI_BYTE_1], 0)
                    end if
                end if
            end if
        end if
    end on
    
  • Andrey
    Andrey Member Posts: 21 Member
    edited September 2022

    Dear EvilDragon, thank you for responding to my request!

    I will try to explain my problem more correctly and recorded a short video. The task is simple. I have 8 instruments. I need to switch them on my Midi Commander. I found the script of the "Solo" "Mute" buttons, but it's not convenient. It is necessary that when you press the Midi Commander button (CC 22), the first channel is turned on and only it sounds (the rest should be inactive so that they do not use CPU resources). And so on.. When you click on the second button on the Midi Commander, the second tool was turned on (all others so that they were not active).

  • Andrey
    Andrey Member Posts: 21 Member
    edited September 2022

    Maybe I don't need to use all 8 Midi channels, but only use the first Midi channel? Or in this case, on the contrary, the CPU will use more resources?

    The fact is that for some unknown reason, only the first Midi Channel is played.

    Using Kontakt 6.2 via Program Jam Origin - Midi Bass 2.

    (WIndows 10 pro. Sound card - Focusrite Solo 3 gen)

  • EvilDragon
    EvilDragon Moderator Posts: 1,023 mod

    The multiscript I sent you only works on MIDI channel 1, yes, because you have showed me an instrument bank in the first post, so I thought you were using an instrument bank with 8 patches loaded, which would mean you needed to convert MIDI CCs to MIDI Program Change messages. So I did that. Try to use instrument bank for what you want to do?


    Also, if you go to Kontakt's Options->Engine, make sure to enable multiprocessor support. This should help bring down CPU usage to an extent.

  • Andrey
    Andrey Member Posts: 21 Member
    edited September 2022
    Thanks for the reply, EvilDragon! Yes, I was not careful. I apologize.
    Your musical script works! But not for long...
    
    After pressing buttons on the midi controller, for example "CC22", the multiscript stops working and no longer toggles this button.
    (video recorded)  https://youtu.be/ZoHsi69xiFU
    
    Is it possible for the switching limit to be unlimited?
    


  • Andrey
    Andrey Member Posts: 21 Member
    edited September 2022

    My inner muse tells me that I am at the finish line.

    I'm sure you'll come back and give me an answer, EvilDragon

Back To Top