# Chord splitter



## Big Bob (Oct 19, 2007)

I think that would have to be implemented as a MultiScript because ordinary scripts can't generate notes for any MIDI channel other than the one their instrument is set to. Although, I suppose you could create one instrument and script for each MIDI channel you wanted and then have each one receive all the notes but only act on their designated channel.

If you really want some one else to write such a script you would need to provide a lot more info such as how you want to determine which notes of a given chord would go to which channel? Would something simple like lowest note goes to lowest channel, next highest note goes to next highest channel, etc. Or, are you thinking of something like intelligent chord note distribution to 6 guitar-string channels, or what?

Rejoice,

Bob


----------



## tarzana (Oct 19, 2007)

Hi Big Bob,

First i would like to thank you for taking 
the time to reply...

Now , what i have in mind is to basically play a
voicing (chord) in realtime that would be distributed
among the individual midi channels..

ie:4 part chorale played in realtime with 
soprano to violin 1 - midi channel 1
alto to violin 2 - midi channel 2
tenor to viola - midi channel 3
bass to cello - midi channel 4 

regards,
tarzana


----------



## Big Bob (Oct 19, 2007)

How will the script know when the Soprano and Alto crossover? Ditto the tenor and bass? Or, can one simplistically assume that never happens?

To clarify, I assume you just want to play 4-note chords and have the script MIDI channel tag the four notes with the desired channel for each voice. Now, the script receives 4 notes (actually sequentially but very closely spaced). What determines which note in the chord is the channel 1 soprano note? For example, is it always the highest note in the chord? How does the script know when Violin2 plays a note higher than Violin !? etc, etc, etc. ....????

Rejoice,

Bob


----------



## Dynamitec (Oct 19, 2007)

Hi tarzana!

Unfortunately i don't have much time at moment so i didn't looked into the multi script thing right now :roll: 

But i can tell you how to detect a chord and how to split it if you need help with this.
How much do you know about KSP?

Cheers,
Benjamin


----------



## tarzana (Oct 19, 2007)

Hi Gentlemen,

thank you kindly for considering the challenges
such a script would pose...

unfortunately i am a keyboard player with
zero knowledge in programming..

for now if you guys can and would 
be willing to create a script that 
would assign top note to channel 1
2nd note from top to channel to
3rd note from top to channel 3... etc..
that would be nice... 

or possibly have the timing of the notes determine
the order and distribution of the notes 

i understand Big Bob's point of crossing 
parts not being understood by a computer..

i will pray that GOD give wisdom and 
guidance on how such a script can be 
created... granted you gentlemen actually 
take it upon yourselves to put your energy
into such a script..

regards,
tarzana


----------



## Big Bob (Oct 19, 2007)

Hi Tarzana,



> for now if you guys can and would
> be willing to create a script that
> would assign top note to channel 1
> 2nd note from top to channel to
> ...



This of course would be about the easiest to do and it might serve you as a good starting point. Then maybe you might want to learn something about scripting so you can 'tinker' with it :wink: . 



> or possibly have the timing of the notes determine
> the order and distribution of the notes



Not too difficult for the script to do but it might be a royal pain for the keyboardist :x 
You would have to play some fairly fast arpeggios so the 'holding' or collection time of the script could be made very short (or else put up with a big latency or delay).



> i understand Big Bob's point of crossing
> parts not being understood by a computer..



It's not that it can't be 'undersood' by a computer it's just that first a musician (you in this case) has to precisely specify what rules of voicing are going to be followed so that an algorithm can be designed. I was just trying to mention a few of the things that you will have to come to grips with before your 'chord splitter' can become a musically useful script.

Like Benjamin, right now I'm pretty much in an overload mode so I don't know when I would be able to spend some time on this. But, let me mention a few more things for you to ponder. Since you have 4 specific instruments in mind, maybe instead of a multiscript, MS, you might want to consider 4 instrument scripts that are all the same except for one 4-position panel knob. Each script would then 'decode' the 4-note chord the same way but for the last step would 'throw-away' all but the voice assigned by the panel knob. Your keyboard could then send the chords to all four instrument scripts. Of course this doesn't end up producing 4 MIDI channels, but it would play the 4 instruments independently (assuming it is Kontakt instruments you wanted to drive).

If you actually need to generate a MIDI output with each voice assigned to its own MIDI channel, then a MS would probably be the easiest way to do it. The only problem is that the current Kontakt implementation of MSs is such that the MS control panel is not visible during usage. In order to get at it you have to change a registry bit and re-launch Kontakt. Therefore, if we write a MS, there would be no control panel available when you are using the script (with which you could tweak any settings). If you need tweakable parameters, you would then need to write another script to allow you to alter the multiscript via MIDI messages. This would be similar to the technique I used for the KSP+ Multiscript.

