Bugfixes, send directly

main
Jurij Podgoršek 2024-10-21 19:53:47 +02:00
parent 3e91e9deb7
commit 79e00022ce
1 changed files with 29 additions and 12 deletions

View File

@ -78,6 +78,11 @@ SLIPDecoder {
// Function for decoding the properly-SLIP-decoded message. // Function for decoding the properly-SLIP-decoded message.
decode { |data| decode { |data|
^NetAddr.localAddr.sendRaw(data);
}
// Skip this, it reads floating points wrong!
decodeD { |data|
var header = data.at((0..7)); var header = data.at((0..7));
// Is it a bundle? (read header from first 8 bytes) // Is it a bundle? (read header from first 8 bytes)
@ -109,35 +114,47 @@ SLIPDecoder {
}); });
}, { }, {
// OSC message // OSC message
var nextString, index, address, type, args = []; var nextString, address, type, args = [];
// Message Address // Message Address
nextString = this.readNextString(data); nextString = this.readNextString(data);
address = nextString[0]; address = nextString[0];
//address.postln;
data = data[(nextString[1]..(data.size - 1))]; data = data[(nextString[1]..(data.size - 1))];
nextString = this.readNextString(data); nextString = this.readNextString(data);
//nextString.postln;
type = nextString[0]; type = nextString[0];
type = type.at((1..(type.size - 1)));
data = data[(nextString[1]..(data.size - 1))]; data = data[(nextString[1]..(data.size - 1))];
//data.postln;
type.do({ |t| // Skip , at the start of the type string
args = type.collect({ |t, i|
var start, end;
start = (i * 4);
end = start + 3;
//data[(start..end)].postln;
t.switch( t.switch(
$i, { $i, {
args = args.add(this.readInt32(data)); //"got int".postln;
data = data[(4..(data.size - 1))]; this.readInt32(data[(start..end)]);
}, },
$f, { $f, {
args = args.add(this.readFloat32(data)); //"got float".postln;
data = data[(4..(data.size - 1))]; this.readFloat32(data[(start..end)]);
}, }/*,
$s, { $s, {
nextString = this.readNextString(data);
args = args.add(nextString[0]);
data = data[(nextString[1]..(data.size - 1))]; data = data[(nextString[1]..(data.size - 1))];
nextString = ^this.readNextString(data);
} }
/* @TODO implement strings, bytearrays */ */
/* @TODO implement strings, bytearrays, other SC OSC types */
); );
}); });
args.postln;
(prepend ++ address).postln;
this.traceMsg("OSC", prepend ++ address, args); this.traceMsg("OSC", prepend ++ address, args);
// Send OSC message to the engine // Send OSC message to the engine
@ -213,7 +230,7 @@ SLIPDecoder {
stop { stop {
this.traceMsg("Stopping..."); this.traceMsg("Stopping...");
running = false; running = false;
port.close; if (port != nil, { port.close; });
port.free; port.free;
this.reader.free; this.reader.free;
} }