# Velocity layer blend script



## kotori (Jun 11, 2006)

Hi everyone,
I've put together a script to do mod-wheel controlled blending between velocity layers using change_vol. Personally I need this because in VSL's Opus 1 there are only mod-wheel blend instruments for the strings and doing it manually for all other instruments and their articulations would take a lot of time (actually I was planning on taking that path until I learned that the change_vol bug had been fixed, which is why I developed that rescalings tool). Furthermore it would be really nice to be able to toggle it on and off like with the Vienna Instruments. The goal of this script is to be able to easily turn more or less any instrument into one where you can crossfade between the velocity layers.

The current version is just something that grew out of my original test script, I thought I'd post it here to get some feedback. Since it uses the change_vol function and has not yet been subject to extensive testing, please make sure that you use it under circumstances where possible sudden jumps in volume will not cause problems to ears or equipment (just as a safety precaution - I think it works fine). Eg. adding a Limiter to the output channel might be a good idea.

To use the script do this:
* Load it on an instrument
* In the Amplifier section remove any velocity modulation
* In the Amplifier section add a CC1 modulation (~40-70%) if you want higher velocity layers to sound louder.
* Specify the number of velocity layers, and the highest velocity of each one.
* Play and use you mod-wheel to blend between the layers.

You can download it http://nilsliberg.se/ksp/scripts/layer_blend.zip (here), and this is what it looks like:






Cheers,
Nils


----------



## Thonex (Jun 11, 2006)

Wow!!!

Why is it that I always say "wow" every time you post a script!!! :smile: 

THis looks very, very useful. I'm in the middle of deadlines right now... but as soon as I'm done with this movie, I'll load it up and test it out.


This could be great!!

Cheers,

T


----------



## synergy543 (Jun 11, 2006)

YOWZOLA! That looks very cool! (I must upgrade Kontakt just for this!)

I've been drawning those curves by hand and wondering if there isn't a better way.

Is there a way to nudge the curve shapes or the position of the curves?

Ideally, I thought the best way to handle such curves would be with vector-based spline curves but I'm sure that's very hard to program. However, this is a very easy way to control curve shapes in many programs I have (all graphic).


----------



## kotori (Jun 11, 2006)

Hey guys,
Thanks for the encouragement. It'll be interesting to hear what you have to say when you have tried it out.

synergy543, it's possible to dynamically change the positions of the curves by changing the four top velocities (the controls down to the right). It's also possible to switch between linear crossfading and cosine curves, and it shouldn't be to hard to add another type. Just to be clear, no editing of the tables is needed. They are just there to provide some visual feedback as you change the control points.

If you haven't seen it already you might want to take a look at my K2 Table Editor for the purpose of editing K2 rescalings. It doesn't support splines but I think it wouldn't be to hard to add something like natural splines (or one could do it in an external tool and paste the values into that program). Doing splines in KSP code is a bit complex though, albeit doable for smaller number of control points.

Nils


----------



## synergy543 (Jun 11, 2006)

kotori @ Sun Jun 11 said:


> If you haven't seen it already you might want to take a look at my K2 Table Editor for the purpose of editing K2 rescalings. It doesn't support splines but I think it wouldn't be to hard to add something like natural splines (or one could do it in an external tool and paste the values into that program). Doing splines in KSP code is a bit complex though, albeit doable for smaller number of control points.
> 
> Nils


Actually I did see your Table Editor and though while it looks very interesting, the trigonometry scares me. That's why I mentioned spline curves. I'm not a programmer (nor a mathematician) but from the "end-users perspective" I think spline curves would be easier to control and adjust for musical shaping. I know its much more complex programming but just throwing in my cheap 2 cents. :wink: 

Also, while the general shape of these curves might be very close and useful, I would think they would also need to be tweaked and adjusted to match the particular crossover of a given sound. I think the ability to tweak and adjust the curve shape in subtle ways might be musically important. (But what do I know?).
Just a thought.


----------



## Craig Sharmat (Jun 11, 2006)

This looks great, and can u use it along with Sips?

I will give it a go l8er.


----------



## kotori (Jun 11, 2006)

Craig Sharmat @ Sun Jun 11 said:


> This looks great, and can u use it along with Sips?
> 
> I will give it a go l8er.



