How to script switches that toggle in Kontakt

Поділитися
Вставка
  • Опубліковано 11 вер 2024
  • In this video I'll demonstrate how to create multiple switches that toggle so that only one of the group of switches can be on at a time.
    💗 Likecoin - Coins for Likes: likecoin.pro/@...

КОМЕНТАРІ • 45

  • @angelooo23gr
    @angelooo23gr 9 місяців тому

    man i am just start to try learn kontakt scripting your video stil work perfect from what i see is 8 years ago thank you for this my english is not good sory about this you help me alot to understant how all this work realy thank you subscribe 1000000000000000% thank you for share

  • @JeshuaW
    @JeshuaW 8 років тому

    Thank you so much for these videos! Will be getting your tutorials asap. :)

  • @christopherphillips7871
    @christopherphillips7871 3 роки тому

    Great Work! :)

  • @simonturner1
    @simonturner1 4 роки тому

    Is there a script/option that can do this for the Kontakt keyboard i.e. so the utilised keyswitch visually remains pressed until you switch articulation, as happens in professional libraries?

    • @Xtant-audio
      @Xtant-audio  4 роки тому

      If I remember correctly all you can do is change the key colour when the keyswitch is activated or deactivated.

  • @visa-schengenwf424
    @visa-schengenwf424 7 років тому +1

    hello sir
    i'd love to know how to do it with 3 switches
    if i wasn't wrong we add a third parameter in the function
    Function toggle(Swt1 , swt2 ,swt3) and we do
    if swt1 := 1
    swt2 := 0
    swt3 := 0
    end if
    on ui_control (switch1) we do
    toggle(Swt1 , swt2 ,swt3) end on
    on ui_control (switc2) we do
    toggle(Swt2 , swt1 ,swt3) end on
    on ui_control (switch3) we do
    toggle(Swt3 , swt2 ,swt1) end on
    i think it's like this

    • @Xtant-audio
      @Xtant-audio  7 років тому +2

      Why don't you watch the video and your question will be answered

    • @visa-schengenwf424
      @visa-schengenwf424 7 років тому +1

      ok i re-watched the video and i got the base (algorithm) on how it works
      Thank you david

  • @zaharishtonov
    @zaharishtonov 7 років тому +1

    Hi David,
    I've been following along your code in Sublime and I am getting a parse error on line 17. I have Kontakt 5.6.5. I've been noticing a few differences in some of your other tutorials too, that I had to look into the KSP Reference Manual in order to slightly rewrite the code to make it work. I am hitting a dead end on this one...

    • @Xtant-audio
      @Xtant-audio  7 років тому

      Is the error occurring on a generic piece of KSP or is it something that has been added in K5.6.5?

    • @zaharishtonov
      @zaharishtonov 7 років тому

      It simply doesn't like the format of the function being declared. I don't think they would change that. But again, I am not really sure. This is the code for it bellow, just to remind you what it was:
      -------
      17 function toggle_switches (switch_id) { parse error is here highlighted in red in Kontakt }
      18
      19 declare $i
      20
      21 for $i := to num_elements(%ids) -1
      22 if (%ids[%i] # switch_id)
      23 %ids[%i] -> VALUE := 0
      24 end if
      25 end for
      -------

    • @Xtant-audio
      @Xtant-audio  7 років тому

      Okay, well first of all you are using [%i] instead of [$i] so that won't help, but are you pasting this straight into Kontakt without compiling it?

    • @zaharishtonov
      @zaharishtonov 7 років тому

      David,
      Thank you for your reply! Your question has solved the problem immediately ( I wanted to facepalm my forehead as soon as I read "compile") Hah! I am also glad I've copied pieces of the code above, although I must've mistyped some of it there. It's pretty late here. Of course, variables are indicated with a "$" in KSP.
      Thank you very much again for your response! You made me feel very comfortable now taking your scripting classes online. I am an educator too (in another area) and I have to say - you have a great style of relaying information to others :)
      Cheers!

    • @Xtant-audio
      @Xtant-audio  7 років тому +1

      Excellent, I'm glad it's solved the issue, these things can sometimes be tricky to pin down. And thanks for the kind words!

  • @AUDIOARTESTUDI
    @AUDIOARTESTUDI 4 роки тому

    Hello David from Barcelona.
    First of all, congratulations for your videos, very instructive.
    My question for you is the next: I try to create several instruments in kontatk now, but I have a problem when i want to create key switches. Well, create the key switches is easy. But, and this is the frustrating part for me, when i load the instrument doensen’t sound! I have to play a key switch to ear the sound. Do yo know the solution?
    Thak you very mutch

    • @Xtant-audio
      @Xtant-audio  4 роки тому +1

      Take a look in the instrument options, there is a setting for default key switch.

    • @AUDIOARTESTUDI
      @AUDIOARTESTUDI 4 роки тому +1

      @@Xtant-audio Amazing, David. Thank you very much! My frustration has been solved!

  • @jesedlijo
    @jesedlijo 5 років тому

    Hello David, this is amazing. it meets most of my need but my case is I don’t want switches to turn on and off independently. Pressing the button should turn on but it should not off when I press it again. It should be off only when I toggle to other button. Kind of latch function. Can you pls help me with the code for this?

    • @Xtant-audio
      @Xtant-audio  5 років тому +1

      Hi Paul, I haven't done much work in KSP for a couple of years so I can't give exact code. But what you'll need to do is run a loop when a button is pressed that turns off all other buttons and turns on the button that was clicked.

  • @waliddjouad3639
    @waliddjouad3639 4 роки тому

    Thank you for the explanation, but I have a question, please
    How to scripting legato work with arabic scales without any problem whene playing with kontakt ?

    • @Xtant-audio
      @Xtant-audio  4 роки тому

      I don't know, but someone asked on the vi-control forum a few days ago, so check that out.

  • @utterssssssssss
    @utterssssssssss 6 років тому

    Question: Would it be possible to create a toggle group where one switch HAS to be on at all times? i.e you can switch between them, but you can't actually have them all off at the same time. One has to be active. Cheers!

    • @Xtant-audio
      @Xtant-audio  6 років тому

      Yeah I do that all the time when I set up buttons for switching articulations.

    • @Xtant-audio
      @Xtant-audio  4 роки тому

      @@tomparrymusic Not really something I can explain in a comment. Search the VI-Control forum, it's probably already been asked there.

  • @TheStrickland94
    @TheStrickland94 6 років тому

    Hi David,
    I want to place 4 or 5 buttons on the UI each with their own PNG graphics, each linked to a sample group. You can click on them to toggle the button from being visible or invisible, while enabling or disabling a sample group respectively.
    Do you have a tutorial for this?
    Thanks

    • @Xtant-audio
      @Xtant-audio  6 років тому

      That's very specific, I don't have a tutorial for that. But if you can make one button do what you want then you will be able to make as many buttons do it, so start with one button and work from there.

    • @TheStrickland94
      @TheStrickland94 6 років тому +1

      Thanks for replying - I managed it in the end (found a forum post with someone wanting to do the same thing to toggle mic position options). Works like a charm.

    • @ThePlwd
      @ThePlwd Рік тому

      @@TheStrickland94 such a long shot but do you remember where you found it?! im trying to do the same thing

  • @jamesbarrow7489
    @jamesbarrow7489 6 місяців тому

    I’m new to scripting, but I cannot seem to figure out what I need to do this. I simply have a Midi latch script in Kontakt 7 that I need to be able to turn the preset bypass on and off with a cc message remotely.
    Seems like this would be really simple to do but you cannot simply assign a cc to the bypass button, so does anyone know of a way around this? Thanks in advance!!!

    • @Xtant-audio
      @Xtant-audio  6 місяців тому

      I'm not much help here, I haven't written any KSP in years. Hopefully someone else will chip in, you can also ask on the VI Control KSP forum.

  • @zaharishtonov
    @zaharishtonov 7 років тому

    Hello David,
    I have another issue. Not with the original format of the script. Everything has been working fine until I've decided to set a second set of switches (3 of them) and make them do the same exact thing, but on their own. I have declared everything completely separately: buttons, separate array for those buttons etc., the function's variables/names are completely different. Yet, after I compile the script in Sublime Text 3 and paste it over to Kontakt 5, I see how Kontakt changes the array inside the second set of switches' *_on ui_control_*_ while loop_!
    If I go and simply change the array name manually, it is all working again. For some reason though, the compiled version coming from Sublime isn't happy. Do you happen to have any idea why is this happening? I can provide the whole code for you to see if you prefer. It is only slightly expanded with a few more buttons and other unrelated functions.
    Thank you!
    This is what the code reads at the end of the script:
    *****************************************************
    { ALLOW TO TOGGLE BETWEEN FX SWITCHES }
    function toggle_fx_switches (switch_id)
    for $i := 0 to num_elements(%ids) -1
    if (%ids[$i] # switch_id)
    %ids[$i] -> VALUE := 0
    end if
    end for
    end function
    on ui_control($button1)
    toggle_fx_switches(%ids[0])
    end on
    on ui_control($button2)
    toggle_fx_switches(%ids[1])
    end on
    on ui_control($button3)
    toggle_fx_switches(%ids[2])
    end on
    on ui_control($button4)
    toggle_fx_switches(%ids[3])
    end on
    on ui_control($button5)
    toggle_fx_switches(%ids[4])
    end on
    on ui_control($button6)
    toggle_fx_switches(%ids[5])
    end on
    { ALLOW TO TOGGLE BETWEEN FX CATEGORIES SWITCHES }
    function toggle_fx_cat_switches (fx_cat_switch_id)
    for $i := 0 to num_elements(%fx_cat_ids) -1
    if (%fx_cat_ids[$i] # fx_cat_switch_id)
    %fx_cat_ids[$i] -> VALUE := 0
    end if
    end for
    end function
    on ui_control($fx_cat_button1)
    toggle_fx_switches(%fx_cat_ids[0])
    end on
    on ui_control($fx_cat_button2)
    toggle_fx_switches(%fx_cat_ids[1])
    end on
    on ui_control($fx_cat_button3)
    toggle_fx_switches(%fx_cat_ids[2])
    end on
    ****************************************************************
    This is what I get in Kontakt for all three additional switches:
    (Example with button number 3)
    ***************************************************************
    on ui_control($fx_cat_button3)
    $i := 0
    while ($i

    • @zaharishtonov
      @zaharishtonov 7 років тому

      I have solved the issue by combining everything in one single function. In other words I have two *for loops* for the two separate arrays, running one after another _within the same function_ although now all buttons interfere with each other (and it is understandable to be that way).
      I am following along your other tutorials too, which I've purchased from your website, and I remember you saying at some point something about there is a specific order of where functions could go. It was something like _"you can't put functions after the callbacks?!..."_ don't remember exactly, because it was going to be covered at a later lesson. So far I am only at lesson 2, so I go with more of the basics material, therefore it isn't discussed yet.
      If you do have a quick answer for this I'd love to hear it :)
      Thanks for your awesome teachings and your replies!
      Have a good one, David!

    • @Xtant-audio
      @Xtant-audio  7 років тому

      That thing with putting functions in a certain place only applied when writing raw Kontakt script it won't affect things when using Sublime Text as the compilation process puts everything where it needs to be. When you get to lesson 4 (I think) we start putting functions into a completely separate file from the rest of the program.

    • @zaharishtonov
      @zaharishtonov 7 років тому

      OK, that makes sense. In this case, I am not sure why Sublime compiles the second function in this way. I thought it was the _for loops_ , but it isn't. I tried all kinds of things, like declaring locally within the function $i for the first one and $a for the second one, and it seems to completely ignore the second function. After compiling, I copy and paste and I see no _declare $a_ plus all the other stuff happening. I am baffled on this one.

    • @Xtant-audio
      @Xtant-audio  7 років тому

      Kontakt doesn't have for loops, it's just a construct created by the extended scripting language which is then compiled to the native Kontakt while loop, it will also change variable names and do other stuff, generally you won't need to look at the compiled code except perhaps to find some tricky bugs in really big scripts. Have a look at Nils' Liberg's website to find out more about the extended scripting language which Sublime supplies

    • @zaharishtonov
      @zaharishtonov 7 років тому

      Yes, This is is why we are using Sublime in order to be able to use the extended scripting. I will take a closer look at Nils' Liberg's website later on today.
      I still can't make this second function to work though. Even if I rewrite the code with completely while loops only. It just ignores the variables and the function all together...And this is not some kind of giant script either.

  • @hechamhecham3558
    @hechamhecham3558 8 років тому

    witch programm you are use for programming