What's new

XY Pad with 2 cursors for 2 filters control [how to ?]

Linn134

New Member
Hi guys!
I'm back with a head scratching question today.
For a non commercial NKI I'm trying to control 2 bus filters : Filter A & Filter B (Bus 1 Filter, Bus 2 Filter) based on the shrinked example in KSP Ref Manual 6.

So I'm with my two cursors, that's perfect but I'm wondering how to write the callback functions.

Here is the WIP code :

on init {basic initialization} message("") make_perfview set_ui_color(9ddddddh) set_ui_height_px(350) {create an XY pad with 2 cursors} declare ui_xy ?myXY[4] {store the UI ID of the XY pad} declare $xyID $xyID := get_ui_id(?myXY) {skinning the cursors} set_control_par_str_arr($xyID, $CONTROL_PAR_CURSOR_PICTURE, ... "Picture1", 0) set_control_par_str_arr($xyID, $CONTROL_PAR_CURSOR_PICTURE, ... "Picture2", 2) {set automation IDs and names} set_control_par_arr($xyID, $CONTROL_PAR_AUTOMATION_ID, 0, 0) set_control_par_arr($xyID, $CONTROL_PAR_AUTOMATION_ID, 1, 1) set_control_par_arr($xyID, $CONTROL_PAR_AUTOMATION_ID, 2, 2) set_control_par_arr($xyID, $CONTROL_PAR_AUTOMATION_ID, 3, 3) set_control_par_str_arr($xyID, $CONTROL_PAR_AUTOMATION_NAME, ... "Cutoff A", 0) set_control_par_str_arr($xyID, $CONTROL_PAR_AUTOMATION_NAME, ... "Resonance A", 1) set_control_par_str_arr($xyID, $CONTROL_PAR_AUTOMATION_NAME, ... "Cutoff B", 2) set_control_par_str_arr($xyID, $CONTROL_PAR_AUTOMATION_NAME, ... "Resonance B", 3) {define the mouse behaviour} 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, 1000) {position and size} 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, 200) {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} ?myXY[2] := 0.5 {2nd cursor, X axis} ?myXY[3] := 0.5 {2nd cursor, Y axis} end on function XYCrossfade() set_engine_par($ENGINE_PAR_CUTOFF, $CONTROL_PAR_AUTOMATION_ID_0, -1, 0, $NI_BUS_OFFSET+0) set_engine_par($ENGINE_PAR_CUTOFF, $CONTROL_PAR_AUTOMATION_ID_1, -1, 0, $NI_BUS_OFFSET+0) set_engine_par($ENGINE_PAR_CUTOFF, $CONTROL_PAR_AUTOMATION_ID_2, -1, 0, $NI_BUS_OFFSET+1) set_engine_par($ENGINE_PAR_CUTOFF, $CONTROL_PAR_AUTOMATION_ID_3, -1, 0, $NI_BUS_OFFSET+1) end function

As you can see I'm trying to tell the event processor to use $CONTROL_PAR_AUTOMATION_ID (+number) to define the value of each function. I know it's a pretty basic thing but I can't find the way to do it reading KSP Ref3 or KSP Ref6.

Kontakt tell me
ERROR (line 53): variable "$CONTROL_PAR_AUTOMATION_ID_3" was not declared
So I assume it will be the same for the three others... But also it's not a good idea to use this as a variable...

Someone to explain me how to get this working ?
Thanks a lot.
 

EvilDragon

KSP Wizard
If you're trying to set the filter parameters, you need to use the cursor values, $CONTROL_PAR_AUTOMATION_ID_x doesn't exist. Instead of that, you use:

real_to_int(?myXY[0] * 1000000.0)

etc.
 
OP
Linn134

Linn134

New Member
Thread starter
  • Thread Starter
  • Thread Starter
  • #4
So, I'm still stuck with this. :unsure:

on init make_perfview declare const $UI_WIDTH := 632 declare const $UI_HEIGHT := 350 declare const $XY_WIDTH := 256 declare const $XY_HEIGHT := 256 set_ui_height_px($UI_HEIGHT) declare %vol_ep[1001] := { I've cut out the values to fit the letters limit of the forum but they are in the code } declare ui_knob $X (0, 1000, 1) declare ui_knob $Y (0, 1000, 1) set_control_par(get_ui_id($X), $CONTROL_PAR_POS_X, $UI_WIDTH / 2 - 96) set_control_par(get_ui_id($X), $CONTROL_PAR_POS_Y, ($UI_HEIGHT + $XY_HEIGHT) / 2 - 8) set_control_par(get_ui_id($Y), $CONTROL_PAR_POS_X, $UI_WIDTH / 2) set_control_par(get_ui_id($Y), $CONTROL_PAR_POS_Y, ($UI_HEIGHT + $XY_HEIGHT) / 2 - 8) set_control_par_str(get_ui_id($X), $CONTROL_PAR_AUTOMATION_NAME, "X Axis") set_control_par_str(get_ui_id($Y), $CONTROL_PAR_AUTOMATION_NAME, "Y Axis") set_knob_defval($X, 500) set_knob_defval($Y, 500) declare ui_xy ?myXY[2] make_persistent(?myXY) read_persistent_var(?myXY) $X := real_to_int(?myXY[0] * 1000.0) $Y := real_to_int(?myXY[1] * 1000.0) declare $xyID $xyID := get_ui_id(?myXY) set_control_par($xyID, $CONTROL_PAR_WIDTH, $XY_WIDTH) set_control_par($xyID, $CONTROL_PAR_HEIGHT, $XY_HEIGHT) set_control_par($xyID, $CONTROL_PAR_POS_X, ($UI_WIDTH - $XY_WIDTH) / 2) set_control_par($xyID, $CONTROL_PAR_POS_Y, ($UI_HEIGHT - $XY_HEIGHT) / 4) set_control_par_arr($xyID, $CONTROL_PAR_AUTOMATION_ID, 0, 0) set_control_par_arr($xyID, $CONTROL_PAR_AUTOMATION_ID, 1, 1) set_control_par_str_arr($xyID, $CONTROL_PAR_AUTOMATION_NAME, "Cutoff A-C", 0) set_control_par_str_arr($xyID, $CONTROL_PAR_AUTOMATION_NAME, "Res B-D", 1) declare $mode := 1 set_control_par($xyID, $CONTROL_PAR_MOUSE_MODE, $mode) end on function xyCallbackPad() set_engine_par($ENGINE_PAR_CUTOFF, real_to_int(?myXY[0] * 1000000.0), -1, 0, $NI_BUS_OFFSET + 0) { A } set_engine_par($ENGINE_PAR_RESONANCE, real_to_int(?myXY[1] * 1000000.0), -1, 0, $NI_BUS_OFFSET + 1) { B } set_engine_par($ENGINE_PAR_CUTOFF, real_to_int(?myXY[0] * 1000000.0), -1, 0, $NI_BUS_OFFSET + 0) { C } set_engine_par($ENGINE_PAR_RESONANCE, real_to_int(?myXY[1] * 1000000.0), -1, 0, $NI_BUS_OFFSET + 1) { D } end function on ui_control ($X) ?myXY[0] := int_to_real($X) / 1000.0 call xyCallbackPad() end on on ui_control ($Y) ?myXY[1] := int_to_real($Y) / 1000.0 call xyCallbackPad() end on on ui_control (?myXY) $X := real_to_int(?myXY[0] * 1000.0) $Y := real_to_int(?myXY[1] * 1000.0) call xyCallbackPad() end on


Not sure what "%vol_ep[1001]" has to do there hence it's not a volume (log) related function I'm trying to use.

And I don't understand when I need to use the real to integer thing.
It's in the function xyCallback and also on ui_control. Two times ?
 

EvilDragon

KSP Wizard
You need to use myXY indices 2 and 3 if you want to set the second filter parameters. Also your bus offsets probably need to be 0011 instead of 0101.

You don't need %vol_ep for this, true.
 
OP
Linn134

Linn134

New Member
Thread starter
  • Thread Starter
  • Thread Starter
  • #6
Thanks E.D

What do you mean with "0011 instead of 0101" ? Replacing "-1, 0, $NI_BUS_OFFSET + 0" with 0,0,1,1 ?
 

EvilDragon

KSP Wizard
You use NI_BUS_OFFSET 4 times, then adding 0, 1, 0, 1. So you're basically just setting the cutoff in bus 1 twice (but never resonance), and resonance in bus 2 twice (but never cutoff).
 
Top Bottom