# Programming Legato in Kontakt!!



## Phillip Lober (Oct 20, 2011)

Hello all,

I'm very new to programming, and I'm sampling a guitar and I was wondering how one would program true sounding legato into a patch?

I've heard of recording legato intervals but I've never understood exactly what that meant.

What if I set it up so when I played one note, the .wav would play, and then I played a fifth higher, which would trigger the recorded interval until the second note is reached?

How do you guys do it?


Also, I was wondering how to program release triggers.
__________________


----------



## mpalenik (Oct 20, 2011)

For true sampled legato, transitions between every pair of notes are recorded. So, using your example of 5ths, you record the instrumentalist playing, let's say, a C and then a G and you cut out the part where the transition takes place and you crossfade to it between the two sustain samples of the C and G. As you can see, this takes a lot of samples.


----------



## Phillip Lober (Oct 20, 2011)

Thank you for replying!

Well, right now what I am doing is something a bit more simple: recording the RESULT of each note being played from the guitar's lowest open E string. 

Since there isn't really a prominent enough interval for this kind of transition, I've decided that each note going from the open E to any note also on that string to be a simple two part legato.

first note (if overlapping) -> legato result note. 

Where as anything not played from an open string could perhaps slide:

first note (if overlapping) -> transition -> second note.


So, is there a basic script I can find for this sort of effect? For now I just want Kontakt to have the ability to play the legato result note if overlapped, and the standard note if not.

I hope this all makes sense.


----------



## Phillip Lober (Oct 20, 2011)

Actually to quote Mike Greene: 



Mike Greene @ Mon Mar 21 said:


> Nick Batzdorf @ Mon Mar 21 said:
> 
> 
> > Mike, I don't quite follow - are you saying you just pitch shift to create the transition samples you don't actually sample?
> ...



Basically for each note going from an open string to a note on that string, I want the second method, and for sliding transitions, I want the first method.

Right now I am focusing on the second method. Is there a basic script or feature in Kontakt that can allow me to do this?


----------



## MacQ (Oct 21, 2011)

Unfortunately legato interval transitions are anything but basic, from a KSP point of view. I'm sure there are many of us who would dabble in sample development if the tools were simple.