If I get some time soon and no one else has whipped anything up by then, I may be able to cobble something together for you. So, why don't you comment on the above so that I know which general idea you would prefer, ie 4 instrument scripts or one MS.

Rejoice,

Bob


----------



## tarzana (Oct 20, 2007)

Hi Big Bob,

Sorry for the late response to my own request :oops: 

my mother just arrived in town and so i spend all day
with her ... right now she is with my mother in law and
i had some time to try to understand these approaches 
for the script ...ms verse 4 scripts...

i imagine if one could drop this script in on different instruments
within kontakt to for example try out different orchestral colors
and possibly take the closed voicing and through octave displacement
of certain instruments have the voicing converted to open that would 
be fun to say the least

i must apologize in advance for my ignorance in the challenges
that such a script might present ...

as far as algorithms that might handle crossing of parts or possibly 
certain voices moving while others are held ie: soprano , alto, tenor,
playing quater notes with the bass handling eight notes ... again 
i wish i could offer some insight :-(

Big Bob thank you and Benjamin & all others at this lovely forum....

musicians empowering musicians through the gifts they have 

Regards, 
Tarzana


----------



## polypx (Oct 21, 2007)

I think it would be simplest if you made a script that allowed an instrument to respond in a special way, and simply put it on all four instruments, assigning them all the same MIDI channel, but setting the script to be in soprano, alto, tenor, or bass mode.

The script would do this:

If there is one note playing, do I play ? yes/no
If there are two notes playing do I play ? yes/no, and which one?
If there are three notes playing do I play ? yes/no, and which one?
If there are four notes playing do I play ? yes/no, and which one?
If there are more than four notes playing, what do I do?

exit


----------



## Big Bob (Oct 21, 2007)

polypx @ Sun Oct 21 said:


> I think it would be simplest if you made a script that allowed an instrument to respond in a special way, and simply put it on all four instruments, assigning them all the same MIDI channel, but setting the script to be in soprano, alto, tenor, or bass mode.
> 
> The script would do this:
> 
> ...



You have just described, in essence, what I referred to as the 4-instrument approach. I would only add that each associated script, while identical, would have one or more user settings on their control panels that would 'help' the scripts to determine which voice it would represent. In its simplest form, this might consist of a single knob with 4 positions. For Script/Instrument #1, you would set this knob to 1. For Script/Instrument #2, you would set the knob to 2, etc. For the first go around, a knob setting of 1 could mean play the lowest note, knob setting 2 could mean play the 2nd lowest note, etc.

I think this 4-instrument/script approach would be better because it will provide access to the control panel (which would not be so for the MS approach). I'm sure you will eventually want to have all kinds of 'tweakable' parameters available and the MS approach just doesn't lend itself to that very well.

However, the reason I posed the question about which approach would be better, is that the original request was to have the script tag each note of the chord with a different MIDI channel. If that is a literal requirement, then we would probably need to use a MS. However, if the reason for requesting the MIDI channel tagging was just to direct the notes to the appropriate Kontakt instrument, then I think the 4-Instrument/Script approach would be best.

*Tarzana, you still haven't actually indicated how you intend to use this script once you get it. For example, will it only be used to play Kontakt instruments or do you actually need to send channel-stamped MIDI data to the outside world?*

I should also add that my workload has just increased further so I have no idea if and when I might be able to work on this. However, I think the things we are discussing will be of value for anyone who wants to write this script and hopefully, someone will soon rise to the occasion :wink: 

Rejoice,

Bob


----------



## Big Bob (Oct 21, 2007)

So, if I read you right (although you haven't yet come right out and said it), you don't really need the chord to be channel stamped just as long as it is distributed to 4 different instruments (even though all four instruments will be operating on the same MIDI channel)? If this is correct, then you will want the 4-way script approach rather than the Multiscript. Just keep in mind that only the MS can channel tag notes (ordinary scripts can only generate notes on the same channel as the instrument that they are part of).

OK Now all that is left is for someone to step up to the plate and do the job for you. I don't think we can offer a refrigerator or a trip around the world for the first one to get this done but, I'm sure you will make Tarzana very happy :lol: 

God Bless,

Bob


----------



## kotori (Oct 22, 2007)

Big Bob @ Sun Oct 21 said:


> [...]Just keep in mind that only the MS can channel tag notes (ordinary scripts can only generate notes on the same channel as the instrument that they are part of).[...]


However, if you set the instrument to receive on Omni it's possible to channel tag notes and treat them differently depending on the original MIDI channel. I do this in my Organ Script to make it possible to use multiple keyboards for the manuals and pedalboard of the organ and have them trigger the right sound using just one instrument. To do this one needs to add 16 dummy groups with a silent sample mapped over the whole range and connect each group to a separate MIDI channel. The script can then examine which group is activated and hence determine the originating midi channel.

Nils


----------



## tarzana (Oct 22, 2007)

Hi Nils,

please bare with my lack of understanding
of how scripts work ... but are you suggesting
that your organ script can be used to take on 
the function of distributing a chord among several 
instruments in kontakt 

or were you addressing Big Bob's point of
Ms functionality

regards, 
Tarzana


----------



## kotori (Oct 22, 2007)

Hi Tarzana,
What I'm saying is that it's possible to let one Kontakt 2 instrument receive midi from multiple source channels and have a script treat notes differently depending on which source channel they came from. For example, if you play two keyboards simultaneously and send the midi data of both to one instrument it's possible to have a script treat notes differently depending on which keyboard they were played on, assuming that the keyboards send notes on different MIDI channels.

It's not really related to chords.

Regards,
Nils


----------



## Big Bob (Oct 22, 2007)

Hi Nils,


> For example, if you play two keyboards simultaneously and send the midi data of both to one instrument it's possible to have a script treat notes differently depending on which keyboard they were played on, assuming that the keyboards send notes on different MIDI channels.



I didn't know you could do this! How does the script know (ostensibly in the NCB) what MIDI channel the incoming note was tagged with? Maybe I'm missing somethng here but it almost sounds like you are saying that groups can be made to either respond to certain MIDI channels or that they can somehow have their output assigned to different MIDI channels, or both? Or am I just totally lost here :lol: 

Not only didn't I know you could do this MIDI channel thing but, it sounds to me like what you are suggesting is more or less the exact opposite of what Tarzana wants to do. If I read you right, you are starting with notes from a number of MIDI channels and using one script that somehow knows which notes were originally tagged with a given MIDI channel. Whereas I think what Tarzana wants to do is start with a chord (where each note originates on the same MIDI channel) and then split the four notes off to 4 different MIDI channels in one script. Aren't these two things more or less opposites? :? 

Boy am I confused :cry: 

Bob


----------



## kotori (Oct 22, 2007)

Bob, what I did with the organ patch + script was that I set the instrument to receive on midi channel omni and then added 16 groups that I set to receive on midi channel 1-16 (the MIDI channel is available as a group setting in the Source section). For each incoming note I then use the GROUPS_AFFECTED array to determine which of these 16 dummy were affected. I had only skimmed throught the thread and not read all posts properly when I added the comment above. Looking back at it now I probably misunderstood your post, so sorry for any confusion.


----------



## Big Bob (Oct 22, 2007)

Hey Nils,



> and then added 16 groups that I set to receive on midi channel 1-16 (the MIDI channel is available as a group setting in the Source section).



There's the part I missed! I either never knew that we could set groups to respond to a specific MIDI channel or I totally forgot about that capability. And, this would seem to give a script the means to determine a note's MIDI channel (at least indirectly). I guess it still doesn't apply to what Tarzana wants to do but, I'm very glad you mentioned it because I should have known about this. Now if only I can remember it for the next time I might need it :lol: 

BTW when you get the time, you might want to review your Editor thread for some of the more recent posts because you left a few things hanging there :roll: 

God Bless,

Bob


----------



## Big Bob (Oct 24, 2007)

Hi Tarzana,

I finally got a little time today and since no one has posted anything for you yet, here's a little script for you to play around with. Please read the 'Readme' file for info on how to install it and how it should work.

I've only tested it rather superficially so travel at your own risk :lol: 

Rejoice,

Bob


----------



## tarzana (Oct 24, 2007)

Hi Big Bob,

You are very kind to have taken
the time.. God Bless you...

I will try it out with joy 

i just don't see it posted here..

what am i missing :oops: 

Regards,
Tarzana


----------



## tarzana (Oct 24, 2007)

Hi Big Bob,

i won't swear ... but it was not here 
a minute ago..

maybe i had to refresh the browser..

anyways Thank you again dear friend if 
i may call you that..

regards,
Tarzana


----------



## Big Bob (Oct 24, 2007)

> anyways Thank you again dear friend if
> i may call you that..



You are quite welcome and sure, you can call me your friend. I always say 'You can never have too many friends' 8) 

Anyway, please let me know if you have any trouble installing the scripts. Since I don't know what your experience level is with installing and compiling scripts, I wasn't sure how detailed to make the Readme.

Have Fun my Friend,

God Bless,

Bob


----------



## tarzana (Oct 24, 2007)

Hi Big Bob,

it is working great :D 

now i am going to see how well it get's along 
with other scripts like humanizer ...however
if i am not mistaken the timing randomization 
on the humanizer would not be a wise move..
i am more interested in the slight detuning and 
possibly the random velocity...

ps.. kontakt experience( a library NI have created)
does come with a chord splitter
and what do you know.... it only handles three parts.. :o 
and it seems rather cumbersome ... requiring the pasting 
of groups (1 group from each instrument) into another instrument
that has the script within it sending the 3 notes to the 3 groups ...

i am not explaining it as clearly as possible... 

you are truly gifted to be scripting at this level ..to be able 
to whip something in a jiffy...

Thank you so much Big Bob,

i am blessed to have you as a friend :D 


regards,
Tarzana


----------



## Big Bob (Oct 24, 2007)

> it is working great



Glad to hear that, only I hope you won't expect too much from this basic implementation.



> now i am going to see how well it get's along
> with other scripts like humanizer ...however
> if i am not mistaken the timing randomization
> on the humanizer would not be a wise move..
> ...



I don't think there will be any problems as long as you put the splitter script first. Then only the notes intended for the selected 'Part' will 'get through' to the remaining scripts. Since the splitter doesn't do anything with tuning or timing per se (other than holding notes during the Gate time), you should be able to do whatever you want with them afterwords.



> ps.. kontakt experience( a library NI have created)
> does come with a chord splitter
> and what do you know.... it only handles three parts..
> and it seems rather cumbersome ... requiring the pasting
> ...



Does it however use a more intelligent algorithm for deciding which 'Part' (group in their case) should receive which notes of the chord?

BTW The technique I used in your script would easily lend itself to handle more than 4 parts. You could also replace the simple 'sort' of the Gate Queue with a more musically intelligent algorithm. So, now you may have some motivation to learn scripting :lol: Once you have absorbed the fundamentals, you might want to study the KS source script for the splitter to see what you can do to improve upon it :roll: 



> Thank you so much Big Bob,



Again you are very welcome and have a great day my friend.

Maranatha,

Bob


----------



## tarzana (Oct 25, 2007)

Hi Big Bob,

kind of off subject ....

would it be possible to combine let's say
chord splitter and humanizer and midi transpose into
one script since they are not clashing in terms of
functionality ..... if not .... is there any way to save
these 3 scripts and load them or rather apply them one shot 
into an instrument in kontakt rather than having to load one 
by one....

by the way Maranatha is aramaic ... which i am sure you 
know .... i, myself am assyrian ( we speak modern day
aramaic ) Maran = LORD ....atha = to come or will come 

In Christ,
Tarzana :D


----------



## Big Bob (Oct 25, 2007)

> would it be possible to combine let's say
> chord splitter and humanizer and midi transpose into
> one script since they are not clashing in terms of
> functionality



I'm not very familiar with these scripts but I presume you mean the ones that come with K2 (written by Martin Jann I think)? If so, the source code isn't locked so combining these scripts should be doable by anyone reasonably skilled with scripting. You can't just 'throw them together' any old which way but on the other hand it's not a severe brain strainer either :lol: 



> if not .... is there any way to save
> these 3 scripts and load them or rather apply them one shot
> into an instrument in kontakt rather than having to load one
> by one....



Are you familiar with the fact that you can save (or resave under another name if you like) any instrument (as a .nki file) and if the instrument has one or more scripts loaded with it, they will be saved along with the instrument? The next time you then reload that instrument it will include the scripts as well. Moreover, if the scripts are written using persistent variables for the controls, they will be initialized to your last settings when the instrument is reloaded.

Better yet for your situation with 4 instruments, if you have your four instruments loaded into the rack they become part of a multi. Now if you load the 3 scripts for each of your 4 instruments and then tweak the controls the way you want everything, all you have to do is save the whole shebang as a Multi (ie as a .nkm file). Then, the next time you launch K2, just reload the Multi and all 4 instruments and all their scripts will be loaded and initialized in one 'swell foop' 8) 



