Relocating Keyswitches is easy

stephen24
stephen24 Member Posts: 250 Advisor
edited January 28 in Kontakt

There have been quite a number of people posting about problems with awkwardly located keyswitches. Relocating them is dead easy, using a multiscript. This facility is available even on Kontakt Player (at least according to the manual) and is accessed via the KSP button at the top R of the Kontakt window. It modifies MIDI messages before they reach the instruments.

The simplest way is to use the Factory Script - Preset>Factory>Transform>Change Keys. Changes any 12 keys to wherever you want.

This will of course affect all the instruments in that Kontakt instance, so if you want separate keyswitch relocations for different instruments in the same multi, you can give them separate channels and use this simple custom script: paste, fill in the 4 variables - channel, lowest/highest_ks, how much you want the notes moved, and click Apply. You can have instances of the script in several slots, or just duplicate the lower half of the script (from "on midi_in") as many times as you need.

on init
 declare $channel
 declare $lowest_ks
 declare $highest_ks
 declare $transposition
end on


on midi_in

          {  ***set these 4 values***  }

 $channel := 1
      
 $lowest_ks := 24   {  current keyswitch  }
 $highest_ks:= 36   {     note numbers    }

 $transposition:= 24 {   how far down you want them transposed   }
                     {  (negative value will transpose upwards)  }



if ($MIDI_CHANNEL = $channel -1)
 if ((($MIDI_COMMAND = $MIDI_COMMAND_NOTE_ON) or ($MIDI_COMMAND = $MIDI_COMMAND_NOTE_OFF))...
 and ($MIDI_BYTE_1 >= ($lowest_ks-$transposition)) and ($MIDI_BYTE_1 <= ($highest_ks-$transposition)))
   set_event_par($EVENT_ID, $EVENT_PAR_MIDI_BYTE_1, $MIDI_BYTE_1 + $transposition)
 end if
end if

end on



