# Instrument Crossfade Multiscript



## Big Bob (May 19, 2015)

Hi Guys,

Here is another multiscript for your toolbox. It allows you to use any MIDI CC to crossfade any two instruments in your multirack.







The crossfade contour can be adjusted anywhere between linear and equal-power and a smoothing filter is also provided.

This script has only been tested superficially, so please let me know if you notice anything that doesn't seem to be working correctly.

Rejoice,

Bob

*EDIT: For V102 a Balance control has been added and the Smoothing filter has been enhanced.*
 
For more detail on these changes, see my latest post at 2:24PM on May 22, 2015


----------



## DynamicK (May 19, 2015)

Thanks for this...will check it out. Looks very useful


----------



## ScoringFilm (May 19, 2015)

Looks great Bob - thanks!

J


----------



## vicontrolu (May 19, 2015)

This is great! Makes me wonder if you ever did a similar multiscript to keyswitch (with stack option, if possible) Between the 64 instruments in a kontakt instance.


----------



## Big Bob (May 19, 2015)

vicontrolu @ Tue May 19 said:


> This is great! Makes me wonder if you ever did a similar multiscript to keyswitch (with stack option, if possible) Between the 64 instruments in a kontakt instance.



By keyswitch stacking I presume you mean something like using multiple momentary keyswitches at the same time (ie playing a 'chord' of keyswitches :lol: )?

I haven't done this precisely but I have done some very similar multiscripts that might easily be adapted.

I guess the idea would be to set each of your 64 instruments to a different midi channel and then have the MS route the input midi data (received on a designated channel) to each currently, keyswitch-enabled instrument?

The biggest problem with things like this is the proper handling of overlapping notes that were steered to different channels.

Why don't you describe precisely what you need functionally. Who knows, it might make an interesting 'spare time' project. 8) 

Rejoice,

Bob


----------



## tomaslobosk (May 19, 2015)

Amazing stuff as always Bob... thank you very much!


----------



## vicontrolu (May 20, 2015)

> Why don't you describe precisely what you need functionally. Who knows, it might make an interesting 'spare time' project.



Something like LASS ARC multiscript (interface is not very intuitive imo)

http://medias.audiofanzine.com/images/normal/audiobro-la-scoring-strings-2-382568.jpg


You can define sets of keyswitches, each one working on a different input MIDI channel, and these keyswitches can trigger any of the 64 instruments loaded on a VST kontakt instance OR any combination of these instruments (so you can "stack" articulations..thats what i was refering too). 


I find this particularly convenient cause you can create new articulations (a marcato by layering a legato + and staccato instrument) and still stay on the same MIDI channel.
And the fact you can adress the 64 channels in the VST instance makes it more efficient + you have the option to neatly organize your articulations in the different ports (A,B, C and D).

So i think the core is kinda made with your script: you can stack any (pair only) of the kontakt instruments by having the modwheel at 64. 
Now it would be so great if you could add different keyswictch settings for different MIDI channels


----------



## Big Bob (May 20, 2015)

It looks like I had a somewhat different idea than what you apparently are looking for.

Of course I can't tell too much about the Lass implementation by just looking at a screen shot of the panel. But, it kind of looks like they are using audio control of the instruments main volume as opposed to using midi channel steering (which is what I was thinking you were after). I presume this because the right column is labeled Slot instead of channel.

Is there some reason why audio steering is required? I do think that a full-fledged keyswitch multiscript that uses midi steering could also be quite useful and someday I may write one :lol: 

Rejoice,

Bob


----------



## vicontrolu (May 20, 2015)

I am sorry but i fail to see the difference between audio and midi steering, forgive my ignorance. 

"Slot" there means you can get audio from any of the slots on an instrument bank but, i dont use it. Honestly i am more than fine with 64 different isntruments to chose from inside a Kontakt instance.

If your crossfade multiscript uses MIDI steering..well, i guess it could work too (actually i´ll try it with something later). Only thing is in this case volume control should be done with keyswitching instead of a CC and several sets of keyswitching sets should be available.