Unfortunately it won't work together with Sips. This is because the script plays multiple instances of the same note - one for each velocity layer - and crossfades between them and this doesn't go well together with Sips being monophonic. To make crossfading work with Sips one will either have to make Sips polyphonic and controllable by other scripts (which would be quite some work if at all possible), or use my Rescalings tool to set up crossfades manually between multiple groups (but with some assistance from the tool to construct and enter the curves). This is one reason I still consider implementing the crossfades using groups instead of with this script for Opus1.


----------



## Waywyn (Jun 12, 2006)

wow, really cool.

i was going to ask the same as Craig, because having all those scripts is really cool.

even it sounds a bit mean, but what is the reason when we have all these cool scripts to make our orchestra even more alive but not have the option to use them all thogether.

i understand completely that there are technical issues and ways which are (maybe) simply not possible at all.

but how about you guys getting all together, creating a script which gives you the opportunity to use legato of sips plus this velo layer script plus the alternative tkt script.

even if you guys would charge something like 10-20 bucks for the end result, this would definitely no problem for the most here to pay that as long as it brings some sense in doing all those things.

please dont feel offended!


----------



## kotori (Jun 12, 2006)

Hi Alex,
Your request is not at all offending. In fact I would love to use these scripts together myself and until NI implements something like the articulation switching in Vienna Instruments I envision having a master script that's responsible for articulation switching and for controlling later scripts in the chain, eg. turning them on and off depending on the active articulation (eg. TKT for staccato and SIPS for sustains). It might be possible to integrate the layer blending into SIPS, but the problem is that it would make SIPS quite complex and harder to maintain which would hurt its development. A better solution might be if SIPS optionally could operate polyphonically and one could control it from earlier scripts in the script chain. Then this script could tell SIPS how to pair up notes. In addition one could employ the technique Benjamin (Dynamitec) uses in his guitar script to impose a small latency making it possible to play legato instruments polyphonically.

Nils


----------



## Rodney Glenn (Jun 12, 2006)

Excellent stuff as always Nils. Thank's (Tackar). :smile:

R


----------



## Elfen (Jun 12, 2006)

Tx Nils. Great feature.

I have test it a bit. Maybe I did something wrong here.... I have set it up as you specified. Still have a hard time searching info in the Kontakt pdf about the Midi CC amplifier modulator functions. I set the first parameter to the right of MidiCC tab to 1. 

When I play a chord it start out polyphonic from any velocity range but as soon as I move the modwheel to any extreme it come out monophonic. It seem it just selected one note from the chord at that point, the last not played. Anything monophonic is working great.
Another thing, sometimes when I move my modwheel to either 127 or 0 the volume fade out completely, happen not often. Mostly when I did just change a parameter, but it resolve quickly. 

Everything else work's great. Hope to find a solution. This script will be a great add-on.

Tx

edit: I got another problem when sometimes I lose one note of a chord. I see on the keyboard one note goes off while I'm still playing it. I only saw this done to a middle note of a 3 notes chord. Don't happen on all chords.

-Btw my test patch was Project Sam, solo session stage French Horn sustain


----------



## kotori (Jun 12, 2006)

Hi Elfen,
Yes I'm aware of that problem. I thought I'd be able to issue an update before anyone noticed but then some other things came up that I had to deal with first. I have yet to find out exactly what the problem is, or if this is a Kontakt bug. Thanks for reporting it.
Regarding the CC modulation NI's documentation is a bit lacking, but in this case I don't think the modulation is the problem.

Nils


----------



## Elfen (Jun 12, 2006)

Tx Nils for the quick response. Hopefully it will not be a head-wall-banger bug. :mrgreen:


----------



## TheoKrueger (Apr 4, 2009)

Nils, thanks a lot again!

I tried it out, works a charm.

A future compatibility with SIPS would be a great feature indeed.

Thank you.

Theo.


----------



## germancomponist (Apr 4, 2009)

Theo,

Nils posted this !Posted: Sun Jun 11, 2006 20:32!

I think this things are now includet in newer scripts?

Gunther


----------



## TheoKrueger (Apr 4, 2009)

Hmm... interesting info Gunther! 

And I thought this was brand new...

Well, better late than ever they say!

Cheers,
Theo.

Edit:



> I think this things are now includet in newer scripts?



Thanks, i'll check it out.
Theo


----------



## Mr. Anxiety (Apr 4, 2009)

Psy-Clone , Could you check to see if Nils XFade script behaves with SIPS2. I cannot get them to play nice together. After a short time, notes start to stick. I've tried reversing the order in which they appear, but it has no effect.

