User defined pitch bend range


Hi Everyone,

I need some help figuring out how to have a user defined pitch bend range for the entire instrument.

I have a ui table where the user can draw a pitch bend graph.
The values can then be read with a slider which feeds the $ENGINE_PAR_TUNE.
This will allow to midi learn the slider and create cool pitch bend modulations.

I want to have a menu where the user can set the pitch bend range.
for example 12, 24,36

The kontakt default is 36

Any ideas how I can achieve this without having to create separate tables with different ranges?

I assume I can ratio the table data so that 1000000 = 24 st rather than 72 and feeds the $ENGINE_PAR_TUNE accordingly.
But I'm not sure about how to do the math :(

1000000 = 72 semitones or 36st each way from 0 (500000)

Maybe I'm complicating things and there's another way?

Thanks so much for your advice!

on init

    declare ui_table %pitch_table [127] (6,4,1000000)
    declare ui_slider $pitch_table_reader (0,126)

    declare ui_menu $range  
        add_menu_item ($range,"12",1)
        add_menu_item ($range,"24",2)
        add_menu_item ($range,"36",3)

end on

on ui_control ($pitch_table_reader)

    select ($range)
    case 1 {12}
          set_engine_par($ENGINE_PAR_TUNE,(%pitch_table [$pitch_table_reader])  {math here?},-1,-1,-1)
    case 2 {24}
          set_engine_par($ENGINE_PAR_TUNE,(%pitch_table [$pitch_table_reader])  {math here?},-1,-1,-1)

    case 3 {36}
          set_engine_par($ENGINE_PAR_TUNE,(%pitch_table [$pitch_table_reader])  {math here?},-1,-1,-1)
     end select

   message (%pitch_table[$pitch_table_reader]) 
end on


KSP Wizard
It would be much better, simpler, and more efficient to use change_tune() rather than changing group tune... Then you literally deal in microcents and adjusting the range is just simple multiplication.