[PD] sprintf and netsend for comma delimited UDP data

Martin Peach martin.peach at sympatico.ca
Tue Mar 10 23:55:55 CET 2009


florian mosleh wrote:
> Hello,
> 
>    I already posted this to the forum, so I hope it's no foible to post 
> it here as well...
> 
> I am building a connector for PD to communicate with an external 
> application running on another system. I am using netsend to craft UDP 
> packets that the remote application can parse for actions. The payload 
> is supposed to look sort of like this:
> (STRING,STRING,INTEGER,INTEGER,STRING,INTEGER)
> 
> Initially I was unable to get commas into the netsend stream because PD 
> uses commas as in internal delimiter. I was able to circumvent this by 
> using the cyclone external's 'sprintf' function. Like this:
> 
> |44|
> |
> |send  (STRING%cSTRING%cINTEGER%cINTEGER%cSTRING%cINTEGER) |
> |
> |netsend|
> 
> this almost works, except that pd inserts whitespace characters after 
> the commas, which the remote application doesn't understand.
> 
> I noticed that 'print' actually puts a space before and after the 
> commas, whereas netsend (or sprintf) only puts one after the commas.
> 
> Does anyone know how to circumvent this behavior? Or, perhaps a simpler 
> way to achieve what I am trying to do?
> 

If you're using pd-extended you could use [any2string] to convert to 
lists of (ASCII) floats and [udpsend] to send the list of floats. Also 
the [str] object might work as a way to convert symbols into lists of 
ASCII characters.


Martin





More information about the Pd-list mailing list