PDA

View Full Version : VSL legato script for Kontakt 2



Guga Bernardo
04-07-2005, 12:17 PM
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

josejherring
04-07-2005, 12:38 PM
OMG-- Is that where we're heading these days?

Ay dios mios!!!!

Jose

dezai
04-07-2005, 12:49 PM
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.

Rich Pell
04-07-2005, 12:58 PM
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..

fizbin
04-07-2005, 02:49 PM
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

esteso
04-07-2005, 05:14 PM
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?

Guga Bernardo
04-07-2005, 05:21 PM
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! :)

andreas
04-07-2005, 05:32 PM
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-

-Ed
04-07-2005, 05:39 PM
OMG.

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

janila
04-07-2005, 06:21 PM
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? :p

Andrew Aversa
04-07-2005, 07:01 PM
OMG.

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

Of course you don't need to know programming. Scripts are loaded with a point and click from a menu. Legato operates by simply playing keys on the keyboard. What's the big deal?

FireGS
04-07-2005, 07:12 PM
Zircon, please dont pull your macho stuff here. May be fine for OCR and VGM, but please, be nice. :)

-Ed
04-07-2005, 07:17 PM
Of course you don't need to know programming. Scripts are loaded with a point and click from a menu. Legato operates by simply playing keys on the keyboard. What's the big deal?

Well no one explained that to me
:rolleyes:

But its still doesnt sound very unprogrammer friendly. Giga Midi rules isnt either.

Andrew Aversa
04-07-2005, 07:23 PM
Zircon, please dont pull your macho stuff here. May be fine for OCR and VGM, but please, be nice. :)

Macho stuff @ OCR? VGM? Huh? :confused:

I'm just making sure people don't the wrong information about K2, since it's a wonderful tool. I'm sorry if I appeared to be rude, I certainly did not intend to be.

allend2010
04-07-2005, 09:58 PM
Just when I though I'd never see Pascal again :)

Scott Cairns
04-07-2005, 10:13 PM
Just when I though I'd never see Pascal again :)

Haha. yeah. A friend of mine still programs in it for fun. :rolleyes:

josejherring
04-07-2005, 10:41 PM
Just when I though I'd never see Pascal again :)

I knew it had to be one of those forgotten languages. I wasn't sure if it was Fortran or Pascal. Pascal is it?

Jose

Brian2112
04-07-2005, 10:43 PM
Of course we will have the practical joke scripts…

(Here are some I thought up already)

1) Midi Hang - Filter out note offs

2) WTF Warped Record – Random pitchbends during play

3) 88 card shuffle – play one key, sound 88 notes at once

4) Unlimited Polyphony Test – combination of 1 and 3 (also known as the Streaming Hard Disk Burner)

5) Perfect Pitch Tuner (Transpose all input up a minor 2nd and see if anyone notices before it’s too late)
:p
…2112:D

StrangeCat
04-08-2005, 02:14 AM
damn I really am going to just leach scripts I'll be damned if I sit down and try and create my own, 'er will I? Kontakt 2 shipping any day now :D

Martin Jann
04-11-2005, 07:01 AM
Of course we will have the practical joke scripts…

(Here are some I thought up already)

1) Midi Hang - Filter out note offs

2) WTF Warped Record – Random pitchbends during play

3) 88 card shuffle – play one key, sound 88 notes at once

4) Unlimited Polyphony Test – combination of 1 and 3 (also known as the Streaming Hard Disk Burner)

5) Perfect Pitch Tuner (Transpose all input up a minor 2nd and see if anyone notices before it’s too late)
:p
…2112:D

I think that almost all of these scripts are already in the K2 script library (with different names though). Best,Martin

Chris Hein
04-11-2005, 08:52 AM
As far as I know, the only thing the legato script does is:
As long as you hold one not and play another, this second note comes from a different patch.

This way its quite easy to create your own legato patches out of any patch:
Just make a copy of the patch, rename and save it.
In the loopeditor cut off the attack of each sample.
Put the legato script on the patch (I think its included in K2 as a template) Thats it.

