• Register
  • Help
Page 1 of 4 1234 LastLast
Results 1 to 10 of 38

Topic: VSL legato script for Kontakt 2

Share/Bookmark
  1. #1

    VSL legato script for Kontakt 2

    This is the script for legato in Kontakt 2. It is still in development, but works very well to me.

    1 - Start Kontakt 2
    2 - Import any legato instrument by using the import button
    3 - Open up the script editor in Kontakt 2 after loading the converted .nki file
    4 - Click on "Edit" and paste the script into the editor
    5 - Click apply
    6 - Play the instrument to see it working
    7 - Save the program with script and save the script as template for other legato instruments.

    here is the code to be copied in the script window:


    on init

    { Used variables }

    declare $time
    declare $last_note
    declare $interval
    declare $leg_interval
    declare $active_id
    declare $note_count
    declare $enable_legato
    declare $ghost
    declare $repetition

    { User Interface }

    declare ui_button $VSL_GroupKeys
    declare ui_value_edit $FirstLeg (0,127,1) { First Legato Keyswitch (1 semitone) }
    declare ui_value_edit $NoLegKey (0,127,1) { Keyswitch for starting note }
    declare ui_value_edit $RlsKey (0,127,1) { Keyswitch for released note }
    declare ui_value_edit $RepKey (0,127,1) { Keyswtich for repeated/legato note }
    declare ui_value_edit $RepThrs (0,5000,1) { Threshold (ms) for repeated note }
    declare ui_value_edit $GhostKey (0,127,1) { Ghostkey - any key not in the playzone for
    triggering a ghost note for legato }
    declare ui_button $PlayZone
    declare ui_value_edit $From (0,127,1) { First note of the lower octave playzone }
    declare ui_value_edit $To (0,127,1) { Last note of the lower octave playzone }
    declare ui_button $LegatoParam
    declare ui_value_edit $Threshld (0,1000,1) { Threshold (ms) for unconnected legato }
    declare ui_value_edit $Release (0,1000,1) { Release time (ms) }

    move_control ($GhostKey,2,2)
    move_control ($PlayZone,1,3)
    move_control ($From,2,3)
    move_control ($To,3,3)
    move_control ($LegatoParam,4,3)
    move_control ($Threshld,5,3)
    move_control ($Release,6,3)

    { Fill UI with default values }

    $From := 31 { G1 }
    $To := 74 { D5 }
    $GhostKey := 24 { C1 }
    $RlsKey := 14 { D0 }
    $RepKey := 13 { C#0 }
    $RepThrs := 500
    $NoLegKey := 15 { D#0 }
    $FirstLeg := 1 { C#-1 }

    { Save UI values with patch }

    make_persistent ($Threshld)
    make_persistent ($Release)
    make_persistent ($From)
    make_persistent ($To)
    make_persistent ($GhostKey)
    make_persistent ($RlsKey)
    make_persistent ($RepKey)
    make_persistent ($RepThrs)
    make_persistent ($NoLegKey)
    make_persistent ($FirstLeg)

    { initialize variables }

    $interval := 0
    $time := 0
    $note_count := 0
    $ghost := 0
    $repetition := 0

    message(" ")
    end on

    on note
    if ($EVENT_NOTE = $RlsKey)
    exit
    end if

    ignore_event($EVENT_ID)

    if ($EVENT_NOTE = $GhostKey)
    $ghost := 1
    exit
    end if

    if (not in_range($EVENT_NOTE,$From,$To))
    exit
    end if

    $enable_legato := 1
    if (($note_count = 0) and ($ghost = 0))
    if ($time # 0)
    if ($ENGINE_UPTIME - $time > $Threshld)
    $enable_legato := 0
    end if
    else
    $enable_legato := 0
    end if
    end if

    if ($enable_legato = 1)
    if ($last_note # 0)
    $interval := $EVENT_NOTE - $last_note
    end if
    else
    $interval := 0
    end if

    $leg_interval := abs($interval)
    if ($leg_interval > 12)
    $leg_interval := 12
    end if

    if ($leg_interval # 0)
    play_note($leg_interval+$FirstLeg-1,100,0,1)
    $note_count := $note_count + 1
    else
    if (($last_note = $EVENT_NOTE) and ($repetition = 0) and ($ENGINE_UPTIME - $time <= $RepThrs))
    play_note($RepKey,100,0,1)
    $repetition := 1
    else
    play_note($NoLegKey,100,0,1)
    $repetition := 0
    end if
    $note_count := $note_count + 1
    end if

    if ($ghost # 1)
    note_off ($active_id)
    if ($interval >= 0)
    $active_id := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
    $note_count := $note_count + 1
    else
    $active_id := play_note($EVENT_NOTE+48,$EVENT_VELOCITY,0,-1)
    $note_count := $note_count + 1
    end if
    $ghost := 0
    else
    $ghost := 2
    end if

    $last_note := $EVENT_NOTE
    $note_count := $note_count + 1
    end on

    on release
    if ($Release # 0)
    ignore_event ($EVENT_ID)
    wait ($Release*500)
    note_off ($EVENT_ID)
    end if
    dec($note_count)
    if ($note_count < 0)
    $note_count := 0
    end if
    $time := $ENGINE_UPTIME
    end on

    on ui_control ($PlayZone)
    $PlayZone := 0
    end on
    on ui_control ($VSL_GroupKeys)
    $VSL_GroupKeys := 0
    end on
    on ui_control ($LegatoParam)
    $LegatoParam := 0
    end on



    Enjoy

  2. #2

    Re: VSL legato script for Kontakt 2

    OMG-- Is that where we're heading these days?

    Ay dios mios!!!!

    Jose

  3. #3

    Re: VSL legato script for Kontakt 2

    ahhahahhaah

    If that works, then you, Guga Bernardo, are a gent of the highest order.

    But I swear this is the funniest thread I've seen here yet.

  4. #4

    Re: VSL legato script for Kontakt 2

    Thanks for sharing , I`ll have to try that when K2 comes in.. Rich
    maybe try posting in the Kontakt Forum (here and at NI )as well would be appreciated..

  5. #5

    Re: VSL legato script for Kontakt 2

    This is great and has happened sooner than I expected.

    I find it hard (also great?) to believe that the one script would work for all the VSL legatos though, given that in the perf tool you have to load a different tools file for each legato patch. Can it be so easy?

    More power to you, and keep up the fine work. All Kontakt VSL (for me Opus 1) users are looking forward to performance-tool-free days to come.

    Thanks,
    fizbin

  6. #6

    Re: VSL legato script for Kontakt 2

    wow! thanks Guga. I can't wait to try this and I sure am glad I wasn't the one to write it. I was hoping to play and write a little bit more and program a little bit less. Am I being naive?
    Michael Telle
    Vagabond
    Bay Area

  7. #7

    Re: VSL legato script for Kontakt 2

    Hey, let me clear up something important. I have no clue of the meaning of that code! A german guy posted this in a forum and I just made it available here.
    I hope one day I can build my own scripts...

    Wich proves that using scripts is not for programmers only!

  8. #8

    Re: VSL legato script for Kontakt 2

    Guga,

    If you don't mind me asking, what forum did you find this on?
    I've tried it and it's great! You have to tweak a bit to get ranges and octave offsets right, obviously, but it works perfectly as far as I can tell. I've only tried it on the flute and clarinet so far.

    I'd love to know where you found it, though.

    Thanks!


    -andreas-

  9. #9

    Re: VSL legato script for Kontakt 2

    OMG.

    K2 wasnt an option before I found out you have to know degree level programming!

  10. #10

    Re: VSL legato script for Kontakt 2

    I think this is looking great! You can't tell a computer to switch samples when two notes are played closely together. It doesn't understand the concept of switching, the concept of samples, the concept of notes or the concept of together. So what if it seems cryptic as long as it helps us make music instead of tweaking MIDI tracks. The developer pays for the monkey that farts hexadecimals and we pay the developer some extra for making our lives easier. You didn't think that the Performance Tool was made out of cute drawings of flowers and furry animals, did you?

Go Back to forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •