XY Pad controlling volumes of 3 groups

LucidStorm
LucidStorm Member Posts: 4 Newcomer
edited April 2023 in Scripting Workshop

Hi, I was wondering if anyone has any suggestions for the problem I am having. I'm trying to set up an XY pad to control volume levels of 3 groups. I am very new to this, and scripting in general.

Basically at x0y0, it should only be Group 1. At x1y0 it should only be Group 2. And at x1y1 it should only be group 3. And volumes should interpolate between these points.

here is my code so far:

on ui_control(?XY)
  set_engine_par($ENGINE_PAR_VOLUME, real_to_int(sqrt(1.0 - ?XY[0]) * 600000.0), 0, -1, -1)
  set_engine_par($ENGINE_PAR_VOLUME, real_to_int(sqrt(?XY[0]) * 550000.0), 1, -1, -1)
  set_engine_par($ENGINE_PAR_VOLUME, real_to_int(sqrt(1.0 - ?XY[1]) * 600000.0), 0, -1, -1)
  set_engine_par($ENGINE_PAR_VOLUME, real_to_int(sqrt(?XY[1]) * 600000.0), 2, -1, -1)
end on

Right now it is behaving correctly along the y axis, but as I move along the x axis, group 2 increases in level but group 1 level remains consistent. I'm not sure what I'm doing wrong here. Maybe it doesn't know what to do with set_engine_par on both the x and y axis for the same group?

Any suggestions would be appreciated. Thanks!


EDIT: Figured it out. I had to also interpolate between the x and y positions on group 1. Here's the code:

on ui_control(?XY)
  set_engine_par($ENGINE_PAR_VOLUME, real_to_int(sqrt(1.0 - ?XY[0]) * sqrt(1.0 - ?XY[1]) * 600000.0), 0, -1, -1)
  set_engine_par($ENGINE_PAR_VOLUME, real_to_int(sqrt(?XY[0]) * 600000.0), 1, -1, -1)
  set_engine_par($ENGINE_PAR_VOLUME, real_to_int(sqrt(?XY[1]) * 600000.0), 2, -1, -1)
end on
Back To Top