# -



## Huffer (Jan 15, 2016)

--


----------



## Luca Capozzi (Jan 15, 2016)

check the in_range function in the KSP manual.


----------



## Huffer (Jan 15, 2016)

--


----------



## Huffer (Jan 15, 2016)

--


----------



## willbedford (Jan 15, 2016)

Do you simply want to split the keyboard in half, so anything below middle C is detected as left hand, and anything above is right hand? 

```
on note
    if ($EVENT_NOTE < 60) {left hand}
       
    else {right hand}

    end if
end on
```


----------



## Huffer (Jan 15, 2016)

--


----------



## Jerome Vonhogen (Jan 15, 2016)

If you'd connect a Kinect v2 XBox MoCap-sensor to your PC, you would be able to track finger movement. In game engines such as Unity 3D, that MoCap data can be used in real-time quite easily via inexpensive 3rd party plugins from Unity's Asset Store.

To use the same MoCap data in a DAW environment to interpret Midi input data is (much) more complicated, since the data has to be "read" by your DAW in an efficient way. A while ago, I came up with some ideas for the design of a sequencer plugin that would do just that, but so far, I haven't had time to build a prototype.

I'm not sure if there would be much interest in such plugin anyway, since it would require the purchase of MoCap hardware.

- Jerome Vonhögen


----------



## willbedford (Jan 15, 2016)

Huffer said:


> Hi Will,
> I would like this to detect the hand so it moves, so it does not matter where or how each hand is playing the script will update (in cases changing the key colour to show the split)
> Splitting things into left hand playing and right hand playing. not something which is static on the keyboard itself, but updates upon each new note so that the key split is fluent.
> 
> ...


Using MIDI alone, there is no way to detect which hand is pressing a key. There might be a way to roughly guess based on which notes are pressed. For example, if a bunch of keys are pressed close together, and another bunch of keys are pressed higher up the keyboard with a significant gap between the two, you could safely assume which notes are pressed by each hand. As soon as the hands get closer together, it will be very difficult to differentiate the two.


----------



## Huffer (Jan 15, 2016)

--


----------



## Jerome Vonhogen (Jan 15, 2016)

Here's my suggestion:

Connect two individual Midi-controllers to your DAW and place them on top of each other like the double keyboard instruments from the Baroque that Bach used, or like an organ.

Add two separate, corresponding Midi tracks to your (sequencer) project, and make sure the Midi input from each keyboard is received exclusively by those individual tracks (make sure your DAW assigns individual ports to your Midi controllers).

Direct the Midi Out data of both tracks to the same virtual instrument (usually a VST plugin) on the same Midi channel via the same Midi port for realtime feedback, playback, mixing, bouncing, etcetera. Play your piece with each hand on a separate keyboard, record the sequence, and you're done!

If your sequencer can receive and record Midi data in layers, you may only need one Midi track.

For a setup like this, your controllers don't need to have a range of 88-keys; 76 keys should give enough overlap for the left and right hand if you map the keyboards in your DAW with a combined shift of two octaves. (Keyboards with a range <88 keys often have some sort of note/octave hardware shift button, so this might be done outside your DAW entirely.)

- Jerome Vonhögen


----------



## Huffer (Jan 15, 2016)

Sorry if i placed this in the wrong thread?


----------



## Stiltzkin (Jan 15, 2016)

It is possible, but it would in no way be perfect - there would be a lot of times when you're playing chords together and the script would just get confused.

Since the script wouldn't know which hand is doing what physically, it would just split it in a pre-defined way for certain conditions.

Because of this, you would get a lot of splits not in the right place (ie playing a 4 note chord in the right hand, and a 3 in the left both close to each other) the script wouldn't be able to tell which hand is doing what and would thus give an incorrect split value.

If you're ok with these times when it will do that, then yes it is possible. Additionally if you were thinking of having melodies be split too, that could really just be thought of as polyphonic legato which is less complicated, but can and does still make mistakes based on what you want.


----------



## Jerome Vonhogen (Jan 15, 2016)

Huffer said:


> I think i might just be explaining myself quite poorly.
> in other words, a split keyboard, like you suggested in your "60" centre split. But the value for 60 changes so it is always inbetween the 2 chords you are playing. Which for arguments sake I called left hand and right hand. So possibly calling in an adaptive split keyboard might have been better words. I dont care if its left then right hand or vice versa, or one hand with very adventurous fingers.
> 
> Just a way so I can eventually tell one area to play one sound and another area of the keyboard to play another sounds. and the ranges which are assigned can adapt in realtime to the playing. I know this must be possible someway as it seems something very important to key splitting. Does this make more sense?


 

This can be done by filtering the note values after recording, or by using a custom input transformer (very easy to setup). I used to do that a lot when I was using Nuendo, years ago. I'm sure Cubase has an input transformer as well. Should be possible in most sequencers.

- Jerome Vonhögen


----------



## d.healey (Jan 15, 2016)

Jerome Vonhogen said:


> This can be done by filtering the note values after recording, or by using a custom input transformer (very easy to setup). I used to do that a lot when I was using Nuendo, years ago. I'm sure Cubase has an input transformer as well. Should be possible in most sequencers.
> 
> - Jerome Vonhögen


Kontakt scripting Jerome, nothing to do with a DAW or sequencer, purely in Kontakt script!!!


