fread
Read a binary file
Syntax
y = fread ( file_id,precision,additionalstr[=""] )
y = file_id.fread ( precision,additionalstr[=""] )
Inputs
| Argument | Type | Description | Unit |
|---|---|---|---|
file_id | file_id | file identifier from fopen | n/a |
precision | text | string of precision; see below | - |
additionalstr | text | additional text "audio" "a" "audio2" or "a2" | - |
Outputs / Return Value
y:yis the data (non-audio). If an error occurs,yis null.
Notes
- This function reads a binary file and returns the data read according to
precisionspecified below. precisionis one of the following: "int8" "uint8" "int16" "uint16" "int32" "uint32" "int64" "uint64" "float" and "double"
Examples
Open the file generated in examples of <a href="fwrite.html">fwrite</a>, read as int16 into 1) a non-audio object and 2) an audio object:
<p style="padding-left: 30px;">fd=fopen("x.raw","rb")
a=fd.fread("int16")
fd.fclose</p>
<p style="padding-left: 30px;">fd=fopen("x.raw","rb")
b=fd.fread("int16","audio")
fd.fclose</p>
a is a non-audio object with the range between -32768 and 32767; b is an audio object with the range between -1 and 1.
If the raw file represents a stereo audio data, "audio2" should be used as the second arg instead of "audio."
See Also
Review Status
- Legacy parameter naming does not exactly match current engine metadata and should be reviewed manually.