Comments

  • Sausagefingers
    Sausagefingers Member Posts: 20 Member

    Thank you so much. Apologies - I didn't see the link, probably because I came straight to the comments section. It looks like it may well do the job, but gives another challenge - I have never done scripting before! My musical activities came to an end 30 years ago because of RSI caused by computer keyboards "built to a price", which was just as MIDI started to appear, so I have missed all the developments since then. Needless to say I have also spent most of that time away from computers as well!

    I will give it a go! At the moment I use Kontakt Player within Cantabile for live playing, so each instance of Player is on a per song basis, and because my playing is still somewhat limited so that I can manage the RSI, actually using keyswitches isn't often a feature I need, so I can just push them down to the bottom of the range, which is off the range of my 61-note keyboard.

    You may well have saved the day. Thank You!

  • stephen24
    stephen24 Member Posts: 250 Advisor

    Nothing to apologise for. (Actually this was just a ruse to get back in the front page - this forum is so busy things very quickly get buried)

    Let us know if you need any help.

  • Sausagefingers
    Sausagefingers Member Posts: 20 Member

    HI. I'm back. After a long illness I have started trying the scripting route that you suggested. I have had limited success with Transform/Change Keys, because it has taken some of the keyswiches out of the equation - thank you! However, on the first instrument I tried there are mor than 12 notes acting as keyswitches. I went onto to INIT but it went straight back to the instrument screen. I have also tried vi the EDIT screen, but obviously having never done scripting before all I get is a red highlight for the first line, which I don't know how to correct.

    For the initial vst (strummed guitar 12 string, I want to transpose keys c1 to D#2 down by 12 notes. How does this look in the actual script?And can I achieve this vbi the EDIT screen, or is there another way I should be doing it?

  • stephen24
    stephen24 Member Posts: 250 Advisor

    Just paste the above script into an empty multiscript slot (KSP button, Edit opens the script text area) and set the 4 values (just after on midi_in) to what you want - channel number, lowest and highest keyswitch notes (in Kontakt I think C1 is note 36, D#2 51) and the transposition (12) . ("Transposition" is how the script will move the keyswitch note you play, so it will be positive here), then click on Apply. You need to click Apply again after any alterations.

  • stephen24
    stephen24 Member Posts: 250 Advisor

    There was an error in the script which I have corrected. It should function correctly now. (If you copied it before the time of this post, you should start again)

  • Sausagefingers
    Sausagefingers Member Posts: 20 Member

    Right: so I copied the script you gave me onto the edit screen and clicked "Apply", but nothing changed. Here is what I entered for midi channel, highest and lowest keyswitch and transposition:

    on init

     declare $channel

     declare $lowest_ks

     declare $highest_ks

     declare $transposition

    end on



    on midi_in


     $channel := 1    

     $lowest_ks := 12

     $highest_ks:= 27

     $transposition:= 24


    if ($MIDI_CHANNEL = $channel -1)


     if ((($MIDI_COMMAND = $MIDI_COMMAND_NOTE_ON) or ($MIDI_COMMAND = $MIDI_COMMAND_NOTE_OFF))...

     and ($MIDI_BYTE_1 >= ($lowest_ks-$transposition)) and ($MIDI_BYTE_1 <= ($highest_ks-$transposition)))

      set_event_par($EVENT_ID, $EVENT_PAR_MIDI_BYTE_1, $MIDI_BYTE_1 + $transposition)

     end if


    end if


    end on

    So what am I doing incorrectly?

  • stephen24
    stephen24 Member Posts: 250 Advisor
    edited January 28

    Values to be filled in are the current keyswitch note numbers. I have added a few more notes to the script to make it clearer.

    I think the note numbers you want are 36 and 51 (assuming middle C = C3). Transposition 12 or 24 whichever you want.

  • Sausagefingers
    Sausagefingers Member Posts: 20 Member

    Got you now. I made the mistake of putting in the key numbers of where I wanted the transposed keyswitches to end up! SO now I have put in the numbers you suggested!

    So now I have pasted in the following script, and changed the MIDI channel in Kontakt Player from OMNI to "1":

    on init

     declare $channel

     declare $lowest_ks

     declare $highest_ks

     declare $transposition

    end on



    on midi_in


          


     $channel := 1

        

     $lowest_ks := 36

     $highest_ks:= 51


     $transposition:= 24

               




    if ($MIDI_CHANNEL = $channel -1)

     if ((($MIDI_COMMAND = $MIDI_COMMAND_NOTE_ON) or ($MIDI_COMMAND = $MIDI_COMMAND_NOTE_OFF))...

     and ($MIDI_BYTE_1 >= ($lowest_ks-$transposition)) and ($MIDI_BYTE_1 <= ($highest_ks-$transposition)))

      set_event_par($EVENT_ID, $EVENT_PAR_MIDI_BYTE_1, $MIDI_BYTE_1 + $transposition)

     end if

    end if


    end on

    But still no change!

  • stephen24
    stephen24 Member Posts: 250 Advisor

    And I thought it would be easy.

    It works on my computer. Not sure what you mean by no change. Open the Mapping Editor and if it's set up properly you'll see a tiny red mark in the mapping area when you play a note, e.g. by clicking on the Mapping Editor keyboard.. That's the note (and velocity) that's being played. You've set the script for 2 octaves (24 notes). Did you mean to set it for 1? Remember to click Apply so the orange light goes out. Can't think of anything else.

    If it's too dificult and you're only having one channel, you can use several copies of the Factory Transposition script in separate slots to cover all your keyswitches.

  • Sausagefingers
    Sausagefingers Member Posts: 20 Member

    I set transpose to 24 simply to move the keyswitches right out of the way. I did click on "Apply", but didn't scroll down the script, so didn't see that it had highlighted a line, as per the screenshot (presumably it will highlight each line that needs attention successively), so there may be more. What does the highlighting indicate that needs correcting?

    My apologies for this being long and drawn out. S I may have mentioned, I developed RSI from my employer's "budget" computer keyboards many years ago, just as MIDI started to appear, and have only been able to return to music recently. So I am on a massive learning curve, knowing very little about MIDI itself, and have never done scripting before! So although I appreciate something of what MIDI offers, I am a complete beginner when it comes to technical stuff like this!

    I have managed to create a work-around, simply by using the transposition setting within Cantabile, my vst host. So I h, using the top octave for tave Icon Bass transposed to send its keyswitches out of the lower range of my 61 note keyboard, and then transposed the guitar vst upwards, using the top octave for the chords, with the keyswitches landing in the middle of the keyboard. IT limits me to a single octave for bass playing, and of course the single octave for the guitar chords- the latter is fine, but the whole thing is a little clumsy. But until I can get the scripting sorted, it will have to suffice.

    Many thanks for your patience

  • stephen24
    stephen24 Member Posts: 250 Advisor

    You've put extra empty lines between the lines of code, and it doesn't like this. (The line before the red highlight is the first half of a long line of code which I have split in half for visual convenience. It expects the line to be continued after the ". . ." and just finds empty space.)

    If you are going to use only one channel, or "omni", you don't need my script whose sole advantage over the Factory Transposition multiscript is that you can have different keyswitch relocations in different instruments on separate channels.

    Why not have one more go, copying the script directly from my post above, put in you own variables, you can use "omni" (one less thing to go wrong!) and see how it goes? It would be nice to have it working. Otherwise you could use multiple copies of the Factory multiscript as I suggested above. Good luck!

    (If you save the setup in Kontakt, you'll need to save it as a multi, so as to include the multiscript setup.)

  • Sausagefingers
    Sausagefingers Member Posts: 20 Member
    edited January 30

    Ahaaa!!! Progress! I now have it that the pink keyswitches have been transposed (note numbers 26 - 41), but the yellow and green ones (note numbers 44 - 51) remain in play!

    Incidentally, as an aside, I have spent some time exploring the Mapping Editor, which I have is only accessible via "File/New Instrument", which gets placed below the Guitar vst. The New Instrument displays (DEMO) in red, and I get the message "Only available in full Kontakt", which I suspected. So the normal "spanner" icon in the top left corner of the screen isn't there, replaced by a white rectangle with two sizes of the "Settings" icon, which bring up the "instruments options" dialogue box. Ho hum!

    But at least a part of our objective has been realised!

    So this is a copy and paste of what the script looks like now I have pasted it into the edit page:

    on init

     declare $channel

     declare $lowest_ks

     declare $highest_ks

     declare $transposition

    end on



    on midi_in


         { ***set these 4 values*** }


     $channel := 1

        

     $lowest_ks := 36  { current keyswitch }

     $highest_ks:= 51  {   note numbers  }


     $transposition:= 24 {  how far down you want them transposed  }

               { (negative value will transpose upwards) }




    if ($MIDI_CHANNEL = $channel -1)

     if ((($MIDI_COMMAND = $MIDI_COMMAND_NOTE_ON) or ($MIDI_COMMAND = $MIDI_COMMAND_NOTE_OFF))...

     and ($MIDI_BYTE_1 >= ($lowest_ks-$transposition)) and ($MIDI_BYTE_1 <= ($highest_ks-$transposition)))

      set_event_par($EVENT_ID, $EVENT_PAR_MIDI_BYTE_1, $MIDI_BYTE_1 + $transposition)

     end if

    end if


    end on

  • ms54321
    ms54321 Member Posts: 1 Member
    Hi, did you get it fully working in the end? I am trying to do the same thing. Also - do you have any videos of you live playing? I do something similar and would be interested in seeing your playing :)
  • stephen24
    stephen24 Member Posts: 250 Advisor

    If you want to relocate your keyswitches, just read the first post in this thread and ignore the rest, which is just about a misunderstanding because I didn't explain it clearly enough. I edited the script instructions so it is now entirely clear.

Back To Top