I'd recommend hiring a KSP guy to do the grunt work for you. Sorry I can't be more helpful than that! :-(

~Stu


----------



## Mike Greene (Oct 21, 2011)

Phillip Lober @ Thu Oct 20 said:


> Is there a basic script or feature in Kontakt that can allow me to do this?


No, you'd have to write the script yourself. (Or hire it out, which is what a lot of sample developers do. No shame in that.) As Stu said, legato scripting is anything but basic, and the methodologies each person (or company) uses can vary more than you might think.

If you have a fair understanding of how computer programming and coding is done, though, then it's certainly doable. Here's what your script would need to do:

1. When a note is played, determine if this note is a "starting note" or is it a "legato note." (Basically, if a note was already being played when this new note got played, then of course it's a legato note.) Simple and obvious as this step sounds, this part of the script is surprisingly tricky. (At least it was for me.)

2. If it's a "starting note," then enable and play the "group" that contains all the starting notes.

3. If it's a "legato note," then determine the interval and based on that, enable the proper "legato note" group. ("Up a 2nd" or "up a 6th" or "down a 4th," etc.) Basic as this sounds, there is debate as to what's the best method to do this. In fact, in my Realivox script, I do this way differently than what I had a year ago.

4. Fade out the old note as you fade in the new legato note. There's debate on this step, too, since at least one major developer doesn't crossfade, and instead splices at zero crossings.

That's pretty much it. It's not necessarily complicated, but the devil is in the details, especially if you decide to have your instrument do anything besides just basic legato.


----------



## Mike Greene (Oct 21, 2011)

One other thought: for guitar, I wouldn't sample every possible interval for each note. For example, when hammering up to to an "A," I'm not so sure I'd be able to hear a difference on whether it was an E hammered up to an A, or whether it was a G hammered up to an A.

Even if I _could_ hear a difference, I don't think it would matter. If my ears are that expert, then I'd be good enough to just play a real guitar rather than use samples.


----------



## Phillip Lober (Oct 21, 2011)

Thank you for the replies, guys. I'm afraid I can't really hire anyone at the moment.

I've found that in Kontakt 4 there actually IS a feature located within the Uniso/Portamento preset that allows you to select a starting group and legato group.

After a good amount of hours, here's a test I did: http://s373185814.onlinehome.us/philliplober/Jasmine%20Demo%20Alpha.mp3 (http://s373185814.onlinehome.us/phillip ... 0Alpha.mp3)

*HERE's where things get more complicated:*

In the demo, I've used that preset to program legato going from one note to the next higher note. 

However, I don't know how to achieve legato that can change when going from one note to the next *lower* note.

And above all this, I later want to go beyond +1 intervals and perhaps program +7 and +12. It's a bunch of different things working together, and I presume it needs a damn good script. I don't have any scripting knowledge, so I'm going to have to start learning fast.


----------



## sonaht (Oct 24, 2011)

Hi Phillip,

There is a tutorial on Legato and Polyphonic legato that would get you started in here:

http://dummyworld.net/programs/

Hope this helps.

Best,
Thanos


----------



## Phillip Lober (Nov 27, 2011)

404 error. Sorry.

Okay, the legato I want is pretty much identical to the method used in the Flute Legato Patch included in the Kontakt Library:

Orchestral - Legacy VSL - Flute - Legato Instruments - Flute (legato)


My sample is a guitar so I suppose I'll find a way to create a fade out point (either in volume or velocity) when playing more than two notes.

I can't study the flute legato script at all because it's locked unfortunately, but I can see that the sustains and intervals are categorized into individual groups.


----------



## germancomponist (Nov 27, 2011)

My suggestion:

Copy/save all the adsr`s what are used in this flute patch. Load them then into your guitar instrument and load also the script what is used in the flute patch. This is the way I started my experiments with Kontakt years ago..... .


----------



## MozillaUser (Nov 28, 2011)

Hi Phillip,
I'm only trying to help you, and spare your future disapointments in the moment you become aware of the wrong decisions you took, but it'll be too late to start the whole from the scratch again.
You said you work on a guitar library. When playing guitar, the "normal" legato has two different names: hammer-on and pull-off. In both, you have to store the last note (at the time when the last note was played), and when a legato occures, you have to calculate the distance from the last note to the new (legato) note. Is the distance a negative number? the note will be a pull-off. Is the distance positive? it'a a hammer-on then.
You have to take some decisions - which unfortunately, in hammer-on case, are totally different from pull-off case. Once those decisions are implemented, and the legato note is actually played, you store again the new note in the "$last_note" variable, thus overriding the old "last" note.
A good source - which is very much worth to study - is our wise Big Bob's legato script (is it a part of his SIPS?)which is not encoded, nor encrypted, nor locked. Just to see with your very eyes those decisions I was talking about. You said you want a realistic legato? Well, the "realistic" lies in lots of lots of small details. The more you take care of those details, the more realistic your legato will sound.
Just to give you some obvious examples: 
Mike Greene said for him a hammer-on legato note will sound 100% the same no matter the distance the last note before that was. And he is right: yes, that happens for real. Well...there are still some minor differences, but you can safely neglect them.
But let's see the behaviour in the pull-off case. Does a pulled-off 6th E note sound the same when the last note was F, one half-tone higher, and when the former note was G# (one major third higher)? Obviously not  The closer the former note was, the more the pulled-off note will sound like "picked closer to the bridge (just turn your guitar upside-down, and do the pulloffs with your right hand; you cannot overlook the resemblance to the "picked-next-to-bridge" case. The further upwards on the neck the former note is, the more will it sound like a "picked-next-to-the-neck" note)
I was once in a disperate situation, where I was in impossibility to sample new notes (I didn't have the original guitar, which I used years ago, anymore) so I had to simulate those decisions in a script. You can insert a hipass filter on the "legato group", and use the "distance" information to modulate the filter cutoff: the smaller the distance was, the higher the filter cuttoff (hence, the more "castrated" your pull off will sound - thus, simulating the behaviour I was talking about). Well, for the major part of the listeners, it sounded exactly like the real thing... but not for me. The more I got aware of the differences, the crappier seemed to me. Actually, I gave up the whole, and started to sample the whole library from scratch.
This was one problem, but there are a lot more problems. What about this one? The stronger will you hammer-on a note, the higher its starting pitch will be - for obvious reasons. Please believe me, these things are hearable. You want a realistic legato? then you have to simulate that. A pitch envelope will be needed - modulated by the velocity of your hammer-on note.
What about - read this carefuly, please - the things that happen to the FORMER note BEFORE you actually play a pull-off?). No matter how carefully you play a pull-off, you'll bend up the string right before the transition happens. You want a realistic legato? You have to take care of that (once the former note was started, no pitch envelope late manipulation will work; you will have to write a change_tune loop). There is no workaround.

Fortunately, you can avoid all these problems with a single, total, move: Sample all possible transitions, in all possible velocities, and you'll live happy.
This last case (the things happening BEFORE the transition) solves the dilema "should I sample the whole transitions, and keep some sound flesh before the transition" versus "should I sample just de transition itself, and cut out everything happening before". If you want a realistic legato, you have to chose the first halve of the sentence. 
The same about the decision "should I sample short transitions, and then, once they happen, crossfade to the real long note?" or rather "should I sample the whole long note after the transition?" Obviously, because of the sound difference in the long pull-off note (which I talked about before) it's easier to take the right decision: sample the transition and keep the whole, long, note after it. Any other decisions could be valid for another type of instruments. But for guitar, you have to take these decisions if you want a realistic legato. There is no simple workaround to this.
And anyway there are lots of decisions you should take about the whole library, not only the legato-related decisions. These decisions are very time-consuming, and it's better to have them clearly in your head before you actually start sampling. Want an example? Look, one of many: the legato happens in a longer time than a regular note; from my experience, under 40 ms you don't even need to start thinking. Now: when your library is done, and you do your first programming and recording, you will find, the hard way, that all the normal notes are pretty much in time, and all your legato notes are unbearably late. That will be the moment for you, to repeatedly use the F word, and start adding an empty 40 msec zone at the start of EACH "normal note" sample file. This was just one example. I've been there. It's an ugly moment, and I see no reason I wouldn't spare you such moments.
I hope it helps.
Mozil


----------