Anyway, i know this might probably be a huge script to develop but since you could play 2 instruments from different ports simultaneously..i felt i had to try!


----------



## vicontrolu (May 20, 2015)

Allright i tried your script and works beautifully! 

I can think of a request: another control that allows the user to vary the maximum level to reach in each kontakt instrument. 
Right now the 2 extremes of the crossfade end at 0dbs but some times you´d want to compensate for some level differences so you could set it up so that instrument A max volume is 0db and instrument B max vol is 3dbs , at the other side of the crossfade. Could be a just a % ratio value knob i guess.


----------



## tomaslobosk (May 20, 2015)

vicontrolu @ 20/5/2015 said:


> Allright i tried your script and works beautifully!
> 
> I can think of a request: another control that allows the user to vary the maximum level to reach in each kontakt instrument.
> Right now the 2 extremes of the crossfade end at 0dbs but some times you´d want to compensate for some level differences so you could set it up so that instrument A max volume is 0db and instrument B max vol is 3dbs , at the other side of the crossfade. Could be a just a % ratio value knob i guess.



Excelent request, I thought exactly the same!


----------



## Big Bob (May 20, 2015)

> I can think of a request: another control that allows the user to vary the maximum level to reach in each kontakt instrument.



I guess, in addition to the Overall Volume, we could add an Overall Balance control. However, there isn't much panel real estate left and I sort of hate to increase the panel size much more.

How about if we make it so that when you hold down the Alt key (when you drag the Overall Volume slider) that it instead adjusts the Overall Balance? That will make this a dual function slider.

Rejoice,

Bob

BTW Regarding MIDI steering keyswitches, when I get a little more time I'll try to post a description of what I had in mind initially. Actually, I already described it superficially in my first response to you.


----------



## vicontrolu (May 20, 2015)

Yeah, balance! It would be a nice addition, in whatever form you decide to implement it  

I read your lines abOut the midi steering and looks really good!


----------



## Big Bob (May 20, 2015)

> Yeah, balance! It would be a nice addition, in whatever form you decide to implement it :D



How useful do you think the Overall Volume control is? I wonder if maybe I should just *replace it* with a Balance control instead of having both? 

With a similar +/-12 dB range, -12 would make instrument A 12 dB lower in volume than instrument B (-6dB for A and +6dB for B) or vice versa with +12 making inst A +6dB and inst B -6dB. Maybe we don't really need to have a separate control for volume?

If it seems important to have *both* volume and balance, the Alt key idea may not be the best way. Perhaps another button to toggle the slider from Volume to Balance would be more intuitive and friendlier?

Any additional feedback about this will be welcome.



> I read your lines abOut the midi steering and looks really good!



Well I think it might be a useful MS but there are quite a few details to be worked out. I think I will post some thoughts about this to maybe get some sort of consensus of what features might be valuable to others.

To be continued ...

Bob


----------



## vicontrolu (May 21, 2015)

The volume control is needed imo. The toggle to switch between balance/control looks like a better alternative to me.

Thanks Bob!


----------



## vicontrolu (May 22, 2015)

Hey Bob,

If i want to select an instrument i cant type "17" (frst instrument of port B). It will just allow for 16 and below. This is problematic cause then i need to to increment +1 with the little arrow and each time the selection is aimed at a given channel it modifies the volume of the instrument (according to the current value of the CC assigned to crossfade i guess) messing up the mix i might have already done inside kontakt.

Cheers


----------



## Big Bob (May 22, 2015)

Hmmm,

The Slot selection edit boxes are intended to only allow selection of multi slots that are not empty. For example if you have instruments in slots 1,2,17,34,35, and 49 and you start with the edit box at 1 and you click the up arrow, it should sequence thru the same set of slots, namely 1,2,17,34,35, and 49. If you then hit the down arrow it should step through the same sequence in reverse. However, I didn't test direct entry of values carefully so there could be a bug. 

Let me look into this a bit but could you tell me the exact conditions under which this occurs and provide a step by step to repro it?

