Hi All! This is my first script post.
I am running Kontakt 5 on a Surface Pro 3 with Win10. I made a multi script that has 12 instrument program buttons, 6 cc knobs, a modulation slider and a XY Pad for pitch bend. I want to use the Surface instead of external controllers so I can be keyboard independent, i.e., I can walk into any gig, plug into any keyboard, and control my sounds.
I can select programs in the instrument bank, and I can transmit CCS using the script knobs. I can transmit pitch bend but I cannot re-center the XY pad.
When I lift the left mouse button, I want to center the X axis of the pad (0.5 or 8192). All other cases I want to transmit pitch bend.
Here is my script:
on init
set_ui_height(6)
declare ui_xy ?myXY[2]
declare $xyID
$xyID := get_ui_id(?myXY)
set_control_par_str_arr($xyID, $CONTROL_PAR_AUTOMATION_NAME, ...
"Bend", 0)
set_control_par_str_arr($xyID, $CONTROL_PAR_AUTOMATION_NAME, ...
"Unused", 1)
set_control_par($xyID, $CONTROL_PAR_MOUSE_MODE, 0)
set_control_par($xyID, $CONTROL_PAR_MOUSE_BEHAVIOUR_X, 1000)
set_control_par($xyID, $CONTROL_PAR_MOUSE_BEHAVIOUR_Y, 10)
set_control_par($xyID, $CONTROL_PAR_POS_X, 50)
set_control_par($xyID, $CONTROL_PAR_POS_Y, 50)
set_control_par($xyID, $CONTROL_PAR_WIDTH, 200)
set_control_par($xyID, $CONTROL_PAR_HEIGHT, 50)
{move the cursors to the center of the XY pad}
?myXY[0] := 0.5 {1st cursor, X axis}
?myXY[1] := 0.5 {1st cursor, Y axis}
end on
on ui_control (?myXY)
if($NI_MOUSE_EVENT_TYPE = $NI_MOUSE_EVENT_TYPE_LEFT_BUTTON_UP)
?myXY[0] :=0.5 {set pitch bend to neutral}
set_midi(0,$MIDI_COMMAND_PITCH_BEND,lsb(real_to_int(16383.0 * ?myXY[0])),msb(real_to_int(16383.0 * ?myXY[0])))
else
set_midi(0,$MIDI_COMMAND_PITCH_BEND,lsb(real_to_int(16383.0 * ?myXY[0])),msb(real_to_int(16383.0 * ?myXY[0]))){transmit pitch bend}
end if
?myXY[1] := 0.5
message( real_to_int(16383.0 * ?myXY[0]) )
end on
I think my mistake is with the "if $NI_MOUSE..." statement.
Thank you for your help!
Sam in NJ USA