Sending Messages with multyxy

Hello,

I have been trying to figure out how to send messages with the multixy widget with no success.

I would really appreciate it if someone could help get me started so that I can send individual messages with each xy point.

Thank you for your time,
CJ

Hi,

XY pads use an array for the values. For example, [0,1] would be x value = 0, and y value = 1.

You could use the onValue property, to get the values, and use the send() method to send the individual messages. I'm not sure exactly what type of messages you are trying to send, but if you want to send some CC data on an XY pad, here is an example you could use in the onValue property.

let x = value[0]
let y = value[1]

// convert variables to CC Midi data by multiplying by a value of 127
// then round the number to a whole number
x = Math.round(x * 127)
y = Math.round(y * 127)

// send x value to channel 1, CC1
send("midi:YOURMIDIPORTNAMEHERE", "/control", 1, 1, x)

// send y value to channel 1, CC2
send("midi:YOURMIDIPORTNAMEHERE", "/control", 1, 2, y)

Cheers,
DMDComposer

Thank you @DMDComposer ,

Your script helped me to design a regular XY Pad to send /control messages! It works great controlling a filter that I have mapped :smiley:

I am now trying to figuring out how to adapt it to a multixy pad. I want to be able to send a different /control message for each xy point. Right now my multixy pad is set with three points and I would like for each of them to control different parameters.

Here is what I've got right now:

let x1 = value[0]
let y1 = value[1]
let x2 = value[2]
let y2 = value[3]
let x3 = value[4]
let y3 = value[5]

// send x value to channel 1, CC1
send("midi:BMT", "/control", 1, 1, x1)

// send y value to channel 1, CC2
send("midi:BMT", "/control", 1, 2, y1)
send("midi:BMT", "/control", 2, 3, x2)
send("midi:BMT", "/control", 2, 4, y2)
send("midi:BMT", "/control", 3, 5, x3)
send("midi:BMT", "/control", 3, 6, y3)

As you can probably tell, each point is now sending 3 sets of CC data on 3 separate channels :confused:

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.

With Gratitude,
CJ

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

Fantastic! Thank you @DMDComposer,

I'm able to send messages with the multixy pad for each individual point now.

Happy New Year,
CJ Barbot

1 Like