1. Which of your 64 slots are actually occupied with instruments (or Which ones are empty if that's a shorter list)?

2. What is the current setting of the Inst A edit box when you type 17 in the Inst B edit box. What is the current setting of Inst B when you try to type in 17?

I'm getting close to posting an update. I've added a Balance slider and made some improvements in the Smoothing filter performance. But, I'll hold off on this until I look into this edit box problem.

BTW Mr/Ms vicontrolu, what is your first name?

Rejoice,

Bob

*Whoops! I missed this part of your post:*


> This is problematic cause then i need to to increment +1 with the little arrow and each time the selection is aimed at a given channel it modifies the volume of the instrument (according to the current value of the CC assigned to crossfade i guess) messing up the mix i might have already done inside kontakt.



That certainly will be a problem, perhaps I should not update inst volume when only the slot edit boxes are changed. Let me ponder that.

*However, so far I haven't been able to repro your direct entry problem* so I await you posting the details. Are you using K4 or K5?

*EDIT: I finally had a little more time to look at this and I have been able to repro your problem. But, it's a lulu :lol: There is some very weird problem with Kontakt's value edits not producing a callback when direct entries are made under certain conditions. This is probably going to take a while to zero in on exactly what the issue is and find out if there is a workaround.*

Meanwhile, regarding your problem with changing inst vol for slots you just 'pass through', I think the fix is pretty simple. I'll just not update the volume when a slot change is made. I'll defer sending new volume data until something else is moved like the CC, the Volume, Balance, or Contour.

To be continued ...

Bob


----------



## Big Bob (May 22, 2015)

OK,

Here's the story on Kontakt's value edit boxes.

Value edits, especially in K4 have a few quirks when operating in the direct value entry mode. When you double click in the value field, the current value is supposed to appear left-justified and highlighted with a gray selection field and a flashing cursor on the left. Sometimes, when you double click, the blinking cursor appears on the left but some of the old value digits may still be left to the right and usually, when this occurs, the gray selection field does not appear.

In this second case, you can enter new digits but they end up being prefixed to the old digits to the right so that when you hit enter, an illegal value is formed and the edit box merely reverts to the old value (without producing a callback). This seems to be more of a problem with K4. When using K4, you often have to double-click several times before you get the gray selection field. The problem is somewhat exacerbated by the narrow value field in V100 of the script. With the narrow field I allowed (because of using a rather long caption), the leftover old digits are often obscured off the right side of the edit box. 

So, for V102, I have narrowed the edit box caption to give more room to the value display. This way, when the double-click goes wrong, it will be more obvious because you will always be able to see that there are old digits to the right of your new entry.

So, if you want to make a reliable direct value entry, be sure (when you double click and start entering the new value) that no old digits are still present after you type the first digit. 

Hopefully, I should be posting V102 sometime later today -- 'the Good Lord willing and the Creek don't rise' :lol: 

Rejoice,

Bob


----------



## Big Bob (May 22, 2015)

OK I've posted V102 with the original post. Here are the changes:

1. A new Balance slider has been added with a +/-7.5 dB range.

2. The Smoothing filter has been enhanced for better tracking at higher lag times.

3. Changing the A/B slot assignments no longer updates the instrument volume. The new instrument volume is not sent until one of the other controls are changed. If you don't really want to change any other settings, just click (but don't drag) any of the sliders to send the initial volume control for the new slots. 

4. The slot edit box captions have been shortened a bit to make it easier to spot if K4's direct entry goes awry, see my prior post for details about this Kontakt problem. 

Rejoice,

Bob


----------



## Andreas Moisa (May 23, 2015)

Awesome! Thanks for that!


----------



## vicontrolu (May 25, 2015)

Hi Bob,

My name´s Ed 

Everything works beautifully as expected now. Cant think of anything else here regarding the xfade. Wonderful job!

Since i am using it to layer some articulation of the same instrument i´d find useful that volume on instrument A should be fixed, while the crossfade CC should only modify volume B´s (adding more or less staccato sample to the legato)..but then..well..shouldnt be called a crossfade scritpt...i guess this could be a feature for the midi steering keyswitch MS right? :D 

