High numbered keyswitches retuning

Sketch for Kontakt high numbered key switches retuning source code.

Status
This now runs okay and permits high keyswitch retuning of Kontakt instruments.

For the draft of the RPN spec see Tuning RPNs (specification draft). I've modified it here, instead of using the data increment and decrement, I do it using keyswitches

The keyswitches idea
This is the brilliant suggestion of Dr Ozan Yarman, The topmost notes of the midi range are rarely used in instruments - are well beyond the top notes of a piano.

Keyswitches are often used to change playing styles of instruments, but typically they use notes below the natural range of the instrument to do this. The high notes are normally not used for anything.

So the idea is to send the information using the note on velocities of the note numbers 124 to 127. In this script I also use note number 123 to send an extra ultra fine pitch resolution byte.

The instructions used in this script are: where v (note velocity) > 0

For v = 0 use

How to use this
This script adds four knobs to the user interface for your instrument.

To retune aNY note on the keyboard to anywhere in the midi range, use the first knob to select the input note, second knob to select output note, third note to set pitch bend, and 4th knob to fine adjust the pitch bend in millicents

Later on I plan to release a version of Bounce Metronome able to send RPN and undefined controller messages to retune these instruments via midi, so e.g. you just need to select a SCALA scale from a drop list to retune all the notes to that scale.

Other programmers of retuning software will probably follow suit.

NOTE - BETA, WORK IN PROGRESS

How to add this script to a Kontakt instrument
Note, this is a BETA script - particularly since the spec itself is work in progress. Also to install a script into an instrument, you need the full version of Kontakt. You can't use this with Kontakt Player.

To add this script to a Kontakt instrument you click on the wrench icon then on Script Editor, then look for an empty slot labelled Click on tab to select it and then click Edit. Enter any desired title for the script and copy and paste my script into the edit field. Then click Apply and the knobs will appear and your instrument can now be micro-tuned in Kontakt.



Some instruments can't be retuned in this way because all four of the script slots are filled and are password protected. If the script slots are not password protected you might be able to merge my script with the script already there if you have some knowledge of how the scripts work.

So for instance Kontakt instrument designers could merge this script with their instrument scripts to make their instruments micro-tunable

which retunes InputNote to OutputNote + Pitch Bend (in cents, usual format)

see discussion here: Discussion of RPN retuning on facebook

For the undefined controllers method I use the undefined controllers 115 to 118 as follows to retune a note:

where the retuning info gets updated on receipt of the controller 118. So on receipt of controller 118 it uses the current values for controllers 115 to 118 to determine how to retune the input note as set by controller 115.

I also used

Here is the complete script, including diagnostics

Useful external links
http://www.sandymilne.com/category/kontakt-scripting/

http://nilsliberg.se/ksp/

http://www.soniccouture.org/tutorial/scriptorium-manual.pdf

http://www.audiotek.cz/produktyATK/ni/kontakt3_p2.pdf

http://www.soundonsound.com/sos/jul10/articles/kontakt1.htm

bug details
I've actually got this working now, successfully retuned a Kontakt instrument to 120-et using RPN retuning sending the RPN messages from a debug build of Bounce Metronome.

But ran into a curious issue. I have to leave a pause of 40 ms between each change of rpn like this:

RPN coarse: 101 RPN fine: NoteToRetune Data entry coarse 0 Data entry fine: NoteToRetuneTo

Sleep(40)

RPN coarse: 100 RPN fine: NoteToRetune Data entry coarse : Pitch bend MSB Data entry fine: Pitch bend LSB

Sleep(40)

If I set it to less than that e.g. Sleep(10) then it gets mixed up.

It will use e.g. the Pitch bend LSB as the NoteToRetuneTo, as if it never got the intervening RPN coarse and RPN fine messages.

Anyone know why that is necessary and whether there is a work around?

Note - never found a solution to this. Same thing happened with the undefined controllers retuning. Needed to have a sleep of about 10 ms between each controller sent. If sent without sleeps, then I found that the script only received 12 controller messages out of a batch of 512 controllers sent to Kontakt, in a test run.

But - the keyswitches idea solves this. Notes are high priority.