What's new

XY Pad Problem

Kore G

Member
Hello guys!
I have a 4 layer library and i want to control the volume
with an XY pad. Here is the code:

Code:
on init
make_perfview
declare ui_xy ?xy[2]
make_persistent(?xy)

end on

on ui_control (?xy)
set_engine_par($ENGINE_PAR_VOLUME,real_to_int(?xy[1] * 1000000.0),0,-1,-1)
set_engine_par($ENGINE_PAR_VOLUME,real_to_int(?xy[0] * 1000000.0),1,-1,-1)
set_engine_par($ENGINE_PAR_VOLUME,real_to_int(?xy[1] * 1000000.0),2,-1,-1)
set_engine_par($ENGINE_PAR_VOLUME,real_to_int(?xy[0] * 1000000.0),3,-1,-1)

end on

I want the volume to be at maximum when the cursor go to each corner
and the others at minimum.

This code not work for me.

I try this one but it saws me 2 cursors instead...

Code:
on init
make_perfview
declare ui_xy ?xy[4]
make_persistent(?xy)
end on

on ui_control (?xy)
set_engine_par($ENGINE_PAR_VOLUME,real_to_int(?xy[0] * 1000000.0),0,-1,-1)
set_engine_par($ENGINE_PAR_VOLUME,real_to_int(?xy[1] * 1000000.0),1,-1,-1)
set_engine_par($ENGINE_PAR_VOLUME,real_to_int(?xy[2] * 1000000.0),2,-1,-1)
set_engine_par($ENGINE_PAR_VOLUME,real_to_int(?xy[3] * 1000000.0),3,-1,-1)
end on
 
You only need one cursor, so the first declaration is ok.
But XY pad values go from 0 to 1, so you need to change your math to something like this:
a := real_to_int((?xy[0] - 0.5) * 2000000.0)
b := real_to_int((1.0 - (?xy[0] - 0.5)) * 2000000.0)
c := real_to_int((?xy[1] - 0.5) * 2000000.0)
d := real_to_int((1.0 - (?xy[1] - 0.5)) * 2000000.0)

This formulas will return negative values. You may need to change that.
 
Last edited:
Whoa, I may be a noob to VI composing but I’m a software developer for the past 20 years and didn’t know Kontakt had an SDK! Is it built in like VBA is in Office, or something I need to download separately?
 
This formulas will return negative values. You may need to change that.

Negative values won't work with set_engine_par(), rethink the approach :)


OP, do you want to have a vector crossfade like on Korg Wavestation or Prophet VS, where the joystick (in this case XY pad) crossfades between all 4 soundsources, or do you want to have individual mixing for each?


In case you need a vector mix, what you need to use is bilinear interpolation.

Is it built in like VBA is in Office

It's built in. Check out the manual :)
 
You only need one cursor, so the first declaration is ok.
But XY pad values go from 0 to 1, so you need to change your math to something like this:
a := real_to_int((?xy[0] - 0.5) * 2000000.0)
b := real_to_int((1.0 - (?xy[0] - 0.5)) * 2000000.0)
c := real_to_int((?xy[1] - 0.5) * 2000000.0)
d := real_to_int((1.0 - (?xy[1] - 0.5)) * 2000000.0)

This formulas will return negative values. You may need to change that.

Thanks a lot angeruroth!
I test it, this one doesn't work!
Mario is right negative values doesn't work.
 
Negative values won't work with set_engine_par(), rethink the approach :)


OP, do you want to have a vector crossfade like on Korg Wavestation or Prophet VS, where the joystick (in this case XY pad) crossfades between all 4 soundsources, or do you want to have individual mixing for each?


In case you need a vector mix, what you need to use is bilinear interpolation.



It's built in. Check out the manual :)

I think individual mixing for each is what i need.
I search on the manual and i didn't find anything about callback in ui_xy...
 
Negative values won't work with set_engine_par(), rethink the approach :)
Yes, but you only need to set the limit ;)

This code if you want silence when the pointer in centered:
Code:
$a := real_to_int((?xy[0] - 0.5) * 2000000.0)
if($a < 0)
    $a := 0