Truly, thanks for generosity Bob. People like you make this place rock =o


----------



## Big Bob (May 25, 2015)

Hi Ed,



> i guess this could be a feature for the midi steering keyswitch MS right?



No, the keyswitch MS I had in mind would not provide any kind of volume control for the selected instruments. Rather, it would behave like any other instrument script keyswitcher. The keyswitches would just determine which instrument(s) would respond to the input midi data.

I guess what you are describing is some kind of MS that allows you to control the Volume of a single selected instrument. That could probably be achieved someway with some small modification to the XFade MS.

Anyway, I'm glad V102 is working for you now.

Rejoice,

Bob


----------



## vicontrolu (May 25, 2015)

> The keyswitches would just determine which instrument(s) would respond to the input midi data.



Exactly. As long as its not limited to 1 single instrument --> 1 keyswitch it keeps looking very appealing..at least to me.


----------



## Big Bob (May 25, 2015)

Hi Ed,



> Exactly. As long as its not limited to 1 single instrument --> 1 keyswitch it keeps looking very appealing..at least to me.



That will depend on the types of keyswitches which are supported. Here's a short list of keyswitch types that I can envision.

1. Traditional latching keyswitches.

2. Momentary keyswitches.

3. Toggling keyswitches.

*Type 1* is usually implemented with a 'radio button' style in that when you select a new one, the prior one is cancelled. This keyswitch type can only provide a 'one-instrument at a time' function.

*Type 2* only selects the related instrument while the key is held down. When the key is released, the default instrument is activated. If both type 1 and type 2 KSs are present, the default could be defined as the currently active type 1 KS. Obviously, Type 2 allows for the possibility of activating multiple instruments.

*Type 3* selects or adds a new instrument the first time you press and release it and de-selects the instrument the 2nd time you press and release it. Type 3 can also support multiple instruments.

I'm sure that various other hybrid schemes can be concocted but they will probably be based on some combination of these 3 basic types.

It might be possible to support all 3 types with the same MS.

Maybe you should conduct a survey to determine what kind and combination of keyswitch behaviour would be the most useful?

To be continued ...

Bob


----------



## vicontrolu (May 26, 2015)

Hey Bob,

I was thinking more of type 1 only, but juts because its the one i am used to. But from time to time i use the other type of keyswitches you mention and sure, they are a nice addition.

So, talking about type 1 only, are you saying this should be impossible?

C0 - legato (ch 1)
C#0 - staccato (ch2)
D0 - legato + staccato (ch1 + ch2)

I guess in my mind the script should be able to receive midi on an incoming channel and send the data to other channel or combination of channels, simultaneously. I think thats what the LASS script does, although i am not completely sure.

I´d love to make the survey if i scratch some time but i am not really sure if many people find this useful, since its basically you and me talking here. Would be nice to have more input..


----------



## Big Bob (May 26, 2015)

Hi Ed,

Well I guess you could have a variation of type 1 where more than one channel could be assigned to a keyswitch. Nevertheless, when you press D0 it would latch and remain in effect until you pressed a different keyswitch. For example, when you pressed C0 it would cancel the D0.

Another variation that has been used a lot involves requiring more than one Keyswitch to be pressed to select an articulation. When there are a lot of articulations, it is desireable to reduce the number of KSs required to 'reach' them all. For example, if you use the octave from C0 to B0 for KSs, conventionally you can only reach 12 articulations. However, if you allow 2-key combinations you can 'reach' 78 articulations.

Actually, there is a lot to think about regarding this and I think I would like to get some input as to what might be the most generally useful and flexible without excessive frills and 'unlikely to be used' features :lol: 

Rejoice,

Bob


----------



## tomaslobosk (May 27, 2015)

Hey Bob, it's too much to ask for the source code?, It would be great to study your smoothing algorithms.  

Greetings, 
Tomás.


----------



## Big Bob (May 27, 2015)

Hi Tomás,

No problem, I'll attach the KSE Source to this post.

Rejoice,

Bob


----------