> by the way Maranatha is aramaic ... which i am sure you
> know .... i, myself am assyrian ( we speak modern day
> aramaic ) Maran = LORD ....atha = to come or will come



Yes, indeed, 'even so come quickly Lord Jesus, Amen'?

God Bless you and Have a nice day my Friend,

Bob


----------



## tarzana (Oct 25, 2007)

Hi Big Bob,

I'm sorry for not being as clear as possible with my
question regarding loading up several scripts...and
yes i was referring to the stock scripts (midi transpose,humanizer)

my question should have been posed in this manner.....

can i load an instrument and then with a single click?
load up several scripts .... kind of like a macro function...

just to speed up the experimentation process if you will...

i am aware of the ablitiy to load scripts into an instrument
and save for future recall(use)

what i was wondering was the possibilty to load the instrument and
with one click the 3,4,or 5 scripts being loaded into 
the instrument simultaneously....

i know that a default instrument can be saved with the 
scripts loaded ... but that only allows for .wav to be dropped in
to the blank default instrument ... 

i hope it can be done ... if not, it's just a few clicks...
well maybe more than a few but nothing to complain 
about ... i am ever so grateful for the sharing of your time
and your efforts ...

God Bless,

Tarzana


----------



## Big Bob (Oct 26, 2007)

Hi Tarzana,