----------



## d.healey (Jan 15, 2016)

This is not really possible, not in any accurate way like you're asking. Kontakt doesn't see hands it only sees a bunch of MIDI notes, so here is an image. If you can work out which hand was pressing which keys then reverse engineer how you figured it out and put it into a Kontakt script.





btw, it's harder than I thought to take a screenshot with both hands on the piano!


----------



## Huffer (Jan 15, 2016)

--


----------



## Jerome Vonhogen (Jan 15, 2016)

d.healey said:


> Kontakt scripting Jerome, nothing to do with a DAW or sequencer, purely in Kontakt script!!!


 

Apparently, you have a better solution, so why don't you help the OP getting the results he wants with Kontakt? I would say it's inefficient and (probably) ineffective to try to program this in Kontakt, but what do I know, right? 

Good luck!

- Jerome Vonhögen


----------



## d.healey (Jan 15, 2016)

Huffer said:


> In the case of your screen shot I would happily just take it half and half, but of course in real world scenarios you do not hit every single note at the same time surely?


That's true, so if you want to detect hand position once the notes are held down you will need to decide on a time threshold between the first note being pressed and your hand detection script triggering.


----------



## Huffer (Jan 15, 2016)

--


----------



## Huffer (Jan 15, 2016)

--


----------



## willbedford (Jan 15, 2016)

You could do it if you could guarantee that both hands were playing the same number of notes at a time. For example, if 6 notes were pressed, the top 3 would be assigned to the right hand and the bottom 3 would be the left hand.


----------



## Jerome Vonhogen (Jan 15, 2016)

For each new pair of simultaneously played chords (or notes), you just need to calculate the average of the highest and lowest note value. That's your variable splitpoint, even when chords of the left and right hand overlap, and even when you cross hands/arms like in Bach's Goldberg Variations (although you'd then have to switch both staves as long as you play with crossed hands).

This kind of thing can be done in a sequencer in realtime with any input transformer. Why would you even want to try to write a script in Kontakt for this? This is a typical sequencer task and a very simple one as well.

In this case, using a Kontakt script for note value filtering doesn't make any sense, since you don't want Kontakt to actually use that data anyway. This is just a matter of organizing Midi data in your project, which is why you have a sequencer in the first place.

Only if you're using Kontakt as a stand-alone sampler, Kontakt scripting would make sense.

- Jerome Vonhögen


----------



## d.healey (Jan 15, 2016)

Jerome Vonhogen said:


> Only if you're using Kontakt as a stand-alone sampler, Kontakt scripting would make sense.


Or perhaps he wishes to create and sell a sample library with this functionality


----------



## Jerome Vonhogen (Jan 15, 2016)

d.healey said:


> Or perhaps he wishes to create and sell a sample library with this functionality


 

Yes, that's true, but then he would probably already know this kind of stuff. If not, his sample library might end up as vaporware, since the production of every sample library requires extensive scripting. 

- Jerome Vonhögen


----------



## Stiltzkin (Jan 15, 2016)

Jerome Vonhogen said:


> Yes, that's true, but then he would probably already know this kind of stuff. If not, his sample library might end up as vaporware, since the production of every sample library requires extensive scripting.
> 
> - Jerome Vonhögen



Everyone has to start somewhere - he's looking for help getting started which I think we're all happy to help with 

The fact that it is in the scripting forum sort of made me assume this was the case, no?


----------



## d.healey (Jan 15, 2016)

Jerome Vonhogen said:


> Yes, that's true, but then he would probably already know this kind of stuff.


I don't know how to do it, I've never done it before, it would take me some time to experiment and figure out the best approach (if it's even possible), the first thing I would do is check the forum to see if it's been done before.


----------



## Jerome Vonhogen (Jan 15, 2016)

Stiltzkin said:


> The fact that it is in the scripting forum sort of made me assume this was the case, no?


 

I wouldn't know, since I'm reading this on my Samsung Note 4, which for some reason doesn't show the names of the specific forums. 

- Jerome Vonhögen


----------



## Mike Greene (Jan 15, 2016)

This is a very interesting challenge. It sounds simple at first, but it isn't. David and Stilzkin have made some good points and suggestions. The tricky part of this is figuring out what the "rules" would be, since there are so many possibilities. My thoughts would be:

1. If no other notes are pressed, then if it's below 60, it's left hand, above is right hand.

2. If more than one note is pressed, then you could split in the middle, except you'd need a lot of exceptions. For instance:

2a. If only two or three notes are played and if the interval is small, then just one hand. I wouldn't use two hands to play a basic C major triad, for instance.

2b. Left hand has a limit of a one octave span. All other notes go to the right hand. (At least that's how I usually play.)

2c. If a note above 60 (middle C) gets played, then our rule already says that would be right hand. But then a few milliseconds later, maybe a new note two octaves higher gets played, while sill holding the first note. So we need to make a correction so the first note is *left* hand and the second note is right hand. This is a problem David mentioned earlier about a time window, since a player doesn't normally play notes at *exactly* the same time.

There are lots of other little exceptions or special cases, but those are the ones off the top of my head.

To script this wouldn't necessarily be that difficult. (Then again, that's what I always say. Then two week later . . .  ) The first, and more difficult, task is to come up with a complete set of rules. That's the part you can do even if you don't know KSP.


----------

