[PD] Fwd: Reading and writing binary files

David dfkettle at gmail.com
Sat Feb 26 19:43:01 CET 2011


Thanks for the suggestion. I'm not sure I can use this method, though,
because I have to be able to write it out as well. According to the
help documentation, the '-raw' flag only applies to reading files. Is
that correct?

Anyway, I tried it and I'm getting a usage error:

error: usage: read [flags] filename tablename...
flags: -skip <n> -nframes <n> -resize -maxsize <n> ...
-raw <headerbytes> <channels> <bytespersamp> <endian (b, l, or n)>.

Here's what my patch looks like. I'm not sure what I'm doing wrong.

[read -raw 0 1 8 n Default.syx array1(
|
[soundfiler]

There's no "header" in the file, it's just raw data for a Midi sysex
message, and I want to read each byte as an integer value in the range
of 0 to 255.

David.

On Fri, Feb 25, 2011 at 7:26 PM, Mike Moser-Booth <mmoserbooth at gmail.com> wrote:
> Try using the -raw flag for [soundfiler]. Setting the <bytespersample>
> parameter to 2 will treat it as a 16-bit file.
>
> .mmb
>
> On Fri, Feb 25, 2011 at 7:07 PM, David <dfkettle at gmail.com> wrote:
>> It's probably very obvious, but I can't figure out how to read and
>> write files containing arbitrary binary data. I know there are objects
>> for reading and writing sound files, and there's [textfile] for
>> reading text files, but I want to read and write binary files, and
>> interpret each byte as a 16-bit integer. Does anyone have an example I
>> can look at? Since they will be small files, I just need to read them
>> sequentially, I don't need to jump around in the file randomly.
>>
>> _______________________________________________
>> Pd-list at iem.at mailing list
>> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
>>
>
>
>
> --
> Mike Moser-Booth
> mmoserbooth at gmail.com
>



More information about the Pd-list mailing list