Menu Entry based changes in note and velocity value for specific key ranges

Options
MRTBLN
MRTBLN Member Posts: 3 Newcomer
edited April 2023 in Scripting Workshop

Hi! I am a beginner in kontakt scripting and hope somebody can help me with my problem.

Based on a menu entry I would like to play with the keys of the octave 24-35 the notes of octave 12-23 and only one velocity layer chosen by a menu entry value.

I achieved the note and velocity changes with the following code. But when I play the notes it always has clicking noises caused by the while loop. But why and how can I fix it? Is there a better way to do this? How can I change the values for only a certain key range?

In the end I would like to have multiple menus for different octaves all sharing the same menu entries and playing the samples from octave 12-23. I have everything ready but this is a major problem and I cant find a solution. PLEASE HELP :)

on init

   declare %menu_a[12] := (24,25,26,27,28,29,30,31,32,33,34,35)
   declare %samples[12] := (12,13,14,15,16,17,18,19,20,21,22,23)

   declare ui_menu $menu_a
 	 add_menu_item($menu_a,"Empty",-1)
	 add_menu_item($menu_a,"1",1)
	 add_menu_item($menu_a,"2",2)
end on

on note

  if (search(%menu_a,$EVENT_NOTE) # -1)
	change_note($EVENT_ID,$EVENT_NOTE-12)
  end if

  if ($menu_a=1)
    while (search(%samples,$EVENT_NOTE) # -1)
	change_velo($EVENT_ID,1)
    end while
  end if
end on

Comments

  • medusa
    medusa Member Posts: 86 Helper
    Options

    Not sure if this is relevant, but change_velo requires an ID, not a NOTE

  • MRTBLN
    MRTBLN Member Posts: 3 Newcomer
    Options

    True that is a leftover from a try I did :) Thx

  • medusa
    medusa Member Posts: 86 Helper
    Options

    How about this?

    on init
      declare ui_menu $menu_a
       add_menu_item($menu_a,"Empty", -1)
       add_menu_item($menu_a,"1",1)
       add_menu_item($menu_a,"2",2)
    end on
    
    on note
    if ($EVENT_NOTE >= 24 and $EVENT_NOTE <= 35 and $menu_a # -1)
       change_note($EVENT_ID, $EVENT_NOTE-12)
       change_velo($EVENT_ID, $menu_A)
    end if
    end on
    


  • MRTBLN
    MRTBLN Member Posts: 3 Newcomer
    Options

    Awesome! That will work for my case. Thank you for your fast reply and solution!

Back To Top