Ah, my apologies. Your message did state multiXY pads. I admit, I haven't messed with these and hopefully someone else can chime in with, perhaps, a simpler solution than what I've come up with.
As far as I can tell, you can't grab which point
or event.handle
is being read from the onValue. Is this not possible @jean-emmanuel? However, you can see which handle is being read from the onTouch
using the following.
// this will console.log() the current handle index
if (event.type === "start") {
console.log(event.handle)
}
Nonetheless, you can do what your asking for without grabbing the handle. By storing the current point values in a locals.variable
, and checking if the value has changed. Here is an example using part of the code you used (feel free to change for your needs).
In the onCreate
property add 3 local variables, one for each point. Giving them a default value.
locals.storedXY1 = [0, 0]
locals.storedXY2 = [0, 0]
locals.storedXY3 = [0, 0]
In the onValue
property, you can use the following script to check if the values have changed from the storedXY
variables. In the if
statements, you can send whatever messages you like based on the changed values. I also included in comments a console.log(), which you can uncomment to see the values changing just for each point your handling.
let xy1 = [value[0], value[1]]
let xy2 = [value[2], value[3]]
let xy3 = [value[4], value[5]]
// Check if the arrays are not equal, if true, than sendMessage
if (JSON.stringify(locals.storedXY1) !== JSON.stringify(xy1)) {
// console.log(`xy1: ${xy1}`)
// sendMessages
send("midi:BMT", "/control", 1, 1, xy1[0])
send("midi:BMT", "/control", 1, 2, xy1[1])
// store the current values of the XY points
locals.storedXY1 = xy1
}
// Check if the arrays are not equal, if true, than sendMessage
if (JSON.stringify(locals.storedXY2) !== JSON.stringify(xy2)) {
// console.log(`xy2: ${xy2}`)
// sendMessages
send("midi:BMT", "/control", 2, 3, xy2[0])
send("midi:BMT", "/control", 2, 4, xy2[1])
// store the current values of the XY points
locals.storedXY2 = xy2
}
// Check if the arrays are not equal, if true, than sendMessage
if (JSON.stringify(locals.storedXY3) !== JSON.stringify(xy3)) {
// console.log(`xy3: ${xy3}`)
// sendMessages
send("midi:BMT", "/control", 3, 5, xy3[0])
send("midi:BMT", "/control", 3, 6, xy3[1])
// store the current values of the XY points
locals.storedXY3 = xy3
}
I definitely think what I've come up with is a solution, but, perhaps not the cleanest or most direct route as I'm not familiar with Multi XY-Pads.
I'd also really appreciate it if someone could also please help point me in a direction to learn how to program for Open Stage Control. I'd love to be able to help others in the community.
The documentation , this forum, and a large thread on VI-Control are the best spots for learning OSC specifically. Learning JavaScript, HTML, and CSS will also be very helpful when using OSC. Besides the aforementioned resources, if there are any templates or examples on this forum or elsewhere, dissecting someone else's creations and tampering with them I've always found very informative. I've also personally watched someone else's creation from a picture or video, and then sought to recreate it myself. Whether the recreation took days or weeks I've created huge leaps in learning OSC just recently doing just that. Personally, my biggest stride in learning and crafting OSC to my needs was first learning JavaScript.
Hope this helps!
Cheers,
DMDComposer