[PD] standard encoding of pd files in each system?

Bryan Jurish jurish at uni-potsdam.de
Fri Jan 28 11:07:18 CET 2011

moin all,

fwiw, I'll add my vote in favor of getting Martin's [str] / blob patch
into pd vanilla.  iirc, Miller has indicated in the past that he feels
this sort of thing should be done using arrays.  There are a couple of
proof-of-concept objects (not compiled by default) in pdstring
(moocow/pdstring for pd-extended users) that use arrays, but I wasn't
satisfied with this approach for two reasons:

1) If you treat the array internally as a string of bytes (e.g. char*),
  (A) you must constantly cast and re-cast the data
  (B) you must scale all size attributes (e.g. for re-allocation) by
1.0/sizeof(t_float), so to get an accurate byte length that is not a
multiple of sizeof(t_float), you need to actually store that length
additionally somewhere else
  (C) saving array data with a patch and re-loading can cause data loss
(float truncation may mess up raw byte values)
  (D) it's not really portable (byte order problems with load/save)

2) If otoh you let the array remain a t_float* and just assign the
floats byte ((unsigned) char) or even wide character (wchar) values, then:
  (A) you potentially waste a lot of memory
(strlen(str)*(sizeof(float)-1) bytes)
  (B) I/O: if you read a string as a (char*) -- e.g. from a file,
socket, external library, etc. -- or if you need a pd-array-string as a
(char*) -- e.g. for an external API call -- then you have to explicitly
convert it, which means allocating some memory (maybe defining a static
local buffer to avoid malloc() calls), and iterating over the string
(rsp. over the array), which is O(N) time and space, and is annoying for
long strings and/or frequent calls
  (C) if you really want to store your string data in an array, you can
use [str] or [pdstring] together with e.g. [tabdump] and [tabset] from
zexy, which just makes the conversion overhead explicit.

I think there are workarounds for both techniques, but not without
patching the pd core code, and if we're going to patch the core code, we
might as well take a patch that does the job "right" (i.e. Martin's)...

just my €0.02 ...


On 2011-01-28 09:59:39, Roman Haefeli <reduzent at gmail.com> appears to
have written:
> On Wed, 2011-01-26 at 22:54 +0100, João Pais wrote:
>>> For converting, I like moocow/any2bytes and moocow/bytes2any.
>> I think I had a look at it as well. do you have any comparative reason for  
>> that one instead of the other? or it was just the first one to get to you?
> One important thing to know is that [mrpeach/str] only works with
> Pd-extended, but not with Pd-vanilla as it requires some modifications
> to m_pd.h.
> Btw.... @Martin: Do you think it's time again to to try to get the blob
> support into Pd-vanilla? I think that [str] would be utterly useful also
> in vanilla and it didn't seem to have caused any problem in Pd-extended,
> did it?
> Roman
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list


Bryan Jurish
Deutsches Textarchiv
Berlin-Brandenburgische Akademie der Wissenschaften

Jägerstr. 22/23
10117 Berlin

Tel.:      +49 (0)30 20370 539
E-Mail:    jurish at bbaw.de


More information about the Pd-list mailing list