Hello @dom,
ChatGPT SuperCollider code I used:
(
// Setup OSC target and vars
~target = NetAddr("127.0.0.1", 12000); // Your Processing port
~index = 0;
~toggle = 0;
~sendRandomData = {
var x = rrand(0.0, 1.0);
var y = rrand(0.0, 1.0);
~target.sendMsg("/data", x, y, ~index, ~toggle);
("Sent: x=%, y=%, index=%, toggle=% at %").format(x, y, ~index, ~toggle, thisThread.clock.seconds).postln;
~index = ~index + 1;
~toggle = 1 - ~toggle;
};
// Define a fresh sender task but DO NOT start it yet
~sender = Task({
loop {
~sendRandomData.();
2.0.wait;
}
});
)
I used the oscP5broadcastClient example to receive the data.
You should be able to receive the data and populate different arrays according to the msg number (toggle in this case).
ChatGPT Processing oscEvent() used with minimal example:
void oscEvent(OscMessage msg) {
if (msg.checkAddrPattern("/data")) {
if (msg.checkTypetag("ffii")) { // expecting 2 floats, 2 ints
float x = msg.get(0).floatValue();
float y = msg.get(1).floatValue();
int index = msg.get(2).intValue();
int toggle = msg.get(3).intValue();
println("Received: x=" + x + ", y=" + y + ", index=" + index + ", toggle=" + toggle);
} else {
println("Unexpected typetag: " + msg.typetag());
}
}
}
You can process each one as it is received; I just added the toggle as an example of two different data sets.
I have very little knowledge of either of OSC so this was just a quick exploration.
Cool beans! I may use this in future!
:)