1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

Key Mapping Feature *HELP*

Discussion in 'Scripting Workshop' started by Mr.Lion, Apr 18, 2015.

  1. Mr.Lion

    Mr.Lion NI Product Owner

    Messages:
    159
    Hello!

    This is my first post here.

    I've been having some problems with doing a Key Mapping feature that will give you the opportunity to change a certain key of the instrument,
    for example:

    The snare is on C1 but you would like it to be on D#4 instead.

    Best Regards
     
    Last edited: Apr 26, 2016
  2. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Read up on the change_note() command in the the KSP Reference :)
     
  3. Mr.Lion

    Mr.Lion NI Product Owner

    Messages:
    159
    Thanks, but I've done that.
    But I haven't really understood how it works so I'm still on square 1 :(
     
  4. Mr.Lion

    Mr.Lion NI Product Owner

    Messages:
    159
    I really really need help with this.

    I'm currently doing some scripting for a very large drum kit.

    I've managed to find out most of the stuff by reading the KSP Reference and Googling but i really can't figure out to create a function like this.
    You adviced me to read up on the ''change_note'' in the KSP Ref. and I've tried to figure out the meaning and how it works but I can't seem to get my teeth in it.

    The thing is that I need a similiar function like in the video that I've posted in the thread, were you can change various articulations but not the part were you can enter the key yourself but more like the function in this picture HERE

    It works like when you press the ''Listen'' button you are able to press wich key you want and that articulation will change to that key.

    Would love if someone could give me some guidance or tips, I really need to figure this out.

    Best Regards!
     
  5. Big Bob

    Big Bob Forum Member

    Messages:
    606
    I think the reason that no one is responding here is that your request is rather unclear.

    Is this your instrument with your scripting or are you trying to modify someone else's instrument and/or script?

    If someone else's instrument, will you be able to position a custom script in front of the existing scripts?

    If so, all you would need to do is write the code so that if transforms specific incoming notes to new ones and for that you can use the change_note function as Mario already suggested. I can post an example of such a script if you give me a short list of some of the instrument names and their current note assignments that I can use as an example for you.

    Rejoice,

    Bob
     
  6. Mr.Lion

    Mr.Lion NI Product Owner

    Messages:
    159
    Hello Bob!
    I see, i'm so sorry I shall try to clarify.

    The function i would like to have is for example:

    I have an Snare instrument with
    - Hits, Soft-RimShot articulations on C1
    - Rim Click on C#1
    - Side Stick on D1

    And I want to make a similiar function like the one in the video when you he presses the ''Midi Learn'' button and then the next incoming key will be the new one for the specific articulation, let's say i want to change the Hit key from C1.
    Then I press ''Midi Learn'' and after that C2 and now the snare Hits will be played on the C2 key instead of C1.

    The thing is that I've tried to look into the instrument scripts on the instrument in the picture I linked in my last post, but it's so nicely done so I really cant figure out what is what. I can post it in a minute if you want to check it out?

    The instrument in the video I haven't had the pleasure to buy yet!

    Here's one instrument:

    TMD Custom ply Hybrid Maple Snare (name)

    Articulations:

    Hits:
    There are 5 Samples for each mic and they are organized in 4 groups:
    Direct_mic 1-5 etc


    Direct_Mic (C1)
    OH_Mic (C1)
    Room_Mic (C1)
    Rim_Click (C#1)
    Side_Stick (D1)


    I hope i've clarified it better!

    Best Regards
     
  7. Big Bob

    Big Bob Forum Member

    Messages:
    606
    You still haven't stated whether you want to use this script with your instrument or with someone else's? I need to know if you have charge of all the script slots or not?
     
  8. Mr.Lion

    Mr.Lion NI Product Owner

    Messages:
    159
    It's for my own instrument, sorry for that!
     
  9. Big Bob

    Big Bob Forum Member

    Messages:
    606
    OK my friend. As soon as I get a little block of time I'll post something for you. I'll keep it simple and just use the first 3 sounds you listed with the default note assigments as C1, C#1, and D1. Are you using Nils' KScript Editor (the KSE)? If not, you really should get hold of a copy (it's free).

    Let me know before I get ready to post something for you because it will be easier for me to post code in KSE source format than native Kontakt source format.

    Rejoice,

    Bob

    BTW Mr. Lion, what's your first name? I'm a very informal kind of guy :)
     
  10. Mr.Lion

    Mr.Lion NI Product Owner

    Messages:
    159
    Thank you so very much Bob! Means alot that you will take your time to help me out!

    No, I have it installed but I have never ended up using it. I'm using Sublime and Notepad ++ or windows stock Notepad when Scripting!

    My name is Robin! My nickname here is acutally a translation of my last name.

    Best of Regards!
     
  11. Big Bob

    Big Bob Forum Member

    Messages:
    606
    OK Robin,

    Why don't you fire up the KSE and play with it a little. When I post some code for you, you will need to load it into the KSE first and then hit F5 to pre-compile it and put it in the clipboard. You will then be able to paste the clipboard into Kontakt's script editor, hit apply, and run it. The KSE source code cannot be directly pasted into K5's script editor but must be pre-compiled by the KSE first. This can be new adventure for you.:)

    Give me a day or so to post something for you but, in the meantime, someone else may jump in here now that I got you clarify what you wanted;)

    Rejoice,

    Bob
     
  12. Mr.Lion

    Mr.Lion NI Product Owner

    Messages:
    159
    I will! It's gonna take some time to get used to, but I'll be sure to manage it in time!

    Yes Sir!


    Also, Another question that popped up (if you don't mind). In the video upstairs that I posted there are tabs when he presses ''Snare Top'', Snare BOT'' etc How is it possible to achieve that cool feature?

    I have a snare with up to 10 Mics that I'm adding FX knobs etc for mixing inside kontakt etc but it's getting abit crowded so something like that would be a lifesaver!

    ( EDIT: Like in the video, the FX tabs doesn't hide the main menu)

    I just want a heads-up were to look!

    Best Regards
     
    Last edited: Apr 26, 2015
  13. Big Bob

    Big Bob Forum Member

    Messages:
    606
    Hi Robin,

    I've sketched out the control panel for your demo script and when I get another block of time, I'll add the algorithmic code and post the completed script.

    Meanwhile, I'm going to post the KSE source code up to this point so you can get some practice with using Nils' Editor. When you compile the following code (using the KSE) and paste the clipboard into Kontakt's script editor and then hit Apply, it should bring up the control panel as shown below. The script currently is non-functional because it does not yet contain the algorithmic code.

    on init
    ``message('')
    ``set_ui_height_px(200)
    ``make_perfview
    ``declare const X := 50```{ sub-panel coordinates }
    ``declare const Y := 30
    ``declare const dY := 20``{ row spacing }
    ````{ Default instrument drum-sound/trigger keys }
    ``declare const NumSounds := 3
    ``declare const DS0 := 36``{ Rimshot }
    ``declare const DS1 := 37``{ Rim Click }
    ``declare const DS2 := 38``{ SideStick }
    ``
    ``
    declare DTKey[NumSounds] := (DS0,DS1,DS2)
    ``declare TKey[NumSounds] := (DS0,DS1,DS2)
    ``
    ``
    declare EBoxID[NumSounds]``{ ids for value edits }
    ``declare LBtnID[NumSounds]``{ ids for Learn Btns }
    ``
    ``
    { Fixed caption labels, these can all be in the wallpaper instead }
    ``declare ui_label Header(1,1)
    ````set_text(Header,'Drum Sound Trigger Keys')
    ````move_control_px(Header,X,Y)
    ````Header->width := 155
    ````Header->hide := 1
    ````Header->font_type := 16
    ````Header->text_alignment := 2
    ``ds_caption(0,'Rimshot')
    ``ds_caption(1,'Rim Click')
    ``ds_caption(2,'Side Stick')
    ``
    ``
    key_learn(0)
    ``key_learn(1)
    ``key_learn(2)
    ``
    end on

    macro key_learn(#index#)
    ``declare ui_value_edit TK#index# (0,127,0)
    ````EBoxID[#index#] := get_ui_id(TK#index#)
    ````set_text(TK#index#,'')
    ````move_control_px(TK#index#,X+65,Y + dY*(#index#+1))
    ````TK#index#->width := 45
    ``declare ui_switch LB#index#
    ````LBtnID[#index#] := get_ui_id(LB#index#)
    ````set_text(LB#index#,'Learn')
    ````move_control_px(LB#index#,X+115,Y + dY*(#index#+1))
    ````LB#index#->width := 40
    end macro

    macro ds_caption(#index#,caption)
    ``declare ui_label CL#index#(1,1)
    ``set_text(CL#index#,caption)
    ``move_control_px(CL#index#,X,Y + dY*(#index#+1))
    ``CL#index#->hide := 1``{ transparent }
    ``CL#index#->font_type := 16
    ``CL#index#->text_alignment := 2 { right justified }
    ``CL#index#->width := 65
    end macro


    [​IMG]


    When you can successfully compile the above code, you will be ready for when I post the completed script. To get some additional practice, you might try editing the X,Y constants and move the sub-panel to a different position on the main panel.

    Rejoice,

    Bob

    BTW Re your last post, I don't have time right now to watch the video so let's address this after I get you KeyLearn Demo script finished.
     
  14. Mr.Lion

    Mr.Lion NI Product Owner

    Messages:
    159
    Hello Bob!

    Thank you very much so far!
    It looks beautiful, I've started to play around in the script, moving it around, change texts etc

    KScript Editor is really easy to work with when you get a little hang of it, definatly gonna start working on scripts here instead. So much easier to see what you do!

    Thanks again and Best Regards, looking forward to the next part of the script!
     
  15. Big Bob

    Big Bob Forum Member

    Messages:
    606
    Hey Robin, you mean you got that to compile already? Kudos:thumbsup:

    Looks like you are all prepared then for when I post the full script. I may have a little more time later today and if so, I'll try to finish this for you.

    BTW are you using V152 of the KSE or the Sublime Text 3 plugin? I think you will be glad I urged you to start using the KSE because it makes everything easier and more readable.

    To be continued ...

    Bob
     
  16. Mr.Lion

    Mr.Lion NI Product Owner

    Messages:
    159
    Yes, I spent last night doing a script for a instrument with a full SSLish EQ, Compression, Sustain, Saturation, Reverb, Delay. The whole package !

    Yes the latest version of KSE! I used Sublime 3 almost all other times or the Notepad ++ but KScript is so much better, also that you can see if the script works before I put it into the Script Editor in Kontakt.

    When I first laid my eyes on the KSE I never thought I would start working in it haha..

    Best Regards
     
  17. Big Bob

    Big Bob Forum Member

    Messages:
    606
    So, you are using V152 of the KSE (the scintilla editor) or are you using the latest Sublime Text plugin version of the KSE?

    BTW Robin, I forgot to tell you something. Please put together some kind of simple test instrument that will have the 3 drum sounds setup to respond on MIDI notes 36, 37, and 38 respectively. You will need something like this to test the completed script when I post it.

    Rejoice,

    Bob
     
  18. Mr.Lion

    Mr.Lion NI Product Owner

    Messages:
    159
    I use this (now) http://www.nilsliberg.se/ksp/ and THIS before, hope that answears your question!

    Yes Sir, it's dead n' done waiting for the final touch!

    Best Regards
     
  19. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    For me, Sublime Text 3 is much better (and also faster) than KSE. Fuzzy search for variables when autocompleting alone is worth it.
     
  20. Big Bob

    Big Bob Forum Member

    Messages:
    606
    Mario, I think we may be confusing Robin with the mixed terminology.

    When I use the acronymn KSE, I'm talking about Nils' KScript Editor which can be either the Scintilla-based version 152 or the Sublime Text 3 plugin version. We shouldn't create the impression that we recommend using Sublime Text without Nils' plugin.

    I think Robin is saying that he was using Sublime without Nils' plugin and is now using the Scintilla-based V152 which will be just fine for now.

    Robin, you can also use Sublime Text if you want but first, you must install Nils' plugin which then in my terminology makes it another version of the KSE. Without the plugin, you will not be able to compile my code in Sublime Text.

    Clear as Mud?

    Bob

    Hang on, I was just about to post the completed demo script for you but I wanted to try to clarify the KSE issue here first. The script is coming in the next post shortly.