end if
$b := real_to_int((1.0 - (?xy[0] - 0.5)) * 2000000.0)
if($b < 0)
    $b := 0
end if
$c := real_to_int((?xy[1] - 0.5) * 2000000.0)
if($c < 0)
    $c := 0
end if
$d := real_to_int((1.0 - (?xy[1] - 0.5)) * 2000000.0)
if($d < 0)
    $d := 0
end if

This easier code if you need a linear-crossfade with no silence:
Code:
$a := real_to_int(?xy[0] * 2000000.0)
$b := real_to_int((1.0 - ?xy[0]) * 2000000.0)
$c := real_to_int(?xy[1] * 2000000.0)
$d := real_to_int((1.0 - ?xy[1]) * 2000000.0)

Of course you can go math hard :)
 
Yes, but you only need to set the limit ;)

This code if you want silence when the pointer in centered:
Code:
$a := real_to_int((?xy[0] - 0.5) * 2000000.0)
if($a < 0)
    $a := 0
end if
$b := real_to_int((1.0 - (?xy[0] - 0.5)) * 2000000.0)
if($b < 0)
    $b := 0
end if
$c := real_to_int((?xy[1] - 0.5) * 2000000.0)
if($c < 0)
    $c := 0
end if
$d := real_to_int((1.0 - (?xy[1] - 0.5)) * 2000000.0)
if($d < 0)
    $d := 0
end if

This easier code if you need a linear-crossfade with no silence:
Code:
$a := real_to_int(?xy[0] * 2000000.0)
$b := real_to_int((1.0 - ?xy[0]) * 2000000.0)
$c := real_to_int(?xy[1] * 2000000.0)
$d := real_to_int((1.0 - ?xy[1]) * 2000000.0)

Of course you can go math hard :)

Thanks a lot Mario the linear-crossfade with no silence
is what i need!
 
Of course that's not a linear crossfade because the scaling of $ENGINE_PAR_VOLUME is not linear at all :)
Hmm, I'm almost brain dead right now (too much heat in my region) but that's interesting. Could you please elaborate on how the scaling works?
 
Hi,
it is possible to have 4 layers that are at 100% volume on each XY PAD corner, at 25% in the center and at "0" on all other 3 corners. We have done it in a library we are developing it, but unfortunately I can't share it at the moment since it's a script for a new product (Sorry).
I just thought i'd mentioned that there is a way (or more than one) as i think this is what KORE G might be asking for.
Roby
In the video below the XY Pad controls the 4 busses volumes.
 
Hello everyone,
I'm bumping this because recently I've been trying to achieve what this topic originally asked (which I have already been able to do with an xy pad), except I'd like to do this with a single knob.
Meaning, for example, the knob defaulting all the way to the left would mean only group 1's volume is up, then as you move the knob to the right then it crossfades into group 2, and then group 2 crossfades into group 3 (with group 1 no longer being heard) and then group 3 into group 4 etc.
I'm a newbie so any thoughts on how to approach this will be greatly appreciated.
Thanks.
Gus
 
Tried a few different things but still stuck. One thing is noticed is that I cannot set the value for the [0] slot of the xy array, is this a restriction of ksp?
With something like this: ?xy[0]:= $controller1
In other words, I'm trying to control the xy pad with 2 knobs.
 
Thanks @EvilDragon , that worked :)
My main goal with the XY though, I have not been able to accomplish yet. But since it is not really the same issue as this thread, I'll create a separate one later to see if I can get some suggestions. Thanks again.
 
Negative values won't work with set_engine_par(), rethink the approach :)


OP, do you want to have a vector crossfade like on Korg Wavestation or Prophet VS, where the joystick (in this case XY pad) crossfades between all 4 soundsources, or do you want to have individual mixing for each?


In case you need a vector mix, what you need to use is bilinear interpolation.



It's built in. Check out the manual :)
For a vector/bilinear interpolation:

Code:
{
$layer_1_vol:= real_to_int((?xy_pad[1] - (?xy_pad[0] * ?xy_pad[1])) * 2000000.0)
$layer_2_vol:= real_to_int((?xy_pad[0] * ?xy_pad[1]) * 2000000.0)
$layer_3_vol:= real_to_int((1.0 - ?xy_pad[1] - ?xy_pad[0] + (?xy_pad[0] * ?xy_pad[1])) *2000000.0)
$layer_4_vol:= real_to_int((?xy_pad[0] - (?xy_pad[0] * ?xy_pad[1])) * 2000000.0)
}
 

Attachments

  • Cursor Test VI sliders Mario.nki.zip
    2.7 KB · Views: 7
For a vector/bilinear interpolation:

Code:
{
$layer_1_vol:= real_to_int((?xy_pad[1] - (?xy_pad[0] * ?xy_pad[1])) * 2000000.0)
$layer_2_vol:= real_to_int((?xy_pad[0] * ?xy_pad[1]) * 2000000.0)
$layer_3_vol:= real_to_int((1.0 - ?xy_pad[1] - ?xy_pad[0] + (?xy_pad[0] * ?xy_pad[1])) *2000000.0)
$layer_4_vol:= real_to_int((?xy_pad[0] - (?xy_pad[0] * ?xy_pad[1])) * 2000000.0)
}


I'm currently utilizing this code that functions effectively. However, I've encountered an issue regarding volume control. The problem arises when the cursor reaches the edge of the corner. At this point, the volume of the layer increases to approximately +12db. Conversely, when the cursor is positioned in the center, all layers decrease to around -23db and the overall volume is very low even if all 4 layers are playing at the same time..

My inquiry is: is it feasible to achieve higher volume levels when the cursor is in the center like all layers at around -5db, and lower levels when it's positioned in the corner, like around 0db?

Thank you for your help!

This is the code I'm using:

Code:
on init
make_perfview

set_ui_height_px(350)
declare ui_xy ?xy[2]
make_persistent(?xy)

declare $xyID
$xyID := get_ui_id(?xy)

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)


declare ui_slider $layer_1_vol (0, 1000000)
declare ui_slider $layer_2_vol (0, 1000000)
declare ui_slider $layer_3_vol (0, 1000000)
declare ui_slider $layer_4_vol (0, 1000000)
make_persistent($layer_1_vol)
make_persistent($layer_2_vol)
make_persistent($layer_3_vol)
make_persistent($layer_4_vol)


end on

on ui_control ($layer_1_vol)
set_engine_par($ENGINE_PAR_VOLUME, $layer_1_vol, 0,-1,-1)   
end on
on ui_control ($layer_2_vol)
set_engine_par($ENGINE_PAR_VOLUME, $layer_2_vol, 1,-1,-1)   
end on
on ui_control ($layer_3_vol)
set_engine_par($ENGINE_PAR_VOLUME, $layer_3_vol, 2,-1,-1)   
end on
on ui_control ($layer_4_vol)
set_engine_par($ENGINE_PAR_VOLUME, $layer_4_vol, 3,-1,-1)   
end on



on ui_control (?xy)


$layer_1_vol:= real_to_int((?xy[1] - (?xy[0] * ?xy[1])) * 1000000.0)
$layer_2_vol:= real_to_int((?xy[0] * ?xy[1]) * 1000000.0)
$layer_3_vol:= real_to_int((1.0 - ?xy[1] - ?xy[0] + (?xy[0] * ?xy[1])) * 1000000.0)
$layer_4_vol:= real_to_int((?xy[0] - (?xy[0] * ?xy[1])) * 1000000.0)

set_engine_par($ENGINE_PAR_VOLUME, $layer_1_vol, 0,-1,-1)   
set_engine_par($ENGINE_PAR_VOLUME, $layer_2_vol, 1,-1,-1)   
set_engine_par($ENGINE_PAR_VOLUME, $layer_3_vol, 2,-1,-1)   
set_engine_par($ENGINE_PAR_VOLUME, $layer_4_vol, 3,-1,-1)   


end on
 
Top Bottom