Hi, I'm having an issue here trying to send floats as OSC messages from Pd to Processing.
Every time the float value reaches a whole number (1.0, 2.0, 3.0...) is gets rounded (1, 2, 3...) and it's typetag is set up as an integer.
The processing sketch is expecting floats and won't handle the int typetag. So I get a readout that skips a value... "0.7, 0.8, 0.9, 1.1, 1.2 , 1.3..."
Any ideas?
-
[oscSend] and floats/ints
-
@elcraydo Maybe this can help: force-float.pd
-
@elcraydo I see that the floats are still being converted after sending them via [netsend].
Maybe it is easier to use float() in Processing to cast the integers to floats.
-
Hey, I tried using float() but the problem is that the typetag is getting switched.
If I'm parsing for a message with "fff" and it turns into "iff", then I either need .get(0).floatValue() or .get(0).intValue() -
@elcraydo I have no knowledge about Processing and no means of testing it, but shouldn't it be possible to test for the type like this or similar:
float myvalue = 0; if(theOscMessage.checkAddrPattern("/echo")) { if(theOscMessage.checkTypetag("fff")) { myvalue = theOscMessage.get(0).floatValue(); } if(theOscMessage.checkTypetag("iff")) { myvalue = float(theOscMessage.get(0).intValue()); } } print(myvalue);
-
Absolutely yes. But I've a lot of incoming traffic and trying to avoid duplicating that much code.
At the moment, I'm just scaling the floats to integer ranges before I send them, as a workaround. -
@elcraydo Another solution could be to read the incoming values as a string and then convert them to floats maybe.
-
@elcraydo You should use [oscformat] and specify a float in the blob using the message [format f(
which must of course be specified before the blob is sent.
You must then use the -b switch for [netsend]
https://forum.pdpatchrepo.info/topic/11226/netsend/23Using the old [sendOSC] it might work if you send the message [typetags 0( into it, and specify the incoming float eg........ [float 1.2( ........ although that should not be necessary.
It could be that processing does not support typetags or there is some mismatch with [sendOSC]?
[packOSC] and [udpsend] from MrPeach used to work well.
David.