How to make the "Tune" Knob move in semitones? And control it in high resolution

nowiamone
nowiamone Member Posts: 26 Member
edited October 22 in Scripting Workshop

I want to tell the Tune-Knob to move up/down differently. Not in 0.01 or 0.1 steps, but 1.0, which means in semitones. I m using Komplete Kontrol 2.7.2 to host Kontakt, because i m using the KK S MK2 Keyboard.

I ve found a script for the semitone movement, which works for MidiAssignments, like Midi cc11 - but it also brings some issues with it.

Source for the script: https://www.native-instruments.com/forum/threads/modulating-kontakts-master-tune-knob.360097/

The Script:

on controller

if ($CC_NUM = 11)

set_engine_par($ENGINE_PAR_TUNE,500000+(%CC[11]-64)*13888,-1,-1,-1)

end if

end on

I need help with at least 2 issues here, please help:

  1. It is nice to have "Tune" assigned to the Touch-Strip. But: how do i adjust the range of the tuning? I want to narrow it down to 25 Semitones, so that each tiny LED of the Touchstrip represents 1 semitone-movement, and the middle is 0. This would make hitting the right tuning much easier than how it works now, which is too much movement of semitones with just one touch. How do i achieve that? Sadly, i have no knowledge of scripting. And the only non-script option i found is the "From % to %" Values in the Kontakt Interfaces "Midi Automation" Tab, but this doesn't help! I really hate that the first 6 LEDS are -36 semitones, and the last 6 LEDS are +36 semitones! That limits the range of control drastically, and makes hitting the "0.0" really hard. If anything, i would like to control the midrange (between -12 and +12) in more detail, and the values below/above in less detailed resolution....
  2. my favorite Drum from Native Instruments Discovery Series - Middle East, the "Darbuka", has already all 5 Script-Slots used, and they seem to be non-editable. I can't insert the script there! What a pity! Could someone test that please, and tell me what to do?

Is there another way to make the Tune move in different steps (1 instead of 0.01) aside from the above script?

