Hi everyone,
I am trying to send audio data from JavaScript to SuperCollider via OSC. Since OSC does not support raw Blob types directly, we believe it must be sent as a Uint8Array
.
I tried converting the Blob
to a Uint8Array
before sending it via OSC, but SuperCollider is only receiving small Int8Array data. I suspect there is a limit on the amount of data that can be sent. Is this the correct format for sending binary data to SuperCollider over OSC? Do you know a better alternative?
There also seems to be a limitation on the number of messages. In this example, we can only send 152:
(
~totalChunks = nil;
~receivedChunks = Dictionary.new;
OSCdef(\test, { |msg|
var index = msg[1];
var chunk = msg[2];
if (index == -1) {
~totalChunks = chunk;
("Total expected chunks: " + ~totalChunks).postln;
} {
~receivedChunks[index] = chunk;
("Chunk received:" + index ++ ", Total received:" + ~receivedChunks.size).postln;
};
if (~totalChunks != nil and: (~receivedChunks.size == ~totalChunks)) {
"All chunks received!".postln;
}
}, '/test');
)
(
~sc = NetAddr("127.0.0.1", 57120);
~int8Array = Int8Array.fill(44100 * 8, { 127.rand2 });
~numChunks = (~int8Array.size / 1024).ceil;
~sc.sendMsg("/test", -1, ~numChunks);
~int8Array.clump(1024).do { |chunk, i|
~sc.sendMsg("/test", i, chunk);
};
)
I would appreciate any suggestions or experiences regarding sending audio data to SuperCollider. Thank you!