A newer version of Max is available. Click here to access the latest version of this document.

filein

Read in a file of binary data

Description

filein reads a file of binary data and outputs the data at various points in the file given the appropriate input.

Arguments

Name Type Opt Description
filename symbol opt Specifies a filename to be read into the filein object automatically when the patch is loaded. If the filename is followed by a second argument, spool, the file will be accessed from disk rather than read into memory.

Messages

int byte-offset [int]
Specifies a byte offset in a binary file, and outputs the data stored at that point in the file.

In left inlet: The byte contained at that offset in the file is sent out the left outlet.
  (inlet1) byte-offset [int]
In middle inlet: The 16-bit word contained at that byte offset in the file is sent out the left outlet as an unsigned (short) integer.
  (inlet2) byte-offset [int]
In right inlet: The 32-bit word contained at that byte offset within the file is sent out the left outlet as an unsigned (long) integer.
fclose Closes the file being read, making filein no longer respond to int or list messages.
spool filename [symbol]
Displays a standard file dialog to select a file, which will be accessed from disk whenever an int is received. If the word spool is followed by a filename found in Max's search path, that file will be automatically pointed to for future access. This method of accessing a file occupies less RAM, but does not output data immediately at interrupt level in response to an int message.
read filename [symbol]
Displays a standard file dialog to select a file to be read into memory. If the word read is followed by a filename found in Max's search path, that file will be automatically read into memory.

Information for box attributes common to all objects

Output

bang: Out middle outlet: When a number greater than or equal to the number of bytes in the file is received in an inlet, a bang is sent out signifying that the end of the file (EOF) has been reached.

Out right outlet: Signifies that a read or spool operation has been completed. This bang indicates that the file has been accessed successfully and that filein is ready to receive int messages.
int: Out left outlet: An unsigned integer representing the 8, 16, or 32 bits stored in the file at the location specified by the input int.

Examples

Output the content of a file in 8- 16- or 32-bit chunks

See Also

Name Description
text Format messages as a text file