KSP – set_engine_par $ENGINE_PAR_PAN の値の指定

備忘録。

128段階→1000000段階換算でなんかしっくりこない結果になったので
ググったてみたところ、$ENGINE_PAR_PAN は 5000 区切りっぽい (=200段階っぽい?)
MIDI CC(PAN)からの変換数式はたぶん
value = x * 200 / 127 * 5000
( x = pan(0-127) )

ACTUAL parameter value – engine parameter value will always be in range from 0 to 1000000, for EVERY knob accessible to KSP. If you want to display the actual value of a certain control in Kontakt (say, volume in dB), then you need to use get_engine_par_disp() – as you can see in my example above.
So, you need to do this:  

Code:
set_engine_par($ENGINE_PAR_PAN,<value from 0 to 1000000>,<group index>,-1,-1)

for each group you want (first group has a group index of 0). For example, if you want to put group 5 to 25L, then you would write:  

Code:
set_engine_par($ENGINE_PAR_PAN,375000,4,-1,-1)

because engine parameter value of 500000 is center. But not all engine parameters have linear distribution! Thankfully, panning is linear (one unit of panning is 5000 engine parameter units).