1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

Statement Select() Case and/or Case ?

Discussion in 'KONTAKT' started by rsln, Oct 29, 2020.

  1. rsln

    rsln NI Product Owner

    Messages:
    34
    Hi everybody!

    I couldnt find enywhere and in Reference Manual KRP too:

    how can i use some case(s) in select statement as OR or AND

    for example next code:

    select($EVENT_NOTE)
    case 52 or case 60 { --- this doesnt work ---}
    case 52 or 60 { --- this doesnt work too ---}

    may be anybody knows?
     
  2. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You cannot. You can only use contiguous cases, for example:

    case 2 to 4
     
  3. rsln

    rsln NI Product Owner

    Messages:
    34
    Oh.. Thank you!
    In my C/C++ more flexible capabilities ))
    and by inertia I try to find them here
     
  4. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Many, many, many C/C++ things will never apply to KSP :)
     
  5. rsln

    rsln NI Product Owner

    Messages:
    34
    can i ask you more:

    i use function so:

    function some()
    { ....some code .......}
    end function

    on note
    call some()
    end note


    it works

    but how can i use function with arguments and return some value from it
    for example:

    function some($a, $b)
    $c := $a+$b
    return $c
    end function


    if at all possible
     
  6. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    KSP doesn't have functions with arguments or returns. :) So in vanilla KSP, you would assign values to variables before a function call, then use those variables in the function, and store a return value to another value, which you read out outside of function. Yep, it's low tech style :)

    But may I direct you to using Sublime Text 3 and sublimeKSP compiler which adds a lot of syntactic sugar to KSP.

    https://github.com/nojanath/SublimeKSP/
     
  7. rsln

    rsln NI Product Owner

    Messages:
    34
    Thank you!
    Be sure to try Sublime Text!
     
  8. rsln

    rsln NI Product Owner

    Messages:
    34
    Cool!!!
    Different colors highlight the data.
    It tells me on what line an error )))) and beautifully orders the code in kontakt script window.
    Fine! :thumbsup:

    One more question ) (last today )) :

    when i use play_note(....) I hear a note sound but it is not recorded in cubase DAW.
    what can i do in order to use play_note for recording in daw?
     
  9. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Kontakt's Options->Engine->Send MIDI to outside world. Various options there. Doesn't work in some DAWs.
     
  10. rsln

    rsln NI Product Owner

    Messages:
    34
    Switch On all options
    Doesn't work in my Cubase 10.5 ;(
     
  11. soundtrax

    soundtrax NI Product Owner

    Messages:
    301
    It does work in my Cubase.
    You need to choose "Kontakt MIDI out" as MIDI in - "All MIDI Inputs" won't work (also won't work for other VSTis that generate MIDI notes or CC#)
     
  12. rsln

    rsln NI Product Owner

    Messages:
    34
    Yes!!!!!
    It works!
    Thank you very much! :) :thumbsup:
     
  13. rsln

    rsln NI Product Owner

    Messages:
    34
    I learn ksp script 2th week only.
    Please tell me what have I to press on mac keyboard to choice from the proposed sublime text?
    If i press ENTER or SPACE - proposition disappears and empty space appears
    [​IMG]
    [​IMG]
     
  14. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You press Tab.
     
  15. rsln

    rsln NI Product Owner

    Messages:
    34
    Good day!
    Thank you!
    But Tab doesn't work every time ))

    Please 3 questions:
    1. Is there a hotkey for pressing the apply button in kontakt to apply changes in script?
    2. Where to see all variables and functions related to tempo (beat, 1/2, 1/4, 1/16) ?
    2.1. - how to get current tempo
    2.2. - how to calculate, for example, 1/8 in ms, etc. ?
    3. can i transfer part of script to external file to simplify code?
     
    Last edited: Oct 30, 2020
  16. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Pressing "!" button in Kontakt's top right restarts engine and reapplies script.

    In Sublime, there's no list of variables or functions. That's in KSP reference :) There's a quick jump panel for callbacks and user functions and macros if you press Ctrl+R.

    You can definitely separate your code in multiple files then use "import" keyword to import it. See the wiki section of SublimeKSP repository for more info on syntax additions

    Regarding tempo stuff, everything is listed in KSP reference, it's a recommended read :)
     
  17. rsln

    rsln NI Product Owner

    Messages:
    34
     
  18. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
  19. rsln

    rsln NI Product Owner

    Messages:
    34
    I installed it. Thank you. But i don't understand what to do with it )
     
  20. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938