Sending multiple messages but in concise way
enzyme69 opened this issue · 2 comments
enzyme69 commented
Probably more like a basic Swift question, but anyhow maybe you have a good tips.
Supposedly there are thousands of vertices XYZ position (exactly that) and I need to send message via OSC.
var mymessage:[Float] = []
for data in dataY {
mymessage.append(data.x)
mymessage.append(data.y)
mymessage.append(data.z)
}
let message = OSCMessage( OSCAddressPattern("/hello/iPhoneX"),
mymessage[0],
mymessage[1],
mymessage[2],
mymessage[3],
mymessage[4],
mymessage[5],
.....
)
Would not there be a way to just to do this:
let message = OSCMessage( OSCAddressPattern("/hello/iPhoneX"),
{all the messages unpacked into float separated by space}
)
devinroth commented
You could always do this.
var message = OSCMessage( OSCAddressPattern("/hello/iPhoneX"))
for data in dataY {
message.add(data.x)
message.add(data.y)
message.add(data.z)
}
And since you made a valid point I added a new overload init for OSCMessage that accepts arrays. It's currently in the develop branch.
You can now do this.
let message = OSCMessage( OSCAddressPattern("/hello/iPhoneX"), mymessage)
enzyme69 commented
Thanks Devin!