[PD] Read/write of raw binary data

David dfkettle at gmail.com
Wed Mar 9 00:32:14 CET 2011


Here they are. They prompt for the file name using [openpanel] and
[savepanel]. I'm not sure if that's what you really want. But it
shouldn't be difficult to modify them to pass a file name through an
inlet, or just hard-code the file name. They're built on top of Martin
Peach's [binfile], which is included in pd-extended. But if you're
using vanilla pd, you'll have to download Martin's code as well.

To use 'getfile', just send it a 'bang' and it will return a list of
floats containing the byte values in the file. To use 'putfile', just
send it a list of floats. It doesn't do any validation, so if the list
contains a non-integer or an integer that's outside the range of 0 to
255, you'll get one of the following errors, for example:

error: binfile: input (7.300000) not an integer
error: binfile: input (100020) out of range [0..255]

David.

On Tue, Mar 8, 2011 at 1:37 PM, Jamie Bullock <jamie at postlude.co.uk> wrote:
>
>
> On 8 Mar 2011, at 17:55, David <dfkettle at gmail.com> wrote:
>
>> Hi! I developed some abstractions for reading/writing binary files,
>> but they're somewhat limited in capability. They just load the data
>> into a list of floats (one per byte), or save a list of floats to a
>> file, and they read/write the entire file at once. They don't support
>> repositioning within the file, or writing/reading a portion of the
>> file. But if the files are relatively small, they might be suitable.
>>
>> I can send them to you later if you're interested, I'm at work right now.
>>
>
> Thanks, that would be great!
>
> Jamie
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getfile.pd
Type: text/x-puredata
Size: 638 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20110308/b85a8d7c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: putfile.pd
Type: text/x-puredata
Size: 490 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20110308/b85a8d7c/attachment-0001.bin>


More information about the Pd-list mailing list