fread

Parent Previous Next

fread

y = fread ( file_id,precision,additionalstr[=""] )
y = file_id.fread ( precision,additionalstr[=""] )

Read a binary file

arg

type

Description

Unit or Value scale

file_id

file_id

file identifier from fopen


precision

TXT

string of precision; see below


additionalstr

TXT

additional text "audio" "a" "audio2" or "a2"


Outputs

  • y is the data (non-audio). If an error occurs, y is null.

Notes

  • This function reads a binary file and returns the data read according to precision specified below.
  • precision is one of the following: "int8" "uint8" "int16" "uint16" "int32" "uint32" "int64" "uint64" "float" and "double"

Examples

  • Open the file generated in examples of fwrite, read as int16 into 1) a non-audio object and 2) an audio object:
  • fd=fopen("x.raw","rb")
    a=fd.fread("int16")
    fd.fclose
  • fd=fopen("x.raw","rb")
    b=fd.fread("int16","audio")
    fd.fclose
  • 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

fopen | fclose | fwrite

Created with the Personal Edition of HelpNDoc: Free EPub producer