3. how would the script look, if instead of CC11 it shall adress the first Knob (#000 Host Automation-Parameter) of the Komplete Kontrol Keyboard? By the way, i can't even assign "Tune" to my KK-S49MK2 Keyboard-Knobs via "Automation-Host Automation" Assignment, because the Darbuka Drums have NON-REMOVEABLE Assignments for the first 45 Automation-Parameters! Would be nice if someone can check if that's the case on his/her system, too.

Comments

  • Jeremy_NI
    Jeremy_NI Customer Care Posts: 13,047 mod

    @EvilDragon Any idea on this one?

  • Reid115
    Reid115 Member Posts: 47 Member
    Answer ✓

    As for the first issue, just do some simple math. Convert the 128 value to a 25 value using real numbers and then cast it to an integer so it snaps to the semitones, like so:

    on controller
        if ($CC_NUM = 11)
            set_engine_par($ENGINE_PAR_TUNE, 500000 + real_to_int(25.0 * int_to_real(%CC[11] - 64) / 128.0) * 13889, -1, -1, -1)
        end if
    end on
    
  • soundtrax
    soundtrax Member Posts: 14 Member

    Questions 2 + 3: The Darbouka scripts are actually editable. You could use the last script slot (there's nothing important there) - click on the "Apply from..." menu and change it to 'Editor/Patch'. Then it is possible to paste your new code into it.

    It is also possible to change the host automation assignments - just open the "Main" script and copy the whole script into a text or code editor. Search for this line:

    "set_control_par(get_ui_id($pattern_sld),$CONTROL_PAR_AUTOMATION_ID,0)"

    Change the Automation ID number from 0 to 46 (or whatever).

    Now you can paste the edited code back into the nki ("Apply from..." must be set to Editor/Patch again)

  • stephen24
    stephen24 Member Posts: 418 Pro
    edited August 2022

    on controller

     if ($CC_NUM = 11)

     set_engine_par($ENGINE_PAR_TUNE,500000+(%CC[11]-64)/5*13888,-1,-1,-1)

     end if

    end on

    (best answer)

  • EvilDragon
    EvilDragon Moderator Posts: 1,031 mod
    edited August 2022

    This will work nicely, but there's actually no need to do real to int and vice versa conversions. This will work just as well: 500000 + ((25 * (%CC[$CC_NUM] - 64)) / 128) * 13889.


    Marking yours as best answer since it's using the input arguments (range = 25 semitones) directly and is more undestandable as a consequence. The only thing that is not explained is 13889, but that's a simple deduction of 500000 ep / 36 st = 13888.888...

  • rattala
    rattala Member Posts: 5 Member

    Hi everybody, how can I get the Tune master Knob at group level to be controlled by increment of an exact semitone for each step and for a range of 2 octaves (+1 and -1 OCT) without any CC11 parameter but just the tune knob itself?

    It seemed to be "trivial" if I use a custom Knob with built-in graphics because I think to be able to use:

    declare ui_knob $<variable-name> (<min>,<max>,<display-ratio>)

    but how can I get the same result witha knob with custom graphics that's in reality a slider control that has only min and max parameters if I'm not wrong ?

    thanks a lot for any help, sorry I'm a newbie with KSP :-(

  • rawl747
    rawl747 Member Posts: 2 Member

    I have a GUI with multiple layers all with individual tuning controls (sliders with knobs) which are declared with a range from 0 to 1000000. Each slider's on ui_control event script passes its value to a common variable and also passes the group ID to a common variable and then calls a function I created. The function determines which value to pass to the set_engine_par for the group's tuning control and then calls set_engine_par to set the value. Here is the function code, the rest is pretty obvious:

    function set_pitch

    {converts the value (from 0 to 1000000) of a slider to control tuning to semi-tones}

    {and sets the tuning value of the engine tuning control based on which group needs to have tuning set}

    {$Layer_TUNE is set to the slider value by the on ui_control of the tuning slider calling the function}

    {$sample_group_caller is set to the group number by the on ui_control of the tuning slider calling the function}

    {for each case the value in braces shows the equivalent semi-tone value from -36 to + 36}

    select ($Layer_TUNE)

    case 0 to 13888

    $tune := 0    {-36}

    case 13889 to 27777

    $tune := 13889  {-35} 

    case 27778 to 41666

    $tune := 27778  {-34}

    case 41667 to 55555

    $tune := 41667  {-33}

    case 55556 to 69443

    $tune := 55556  {-32}

    case 69444 to 83333

    $tune := 69444  {-31}

    case 83334 to 97222

    $tune := 83334  {-30}

    case 97223 to 111110

    $tune := 97223  {-29}

    case 111111 to 124999

    $tune := 111111 {-28}

    case 125000 to 138888

    $tune := 125000 {-27}

    case 138889 to 152777

    $tune := 138889 {-26}

    case 152778 to 166666

    $tune := 152778 {-25}

    case 166667 to 180555 

    $tune := 166667 {-24}

    case 180556 to 194443

    $tune := 180556 {-23}

    case 194444 to 208332

    $tune := 194444 {-22}

    case 208333 to 222221

    $tune := 208333 {-21}

    case 222222 to 236110

    $tune := 222222 {-20}

    case 236111 to 249999

    $tune := 236111 {-19}

    case 250000 to 263888

    $tune := 250000 {-18}

    case 263889 to 277777

    $tune := 263889 {-17}

    case 277778 to 291666

    $tune := 277778 {-16}

    case 291667 to 305555

    $tune := 291667 {-15}

    case 305556 to 319443

    $tune := 305556 {-14}

    case 319444 to 333332

    $tune := 319444 {-13}

    case 333333 to 347221

    $tune := 333333 {-12}

    case 347222 to 361110

    $tune := 347222 {-11}

    case 361111 to 374999

    $tune := 361111 {-10}

    case 375000 to 388888

    $tune := 375000 {-9}

    case 388889 to 402777

    $tune := 388889 {-8}

    case 402778 to 416666

    $tune := 402778 {-7}

    case 416667 to 430555

    $tune := 416667 {-6}

    case 430556 to 444443

    $tune := 430556 {-5}

    case 444444 to 458332

    $tune := 444444 {-4}

    case 458333 to 472221

    $tune := 458333 {-3}

    case 472222 to 486109

    $tune := 472222 {-2}

    case 486110 to 499999 

    $tune := 486110 {-1}

    case 500000 to 513888 

    $tune := 500000 {0}

    case 513889 to 527777

      $tune := 513889 {1}

    case 527778 to 541666

      $tune := 527778 {2}

    case 541667 to 555555

      $tune := 541667 {3}

    case 555556 to 569443

      $tune := 555556 {4}

    case 569444 to 583332

      $tune := 569444 {5}

    case 583333 to 597221

      $tune := 583333 {6}

    case 597222 to 611110

      $tune := 597222 {7}

    case 611111 to 624999

      $tune := 611111 {8}

    case 625000 to 638888

      $tune := 625000 {9}

    case 638889 to 652777

      $tune := 638889 {10}

    case 652778 to 666666

      $tune := 652778 {11}

    case 666667 to 680555

      $tune := 666667 {12}

    case 680556 to 694443

      $tune := 680556 {13}

    case 694444 to 708332

      $tune := 694444 {14}

    case 708333 to 722221

      $tune := 708333 {15}

    case 722222 to 736110

      $tune := 722222 {16}

    case 736111 to 749999

      $tune := 736111 {17}

    case 750000 to 763888

      $tune := 750000 {18}

    case 763889 to 777777

      $tune := 763889 {19}

    case 777778 to 791666

      $tune := 777778 {20}

    case 791667 to 805555

      $tune := 791667 {21}

    case 805556 to 819443

      $tune := 805556 {22}

    case 819444 to 833332

      $tune := 819444 {23}

    case 833333 to 847221

      $tune := 833333 {24}

    case 847222 to 861110

      $tune := 847222 {25}

    case 861111 to 874999

      $tune := 861111 {26}

    case 875000 to 888888

      $tune := 875000 {27}

    case 888889 to 902777

      $tune := 888889 {28}

    case 902778 to 916666

      $tune := 902778 {29}

    case 916667 to 930555

      $tune := 916667 {30}

    case 930556 to 944443

      $tune := 930556 {31}

    case 944444 to 958332

      $tune := 944444 {32}

    case 958333 to 972221

      $tune := 958333 {33}

    case 972222 to 986110

      $tune := 972222 {34}

    case 986111 to 999999

      $tune := 986111 {35}

    case 1000000 

      $tune := 1000000 {36}

    end select 

  • Milos
    Milos Member Posts: 2,018 Guru
    edited December 2023

    Insightful!

  • rawl747
    rawl747 Member Posts: 2 Member

    Thanks Milos.

  • Milos
    Milos Member Posts: 2,018 Guru

    No problem!

This discussion has been closed.
Back To Top