I’ve made an extension that communicates with TouchOSC. Sometimes (like when it resets the interface) it sends up to 2500 OSC messages at once. Over even a direct ethernet connection (but not when connected directly via USB), some of these UDP messages get dropped. I wrote the code below to queue the messages and slow them down:
sendMsgIfConnected {arg ... args;
if(isConnected,{
sendQueue.add(args);
},{
("DanDKVTouchOSC couldn't send message to "++args[0]).error;
});
if(queueClockHasQueue.not,{
queueClockHasQueue = true;
SystemClock.sched(0,{
if(sendQueue.size > 0,{
touchOSC.sendMsg(*sendQueue.first);
sendQueue.removeAt(0);
0.0001;
},{
queueClockHasQueue = false;
nil;
});
});
});
}
This works. My question is: is this a decent way to do this, or am I overlooking a more efficient / built-in way to slow down message emission? Alternatively, is there a way to send OSC messages via TCP from SC?