> what i was wondering was the possibilty to load the instrument and
> with one click the 3,4,or 5 scripts being loaded into
> the instrument simultaneously....



I don't personally know of any way to load multiple scripts into an instrument with 'one-click' so to speak but I don't usually do that sort of thing. Maybe some of our other forum members, who do bigger and better things than I, may have worked out some way to do this :roll: 

How about it everyone, do any of you have some clever way of quickly loading a set of scripts into different instruments?

Sorry I can't help you with this but, as my former business partner always used to say 'No one knows everything about everything' :lol: 

Rejoice,

Bob


----------



## tarzana (Oct 30, 2007)

Hi Big Bob,

this chordsplitter is working great.... :D 

i use the midi transposer script (kontakt factory script)
to get a drop 2 voicing or drop 2 and 4 by the same process
(-1 octave) in the 2nd and 4th voicing...
any suggestions how i might be able to automate this process
or assing a global script...

i am not making much sense if any .....

sorry ... 

just wondering if there would be a way to manage
dropping octaves through some kind of global presets 
in a script, that would provide for realtime manipulation

God Bless,
Tarzana


----------



## Big Bob (Oct 31, 2007)

Hi Tarzana,

I'm sure that the script could be embellished to provide some of these options you want. Unfortunately though, these mods will have to be made by someone other than me. :( In spite of my new pacemaker, I just incurred another incidence of Atrial Fibrillation and I'm going to have to discontinue all my forum activities, perhaps permanently.