Theo & Everyone, I posted a few weeks ago a request for someone to try to get these (2) great scripts to work together. It would be the ultimate orchestra programming set-up for all of us composers. No one replied. I'm not a scripter, otherwise I'd do it.
Nils and Big Bob will help supply all the necessary info, that's not a problem. I just don't know anyone who would pick up the torch for us and solve the last few problems with the compatibility issue.

Thoughts?

Mr. A.


----------



## germancomponist (Apr 4, 2009)

Yes, I think it is.


----------



## LATA (Apr 4, 2009)

Hi Big Bob,

Regarding my question a few posts ago, I started looking into your wonderful SIPS library, and noticed the utility functions such as Get_db() and its friends. I thought this would be useful for calculating what I need, but didn't really understand what the parameter is for it. 

Here's the cotext: I need to find out the current played volume, given the note's velocity and the velocity->volume modulation intensity engine parameter. Somehow i need to use that EP + velocity to find out the volume in mdbs. From that point on, I can start calling change_vol based on the mod-wheel movement, much like in the velocity blend script.
Any idea on how I would do it? Will those utility functions come in handy here?

Thanks a lot!


----------



## Big Bob (Apr 4, 2009)

Hi LATA,



> I need to find out the current played volume, given the note's velocity and the velocity->volume modulation intensity engine parameter. Somehow i need to use that EP + velocity to find out the volume in mdbs.



This is a rather tall order :lol: . Perhaps you could use the relative mode (incremental change mode) of *change_vol(id,vol,1) *to avoid trying to find the starting point of the note volume in mdb.

If you really need to know what it is, you can probably work out the formula after you study my Volume Study and Report which gives the transfer functions that NI uses to control volume from velocity, engine parameters, etc. Here is the link to that study.

http://vi-control.net/forum/viewtopic.p ... trol+study

Once you have the needed formulae, you can probably use my KSP Math Library functions to implement it in your script. You can get the latest version of the Math Library here (courtesy of Thonex).

http://www.andrewkmusic.com/filearea/SIPS/Math-Library-V215.zip (http://www.andrewkmusic.com/filearea/SI ... y-V215.zip)

The download package includes a tutorial on how to use the library functions to perform equal-power crossfading two different ways. The first way uses the *change_vol() *function and the second way uses the volume control *engine parameters*.

I hope this will help you to accomplish your objective.

God Bless,

Bob


----------



## Pzy-Clone (Apr 4, 2009)

Mr. Anxiety @ Sat Apr 04 said:


> Psy-Clone , Could you check to see if Nils XFade script behaves with SIPS2. I cannot get them to play nice together. After a short time, notes start to stick. I've tried reversing the order in which they appear, but it has no effect.
> 
> Mr. A.



You mean this new script, or the "old" xfade script?
I only know you can have "manual" xfades and release triggers with Sips2 , becouse i made a bunch of them for the EWQL instruments. 
I didnt try this one ill see what happens later tonite, but im sure if its not working for you guys, theres no reason it will for me.


----------



## Mr. Anxiety (Apr 4, 2009)

Pzy-Clone,

I was referring to the current, or new script.

But, are you using a XFade script that does work with SIPS or SIPS2?

If so, that would be helpful for me until someone sorts out the current compatibility issue.

Maybe you could link us to it.

Thanks,

Mr. A.


----------



## Big Bob (Apr 4, 2009)

Hey Mr A,

I think what pzy is refering to is that you can setup the *SIPS 2 *articulation control script, the *SAS*, to trigger any number of groups per articulation. So, if you have an articulation with 4 velocity layers, you can put each velocity layer in its own group and then manually assign the modwheel to morph between the layers when that articulation is selected. 

AFAIK no version of the *VXF* was ever able to run with any version of *SIPS* because in general, the two scripts fight each other in various ways. I have stated this many times before. At one time Nils and I were going to make the necessary mods to allow these two scripts to work cooperatively. I got as far as making the mods to *SIPS V151 *but Nils never found the time to make the needed mods to the *VXF*. Since then *SIPS* has moved on to *V2* and the custom mods for interfacing with the *VXF* have been removed to make room for other things.

I've also mentioned several times before that it would not be overly difficult to write a new version of the *VXF* which could follow the *SIPS 2* scripts and use the new *Math Library Functions *for ep control of volume to effect the EPXF at the group level instead of the note level as we were trying to do before. However, I believe that so far no one has been willing to tackle this job. :roll:

