Getting a float from a string (OSC/UDP)

Nov 8, 2011 at 3:41pm

Getting a float from a string (OSC/UDP)

Hi there,

I’m receiving a string message from Synapse (for Kinect) that says:
/head_pos_world 856.325661 -243.125124 1891.674467
Here are three float numbers in a string form, but i wish to put them in a flonum.
I tried [fromsymbol] but i dont think im using it the right way

Anyone knows how to do this?

grts

#59901
Nov 8, 2011 at 3:46pm

Oh yeah forgot to say im receiving it via [udpreceive]

#215654
Nov 8, 2011 at 4:41pm

See patch below. Also includes simple explanation of difference between lists and symbols.

– Pasted Max Patch, click to expand. –
#215655
Nov 8, 2011 at 5:39pm

this is working. partially though.

i think the problem is that there are two OSC messages coming in.
i dont know what the proper way is to use this, maybe someone can elaborate?

synapse always sends 1 message, when he is tracking a skeleton.

[attachment=175687,2857]

Attachments:
  1. maxwindow.PNG
#215656
Nov 8, 2011 at 6:12pm

You can select the relevant message using [route].

– Pasted Max Patch, click to expand. –
#215657
Nov 8, 2011 at 7:41pm

works fine now
THANKS!!!

#215658
Nov 11, 2011 at 10:27am

Just so I don’t have to start a new thread, I am also having trouble with UDP and an old ‘otudp php’ script to send udp messages to max with ‘udpreceive’. The messages arrive and I can read them in the Max window, but they are all error messages (below). They are essentially reiterations from the php _REQUEST variable $key >> $value messages (so 1=1; 2=4 etc) from an html form that is sent to a max patch.

Here is the php code:


$fp = fsockopen("udp://$ip", $port);

foreach( $_REQUEST as $index=>$value )
{
$NewString = "$index $value";
if ($index == "Submit" or $index == "LastVisit" or $index == "ip" or $index == "port"){
}else{
if ($value){

if ($Submit){
echo "$NewString
";
}
$stringcount = strlen($NewString);
$r = 4 - $stringcount % 4;

for($i = 0; $i < $r; $i++){
$NewString = "$NewString";
}

// sends string via udp
fwrite($fp, "$NewString");
}
}
}

Here are the error messages in Max. I will try to figure out what the syntax is for udpreceive but if I uncomment the "for($i = 0; $i < $r; $i++){$NewString = "$NewString";}" then I get "OSC packet size (3) is not a multiple of 4 bytes: dropping" error. I have tried to "fwrite($fp, strval("$NewString"));" to no avail.

udpreceive: OSC expected type string. Dropping message for address 1 1
udpreceive: OSC expected type string. Dropping message for address 10 1
udpreceive: OSC expected type string. Dropping message for address 11 1
udpreceive: OSC expected type string. Dropping message for address 12 1
udpreceive: OSC expected type string. Dropping message for address 13 1
udpreceive: OSC expected type string. Dropping message for address 14 1
udpreceive: OSC expected type string. Dropping message for address 2 1
udpreceive: OSC expected type string. Dropping message for address 3 1
udpreceive: OSC expected type string. Dropping message for address 4 1
udpreceive: OSC expected type string. Dropping message for address 5 1
udpreceive: OSC expected type string. Dropping message for address 6 1
udpreceive: OSC expected type string. Dropping message for address 7 1
udpreceive: OSC expected type string. Dropping message for address 8 1
udpreceive: OSC expected type string. Dropping message for address 9 1

#215659
Nov 11, 2011 at 10:37am

Thank you I found an updated php script here which works: http://www.cycling74.com/forums/topic.php?id=34378

#215660
Nov 11, 2011 at 11:55am

Hi, as a small ‘announcement’ I may also suggest you to try [sadam.udpReceiver] from my library, as this is the exact scenario for which it was originally built. You just need to replace [udpreceive] with it, the syntax is the same.

HTH,
Ádám

#215661
Nov 13, 2011 at 11:53am

Thanx Adam, I am now using your object with the original utudp php (www.galen.ca/research/streams.php) with minimal fuss. The php library by Andy Schmeder at (http://www.cycling74.com/forums/topic.php?id=34378) isn’t optimal and I haven’t taken the time to tinker with it for my purpose. For some reason my server is rejecting half the requests and i am not an admin.

#215662
Nov 13, 2011 at 2:27pm

Happy to hear that it works for you!

Thanks for the feedback,
Ádám

#215663

You must be logged in to reply to this topic.