Getting a float from a string (OSC/UDP)


    Nov 08 2011 | 3:41 pm
    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

    • Nov 08 2011 | 3:46 pm
      Oh yeah forgot to say im receiving it via [udpreceive]
    • Nov 08 2011 | 4:41 pm
      See patch below. Also includes simple explanation of difference between lists and symbols.
    • Nov 08 2011 | 5:39 pm
      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]
    • Nov 08 2011 | 6:12 pm
      You can select the relevant message using [route].
    • Nov 08 2011 | 7:41 pm
      works fine now
      THANKS!!!
    • Nov 11 2011 | 10:27 am
      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
    • Nov 11 2011 | 10:37 am
      Thank you I found an updated php script here which works: http://www.cycling74.com/forums/topic.php?id=34378
    • Nov 11 2011 | 11:55 am
      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
    • Nov 13 2011 | 11:53 am
      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.
    • Nov 13 2011 | 2:27 pm
      Happy to hear that it works for you!
      Thanks for the feedback,
      Ádám