To make it more flexibel you can set any midicontroller to the attackpoint
and use this to get variations of the legatosample starting point.

There is nothing special about the VSL Legato. I think, its not a real legato sample.
They just cutted the beginning of the sound.

Chris Hein

werter66
04-11-2005, 10:49 AM
wow it works really fine!!

A tip for everybody who does not know much about the structure of the legato patches: load a patch, connect the performance tool, open the group editor and look what the performance tool makes when you play, then bypass the performance tool, load the script and play with the values until it does the same...

Do you think it will be possible to do such a script allso for the repetitions?

thanks again!!!!!!!

This will change my live (;

werter66
04-11-2005, 10:56 AM
As far as I know, the only thing the legato script does is:
As long as you hold one not and play another, this second note comes from a different patch.

This way its quite easy to create your own legato patches out of any patch:
Just make a copy of the patch, rename and save it.
In the loopeditor cut off the attack of each sample.
Put the legato script on the patch (I think its included in K2 as a template) Thats it.

To make it more flexibel you can set any midicontroller to the attackpoint
and use this to get variations of the legatosample starting point.

There is nothing special about the VSL Legato. I think, its not a real legato sample.
They just cutted the beginning of the sound.

Chris Hein


This is not true, they sampeld every note 24 times allways with the the special legato sound at the beginning wich happens when you play legato from c to a or from g to a...
It depends from wich note you come to for example "a" wich legato sound sounds at the beginnig of a....

huh ist difficult for me to explain my english is not good enought

fizbin
04-11-2005, 11:49 AM
Yeah - in short, the VSL legato samples are just that - samples of someone actually playing the interval. The first note you play is a regular sus note, but if you play a note close to that then it cuts to the sample of the exact interval you just played. That's why those patches are so damned big (sus samples + down intervals to an octave for every note + up intervals to an octave for every note). Correct me if I'm wrong but the perf-legato_p-f patches are usually bigger than the combi-all patches.

Chris Hein
04-11-2005, 01:14 PM
OK, I better shut up until I get my K2.
I just testet it a little bit during the betatesing period.

Chris Hein

Guga Bernardo
04-11-2005, 05:42 PM
Do you think it will be possible to do such a script allso for the repetitions?

thanks again!!!!!!!

This will change my live (;

Definitelly yes, here is the solution for SAM Horns:

http://www.northernsounds.com/forum/showthread.php?t=33443

I hope I can figure out VSL soon! :D

FireGS
04-11-2005, 09:41 PM
Aparently, im just stupid... Im trying to use this with the VSL Solo violin..and its just...not working... could someone do like an in-depth guide to this? I got the SAM horns script working.. not this one tho... help?

~Fire

handz
04-17-2005, 09:55 AM
Hey! It works great! I imported all of my OPUS1 Perf leg patches from giga to kontakt2 and added script and it is working! Only problem is the transposuition - instruments starting on wrong octave...

Up Late
04-17-2005, 03:06 PM
Hey! It works great! I imported all of my OPUS1 Perf leg patches from giga to kontakt2 and added script and it is working! Only problem is the transposition - instruments starting on wrong octave...

Right -- and if you try to use Kontakt's MIDI Transpose, it slightly screws up the Legato Tool's performance. You can hear slight double glisses up on each note, for example, if you have the MIDI Transpose set to -12 to get the patch to play in the correct range on the keyboard.

Does anyone know of another way to correct the transposition?

handz
04-17-2005, 05:18 PM
Up Late- but transpose in Cubase works flawlessly!
But Im too lazy to do it for ieach instrument:)

gugliel
05-06-2005, 12:24 PM
Just found this, and it looks correct for the vsl solo strings, anyway. Seems to me it could be converted into a CAL script for cakewalk Sonar, and with that to drive the gigastudio version of the vsl legato (and spiccato, and portamento). Good work!!

Sovereign
05-06-2005, 05:42 PM
Just wish Kontakt 2's GS3 import functioned a bit better, it doesn't do well with xfades and with other complex patches. :(

Rich Pell
05-06-2005, 07:09 PM
Just wish Kontakt 2's GS3 import functioned a bit better, it doesn't do well with xfades and with other complex patches. :(
i know, :( I was hoping they`d get that together too! I while back made a list for them of all giga "dimentions' that werent working with in K1.53. Looks like nothing much has changed. Alot of GS release triggered patchs dont convert properly as well..

Bruce A. Richardson
05-06-2005, 09:07 PM
You could always go for the real thing...

bluedog
05-07-2005, 02:28 AM
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-

Huh, tweak? mmh..if you think that sharing tweaks info would benefit some who are perhaps not quite able to figure these out..feel free!

;-B

Rich Pell
05-07-2005, 07:57 AM
You could always go for the real thing...
Yea.. you mean, not use samples at all and go for the real thing ? ;) I actually have GS3 and 2.5. I just dont like having to use it along side all my other stuff... i was hoping a better GS import into K2 would solve that... :( Guess I`ll hang on to my GS licence for now..Rich

andreas
05-07-2005, 03:10 PM
Huh, tweak? mmh..if you think that sharing tweaks info would benefit some who are perhaps not quite able to figure these out..feel free!

;-B

The "tweaks" I was talking about were actually not to the script itself. It was more about moving the samples around, to get the octave offset right.

There is no octave offset in the script, like there is in the VSL Performance Tool, so I tried first to insert the MIDI Transpose script before the Legato script. That sort of worked, but if I did more than one or two octaves transposition it screwed up the instrument. The wrong samples would play, and I'd lose descending intervals, stuff like that.

So, what I did instead was to move the actual samples an octave up or down in the mapping editor (provided there is enough empty space between zones with actual samples and the keyswitches). Then do the the remaining one or two octaves with the transpose script. You'll also have to adjust the instrument range in the script if you do this.

With this method, I sort of got it working for some instruments, such as the flute, clarinet and oboe. I had less luck with strings and horns. I don't know why it would make a difference, but it does. At least in my case.

I started to actually modfiy the script itself, but I got real busy and I've had to put it aside for a while. If/when I get around to it again, I'll post my findings here.

In the mean time, maybe someone else has had a chance to experiment more with it? Or has a solution that will make it work more smoothly that they would like to share?

I also tried to ask the original poster where he found the script, so I could ask the author of the script some questions, but I never got a reply. I assumed it came from NI's forum, but I couldn't find it. If someone knows where this was originally posted, I would love to know.

Thanks

-andreas-

Rich Pell
05-07-2005, 07:30 PM
This won`t solve all the octave offset problems at all on a "universal script" level but what i tried helps you play the the inst. in the right Keyboard position.
After you load your VSL inst. in...hit the wrench, go to Inst. Options >Instrument and lower with "midi trans.' an octave or 2 depending.
Then close up and add the legato script. You have to do this before you add the script or it will be messed up.. :D Rich

saxmand
07-23-2010, 07:52 PM
I know it's an old thread, but as information for those hue never figured it out, you have to set the non legato patch as 13, the release note as 14, and sometimes you'll have to expand the play zones... then the script will work properly! took me a some time to figure out and, so would save other the time.

saxmand
07-23-2010, 07:57 PM
I know it's an old thread, but as information for those hue never figured it out, you have to set the non legato patch as 13, the release note as 14, and sometimes you'll have to expand the play zones... then the script will work properly! took me a some time to figure out and, so would save other the time.

I ment the legato key to 14....

saxmand
07-23-2010, 08:05 PM
I ment the legato key to 14....

Not 14, but 13.

And if you transpose the instrument 1 octave down (if it's an trumpet ect.) you have to plus 12 to different vsl group keys, so the values would be: firstleg: 13, nolegkey: 25, Rlskey: 26!! (and for 2 oktaves you'll have to plus with 24).

so you can't transpose an instrument down, cause the values do go down under 0...

see ya!%-

leelika08
08-07-2011, 09:45 PM
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?
et 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.