readheader.3

来自「speech signal process tools」· 3 代码 · 共 113 行

3
113
字号
.\" Copyright (c) 1987 Entropic Speech, Inc.; All rights reserved.\" @(#)readheader.3	1.7 5/1/98 ESI.TH READ_HEADER 3\-ESPSu 5/1/98.ds ]W "\fI\s+4\ze\h'0.05'e\s-4\v'-0.4m'\fP\(*p\v'0.4m'\ Entropic Speech, Inc..SH NAMEread_header \- read in an ESPS file header.SH SYNOPSIS.ft Bstruct header * .brread_header (fd).brFILE *fd;.ft.SH DESCRIPTION.I read_headerallocates memory for an ESPS file header, reads in the header from the stream \fIfp\fR and returns a pointer to it.     The file streampointer, \fIfd\fR, is left pointing to the first data record.   .PPIf thefile does not begin with an ESPS header, then \fIread_header\fR checksto see if the file begins with a Sphere header (as used on the NISTCD-ROM database).  If the file is a Sphere file, then the Sphere headeris processed and an ESPS FEA_SD header is created with the appropriatevalues filled in.   The function returns a pointer to this new ESPSheader.  ESPS Esignal files [1] are handled in the same way,as are files in certain RIFF WAVE (``PC .wav'') formats [2]:.I read_headerchecks for the presence of an Esignal or WAVE headerand, if it finds one, converts it as nearly as possible to anequivalent FEA header.(In the case of the WAVE format, only 16-bit PCM files are supported,though multi-channel files are allowed.)The constructed FEA header contains a special generic headeritem that enables the ESPS data input functions(such as.IR get_fea_rec (3\-ESPS)and.IR get_feasd_recs (3\-ESPS))to give special treatment to the data if necessary.In this way an ESPS program can read Sphere files or ESPSfiles, without any prior knowledge of the file type..PPIf the file does not begin with either an ESPS header or a Sphere,Esignal, or WAVE header,then the Unix environment variable \fBDEF_HEADER\fR is checked.If this variable is defined, it is assumed to be the filename of adefault ESPS header to apply to the file.   The header named by\fBDEF_HEADER\fR is processed and then is returned by \fIread_header\fRin the usual way.   The file stream pointer is left pointing to thefirst data record..PPAn ESPS header can be followed by a \fIforeign header\fR, which is anarbitrary block of data of known size between the ESPS header and thedata records.  This is usually a non-ESPS file header that was on a fileconverted to ESPS by \fIaddfeahd\fR(1\-\s-1ESPS\s+1) or \fIbtosps\fR(1\-\s-1ESPS\s+1) with the \fB-F\fRoption.If, after the ESPS header has been processed, it is found to contain thegeneric header items \fIforeign_hd_length\fR and \fIforeign_hd_ptr\fR,and \fIforeign_hd_length\fR is greater than zero, \fIread_header\fRwill read an additional \fIforeign_hd_length\fR bytes into a block ofnewly allocated memory.   The header item \fIforeign_hd_ptr\fR will beset to point to this block of memory containing the foreign header.(The generic item \fIforeign_hd_length\fR is a long, so it must be castto (char *) before use.)  As in the other cases, the file stream pointer\fIfd\fR will be left pointing to the first data record after theforeign header.   .PPNote that if a default header, picked up by the \fBDEF_HEADER\fRenvironment variable mechanism contains \fIforeign_hd_length\fR and itis greater than zero, then that many bytes will be skipped at thebeginning of the raw file and saved into the foreign header.    In thisway, one can have a default header for non-ESPS files and also specify aforeign header size for any ESPS programs.   Note that\fIforeign_hd_length\fR can be set with the program \fIaddgen\fR(1\-\s-1ESPS\s+1)..PP.I read_header returns NULL if an I/O error occurs, or if any of the above processingfails to yield a valid ESPS header.  .SH EXAMPLEin_fd = fopen (inputfile, "r");.brif ((in_hd = read_header (in_fd)) == NULL) \fIerror...\fR.brin_hd->common.type 	/* is equal to type of header */.SH DIAGNOSTICSThere are a number of error messages might be output to stderr if parts of the header are bad..SH BUGSNone known..SH REFERENCES.PP[1] ``The Esignal File Format'',Entropic Research Laboratory, Inc., 1995..br[2] ``Multimedia Programming Interface and Data Specifications 1.0'',IBM Corporation and Microsoft Corporation, 1991..SH SEE ALSO.IR new_header (3\-ESPSu),.IR write_header (3\-ESPSu), .br.IR copy_header (3\-ESPSu),.IR get_fea_rec (3\-ESPS),.br.IR get_feasd_recs (3\-ESPS)..SH AUTHOROriginal version by Joe Buck..brModified by Alan Parker for new header structures.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?