# Sustain Pedal to connect legato notes



## Mike Greene (Dec 8, 2010)

Legato between two different notes was pretty easy to program. If one key is still being held when a new key is pressed, my script simply tells Kontakt to disallow the straight group and allow the the sampled interval group. (This is sampled legato rather than scripted legato.)

But there are also times I want to use my sampled transitions for two notes on the *same* key. For example, if I'm doing "la-la-la-la-la," it's possible that in that melody that there might be two C3 notes in a row that I want _connected,_ rather than separate. (Believe me, two "la's" played separately does NOT sound the same as a connected "la-la" that I've sampled.)

But how to play them on a keyboard so that they're connected? Unlike when you play a normal legato phrase, it's impossible to play a C3 and still be holding that C3 down when playing the next C3.

So I figured I'd handle this with the sustain pedal. The problem is that the sustain pedal tells Kontakt to ignore all my note-offs, even the one's I've scripted in for my legato transitions. Yikes! Notes keep ringing after I've scripted them to stop.

So the solution I'm thinking of is that when the user presses the sustain pedal, I'll tell Kontakt to turn off that particular CC#, then script my own version of sustain that behaves the way I want it to. But I can see this getting very complicated in a hurry.

I have another option, which is to permanently assign one key (that's just out of the normal playable range) as the designated "play the same note" key. For example, if I assigned B1 as the "play that note again" key, then the user could play a C3 and before letting off the C3, play a B1. Which I would program so this would make Kontakt play two C3's in a row, connected (legato.) This would be pretty easy to script, but the problem is that it's not very intuitive for the user. (They'd have to read the manual to know that's what the B1 is for, and we all know how musicians are with reading manuals.)

So I'd like to stay with the sustain pedal method, but is there an easier way I'm not thinking of?


----------



## andreasOL (Dec 8, 2010)

Hi,

Westgate Modular Series has a mode for this which can be activated/deactivated by two key switches. When activated you play in a legato fashion the note one octave higher and a repetition of the same note sounds. Then play in a legato fashion back to the original note and the same sounds again and so on.

The script remembers which is the true note that sounds and from that point normal legato playing is possible, i.e. if you play

C3-C4-D3

you get C3, then C3 as a repetition and then legato transition to D4 as if you come from C3 itself.

- Andreas


----------



## Mike Greene (Dec 8, 2010)

That's an interesting variation. (Although I guess they came first, so it's actually mine that's the variation. :mrgreen: )

Interesting that they didn't go the sustain pedal route. I take that as a sign that it must be really complicated.


----------



## EvilDragon (Dec 8, 2010)

You do know you can completely disable Kontakt's internal sustain pedal script and do your own pedalling however you want? 

Add SET_CONDITION(NO_SYS_SCRIPT_PEDAL) at the beginning of your script.


----------



## andreasOL (Dec 8, 2010)

Sustain pedal activates a "polyphonic" mode in their legato patches. Not polyphonic legato - that was not around then  - just plain polyphonic.

So it's probably a decision how and what fits best with the rest of your patch conceptually. I don't think it's more complicated to use the sus pedal for it (Cinematic Strings and LASS do it this way).

EDIT: Yes, what Mario says is important.


----------



## Mike Greene (Dec 8, 2010)

This is very interesting stuff guys. I didn't know CS and LASS used sustain pedal, so maybe it's not so hard. I mean, let's be real, if a bozo like Andrew can script it, then so can I! :mrgreen: 

I also didn't know about the NO_SYS_SCRIPT_PEDAL thing either. I'm going to play with that a little and see what happens.

Thanks guys! 8)


----------



## Mike Greene (Dec 8, 2010)

Here's something weird - I put SET_CONDITION(NO_SYS_SCRIPT_PEDAL) into the init part of the script and it defeats the sustain pedal, as expected. Cool.

But I realized that when my legato mode is turned off, I would want the sustain pedal to work again normally, so people could sustain chords and stuff. So I wondered if I could put it into the script itself and turn it on and off. Here's sort of what I did, just to test whether I could have it outside the init:

on note
if ($EVENT_NOTE = 23)
SET_CONDITION(NO_SYS_SCRIPT_PEDAL)
end if

if ($EVENT_NOTE = 24)
RESET_CONDITION(NO_SYS_SCRIPT_PEDAL)
end if
end on

The funny thing is that this disables the sustain pedal right from the start, whether I hit key 23 or not. And hitting key 24 doesn't turn it back on. The script completely ignores the "if" stuff and apparently you can put SET_CONDITION(NO_SYS_SCRIPT_PEDAL) anywhere in the script and it will work.

RESET_CONDITION(NO_SYS_SCRIPT_PEDAL) seems to do nothing, even though the manual implies it will delete the previous disabling.

Am I sure about this? Pretty sure. I deleted the SET_CONDITION(NO_SYS_SCRIPT_PEDAL) line from my if statement and the sustain pedal again worked like a normal sustain pedal, so I know I don't have a second SET_CONDITION(NO_SYS_SCRIPT_PEDAL) hidden somewhere in the init.

Weird.


----------



## EvilDragon (Dec 8, 2010)

The manual also says:



KSP Reference Manual said:


> All commands will be interpreted before the script is running, i.e. by using USE_CODE_ the code might get stalled before it is passed to the script engine. That means, SET_CONDITION and RESET_CONDITION are actually not true commands: they cannot be utilized in if()...end if statements; also a wait() statement before those commands is useless. Each SET_CONDITION and RESET_CONDITION will be executed before something else happens. All defined symbols are passed on to following scripts, i.e. if script 3 contains conditional code, you can turn it on or off in script 1 or 2.



Which means you can't change conditions after the script has been initialized, since it's a *pre-*processor (compiler) command.

However you can code the sustain behavior back in, by ignoring note off events in release callback if CC64 is active...


----------



## Batrawi (Mar 6, 2017)

Sorry KSP Einsteins for invading your thread with my outrageous ignorance (and...6years later)
I literally don't understand a word in this thread, yet (with my excellent google search skills ) I managed to find my way in as I was trying to find a solution for how to sustain the legato notes in my string library (Spitfire Chamber Strings) which doesn't originally have this feature.

Would you please provide an easy step-by-step for how to do that?

(Remember: I know nothing about KSP language, yet, I have excellent skills to copy&paste a script if you have one prepared already for this purpose)


----------



## EvilDragon (Mar 6, 2017)

Spitfire's legato patches are locked anyways so you can't do anything about it.


----------



## tack (Mar 6, 2017)

EvilDragon said:


> Spitfire's legato patches are locked anyways so you can't do anything about it.


True they are locked, but a multiscript could handle this without too much effort. It just needs to watch CC64, and defer note-off events until after it receives the next note-on when the sustain pedal is pressed. More or less.


----------



## EvilDragon (Mar 6, 2017)

Or, in patches that contain multiple articulations (say a - Violins 1.nki), Ctrl+clicking the articulation you can set it up to activate on CC64... no outside scripts needed. However sustain pedal needs to be disabled in Insturment Options->Controllers (MIDI Controller #64 should be set to Controller only).


----------



## tack (Mar 6, 2017)

That would just latch on CC64 though. Wouldn't you still have to actually _play _with connected notes to trigger the legato transitions?


----------



## Batrawi (Mar 6, 2017)

> Or, in patches that contain multiple articulations (say a - Violins 1.nki), Ctrl+clicking the articulation you can set it up to activate on CC64


Totally forgot about that... thanks! As Tack mentioned though this may just latch on CC64... still, I remember seeing an option there for enabling/disabling Latch.. Not sure..will check and let you know


----------



## Batrawi (Mar 7, 2017)

Look what I found! a spitfire sustain pedal support script 

Not at my studio to test it but thought it might be useful to share it with you guys

Edit:Tested and working

(I think this is by Blakus? It is amazing how this guy is always on top of everything)

http://www.syntheticorchestra.com/blog/?18


----------



## EvilDragon (Mar 7, 2017)

Batrawi said:


> I think this is by Blakus?



Nope. Blakus is Blake Robinson from Australia. Spitfire's Blake Robinson is The Synthetic Orchestra, Scotland.


----------



## Batrawi (Mar 7, 2017)

EvilDragon said:


> Nope. Blakus is Blake Robinson from Australia. Spitfire's Blake Robinson is The Synthetic Orchestra, Scotland.


Really! always thought they are the same person 
Either ways, both are just inhuman


----------