Sorry,

Bob


----------



## Mr. Anxiety (Apr 4, 2009)

Yes Bob, You're absolutely correct in the fact that you've mentioned many times how these 2 scripts cannot work together. You have also mentioned how potentially successful one might be in getting these 2 scripts to behave together.

I don't you to feel like I'm ignoring you about these facts. 

I just didn't know how PzyClone might be achieving the results he had happening, so I wanted to get more info from him.

Once again, thanks for all your hard work, and thanks for contributing to this thread.

Mr. A.


----------



## Pzy-Clone (Apr 4, 2009)

there you go.
I never tried to use any scripts for xfading, becouse its not realy that much work to set up a xfade in kontakt anyway, and like the man above me here said..u can use SIPS2 and SAS in combination with a uhm..., "traditional" CC1 xfade, and he should know better than anyone else.

While you`re there mister Big Bob, is there a way to bypass the bank and articulation KS functions in Sips2?

As wonderfull as it is, often i want to just take a pre-exisiting xfade instrument in a larger multi setup and use Sips, without putting all the other articulations in the same instrument, not to mention rearranging and copying groups etc.

Anyway Mr. Anxiety, i have no link to post, sorry, just do it the old fashioned way.


----------



## Mr. Anxiety (Apr 4, 2009)

Oh, BTW, having these two scripts working together basically solves my quest for the perfect set of scripts to allow me the most flexibility in using Kontakt to compose my orchestral music. Since this is my full time job, it's rather important and I get excited with the prospect of having this set of tools working together. I would also assume that I'm not alone in this.

I bet Andrew is going to have a set of scripts that do this in his new library. Just a hunch!

Mr. A.


----------



## Pzy-Clone (Apr 4, 2009)

Mr. Anxiety @ Sun Apr 05 said:


> I just didn't know how PzyClone might be achieving the results he had happening, so I wanted to get more info from him.
> 
> 
> Mr. A.


LOL theres not much happening here i can assure you... >8o 

But you can still (and this is not what this post is about anyway , i know) do xfades without a script, the way Big Bob described.
So theres no reason you cant have a xfaded instrument with sips2. 
You just cant use any of the current scripts for xfading.


----------



## Mr. Anxiety (Apr 5, 2009)

Thanks PzyClone,

You can't blame me for trying. My set-up is massive, across 4 PCs,so that's a lot of programming those velocity curves, if you know what I mean. The script is way cleaner and easier.

Mr. A.


----------



## Pzy-Clone (Apr 5, 2009)

oh, well what i mean is ...i want to use SAS ans SIPS2 for only one articulation in one instrument,( wich already uses a script for keyswitching) in a large multi setup.
So that the articulation is always active, and doesnt have to be selected with keyswitches in SAS. 
Becouse if you only have 1 articulation with SIPS2\SAS, you dont realy need a keyswitch for it.? 
I dont want to move all the other arts into the same instrument, becouse the other articulations\instruments uses different scripts as well, that cannot be used in the same instrument as the one with SAS \ SIPS2.

I know Sips 1.5 works like that for only one single articulation (no KS at all), but then you dont get release triggers and round robin.

Mr: Anxiety:
yeah i know, but if you save the curves as presets in kontakt, it only takes like a few mouse clicks to make a new xfade instrument, but offcourse a script would be faster indeed. Not to mention the option off turning it off\on , like kotori says in the post here.
But as far as i can tell, this latest blending script does exactly the same as creating custom xfades inside kontakt for each group, only much faster :D


----------



## Big Bob (Apr 5, 2009)

If you only want to get rid of the keyswitches themselves, see the 2nd paragraph on page 36 (in section 3.23) of the SIPS 2 User's Guide. Specifically, read the last two sentences of the paragraph for the technique you can use to 'de-allocate' all keyswitches. Keep in mind however, that the SAS still requires exclusive use of the Group-Start parameters.

God Bless,

Bob


----------



## Pzy-Clone (Apr 5, 2009)

yes, , thats just what i need. =o 
I did read the manual a few times, but i must have missed that part. 
As usual lol.
Thanx.


----------



## LATA (Apr 6, 2009)

Big Bob @ Sat Apr 04 said:


> I hope this will help you to accomplish your objective.



Thanks so much Bob! This is some really helpful stuff. You really did a lot of work and spent the time documenting it. i'll need to spend some more time on it soon, but i think it'll be very useful. I really appreciate your willingness to help


----------