However, the code I gave you is well commented and any competent scripter should be able to modify it for you. So, maybe someone else can pitch in here?

Sorry that I can't help further.

Maranatha, (maybe sooner for me :lol: )

God Bless,

Bob


----------



## Hans Adamson (Oct 31, 2007)

Bob,

Take care, get better, and thanks for all your outstanding contributions.


----------



## tarzana (Oct 31, 2007)

Hi Big Bob,

Thank you for all your help.  

You will be in my prayers...

interesting you should mention sooner for you
there is a tremendous amount of information in the Bible
with regards to among other things the timeline

time has an end

if you are interested check it out for yourself
familyradio.com

may 21, 2011 

p.s."We are confident, I say, and willing rather to be absent from the body, and to be present with the Lord." (2Corinthians 5:8, KJV) 


In Christ,
Tarzana


----------



## tarzana (Feb 7, 2008)

Hello All,

First off let me start by sending a shout out 
to Big Bob 

Thanks for the chord splitter script. It works great.

Now I am hoping someone with the knowledge and willingness
would kindly consider expanding this script to allow for 6-8 voices.

Thank you in advance

Best regards,
Tarzana


----------



## tarzana (Feb 20, 2008)

Hi Everyone,

It seems no one is willing to expand this script 
to accomadate more voices...

currently it allows for four...

i am clueless about scripting but if someone
might be willing to help guide me in what i may
need to know . 

if this script could handle 6 or 8 voices that would 
be awesome...

Any takers?

:oops: 

best regards,
tarzana


----------



## Big Bob (Feb 20, 2008)

Hi Tarzana,

I edited your script for 8 voices. I also defined a 'Voices' constant that you can change if you want a different number of voices in the future (you can make it as high as 16 but no more). I also edited the readme file accordingly.

I think I made the changes correctly but I don't have time right now to test this.

God Bless,

Bob


----------



## tarzana (Feb 20, 2008)

Dearest Big Bob,

I'm blessed to be able to call
you a friend.

I would post the beer saluting emoticon but "It is not for kings, O Lemuel, it is not for kings to drink wine; nor for princes strong drink" 
Proverbs 31:4

In Christ,
Tarzana :D 

I will pray for your continued health.


----------

