⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 files.doc

📁 speech signal process tools
💻 DOC
📖 第 1 页 / 共 4 页
字号:
       ETM-S-86-13:rap/jtb                                            page 14       other source files.  The (3-ESPS) functions that deal with  FEA  files       are:  allo_fea_rec,  add_fea_fld, fea_decode, fea_encode, get_fea_ptr,       get_fea_rec, print_fea_rec, and put_fea_rec.  For a detailed introduc-       tion to FEA files, see [5].       6 .2 .  Using eopen       Many ESPS programs go through a sequence  of  getting  a  command-line       file  name, checking to see if it is a "-" (for standard input or out-       put), opening the file, and checking to see that is an ESPS file  type       of  the  proper  type  (and  proper subtype for FEA files).  Here's an       example with a FEA_ANA file:           /*            * open the input file            */           if (optind < argc) {                  in fea = argv[optind++];                  if-(strcmp (in fea, "-") == 0)                      in fea = "-stdin>";                  else  -                      TRYOPEN (argv[0], in fea, "r", infea strm);                  }                       -               -           else {                  Fprintf(stderr, "no input file specified.\n");                  SYNTAX;               }           /*            * check for FEA ANA ESPS file            */             -           if ((fea ih = read header(infea strm)) == NULL)                  E-ROR EXIT(-couldn't rea- input FEA file header");           if(fea ih->c-mmon.type != FT FEA)                 -ERROR EXIT("Input fil- is not a FEA file");           if(fea ih->h-.fea->fea type != FEA ANA)                 -ERROR EXIT("Inp-t file is n-t FEA ANA type");           /*          -                           -            * allocate a record; input a record, and process            */           anafea rec = allo anafea rec(fea ih);           (void)-get anafea-rec(an-fea rec- fea ih, infea strm);           if (*(shor- *)get-genhd("spe- rep", f-a ih) != -C)               ERROR EXIT("F-A ANA file -oes not h-ve reflection coefficients");           rc0 = ana-ea rec->s-ec param[0];   /*get first reflection coefficient*/                       -         -       Often, code like the above can be simplified by using eopen,  as  fol-       lows:           if (optind < argc)               in fea = eopen(ProgName, argv[optind++], "r", FT FEA, FEA ANA, &fea ih, &infea strm);           else {-                                             -        -         -          -                   Fprintf(stderr, "no input file specified.\n");       Version 3.5                      ERL                           1/22/93       ETM-S-86-13:rap/jtb                                            page 15                   SYNTAX;           }           /* note that standard input is allowed, so we don't need to check in fea            *                                                                  -            * allocate a record; input a record, and process            */           anafea rec = allo anafea rec(fea ih);           (void)-get anafea-rec(an-fea rec- fea ih, infea strm);           if (*(shor- *)get-genhd("spe- rep", f-a ih) != -C)               ERROR EXIT("F-A ANA file -oes not h-ve reflection coefficients");           rc0 = ana-ea rec->s-ec param[0];   /*get first reflection coefficient*/                       -         -       6 .3 .  Reading Data Files with Generic Programs       Before FEA files were introduced, a different mechanism was  available       to  allow so-called "generic" (also called "dumb") programs to operate       on ESPS data files without knowing the details of the file format.  We       shall describe that mechanism here, but users should avoid using it as       it will be phased out in later releases.       An example of such a "dumb" generic program is stats  (1-ESPS).   This       program computes certain statistics on records in a data file, without       knowledge of the particular data structure.  Clearly, in order to sup-       port  this  class of programs sufficient information must be available       in the file header.  To provide that information, the common  part  of       the  header contains the number of doubles, floats, longs, shorts, and       characters that comprise a record within the file.  Moreover, the data       in  each record is stored in the order listed - i.e., the given number       of doubles followed by the given number of floats, etc.   These  items       are  set  automatically  by write_header when the ESPS file is created       (except in the case of SD files, where a call to set_sd_type  is  also       needed),  and  they can be used by generic programs to properly read a       record.  To simplify this further, the library  function  get_gen_recd       is  provided  to  read an arbitrary ESPS record into an vector of dou-       bles.  A short example of reading records from a data file in  a  non-       type specific manner is:           FILE *ifile;           struct header *ih;           double tag;           double dbuf[100];           .           .           .           ifile = fopen(in file,"r");           ih = read header-ifile);           if (get g-n recd(dubf, &tag, ih, ifile) == EOF) done();           a = dbu-[2]-                         /* access an element */       Programmers and  users  sometimes  need  to  know  the  correspondence       between this generic view of an ESPS record and the type-specific view       provided by the C structures such as this one for PIT files  (see  PIT       (5-ESPS)):       Version 3.5                      ERL                           1/22/93       ETM-S-86-13:rap/jtb                                            page 16           struct pitch {                  long tag;                     /*position in the reference file*/                  float pulse dist;             /*pulse to pulse distance*/                  float raw p-lse dist;         /*raw pulse distance*/           }               -     -       For example, a user of a generic statistics program might want to  get       statistics  on the pulse_dist component of pitch records, and to do so       must be able to state which element of the record  this  is  from  the       viewpoint  of  generic  programs.  This information is provided in the       section "RECORD ELEMENT FILE STRUCTURE" within  each  Section  5  ESPS       manual  page.   Thus,  for  example,  by reading SCBK (5-ESPS) you can       determine that the final_dist component of SCBK records is the element       number  1  from  the  generic viewpoint. In the case of FEA files, the       correspondence between the FEA-specific view and the generic  view  is       more  complicated  since a single such table will not suffice, and for       this reason an ESPS program is provided to translate between  the  two       views; see elemfea (1-ESPS).       7 .  The Preamble - Reading ESPS Files with non-ESPS Programs       Each ESPS header contains a fixed size structure  which  we  call  the       preamble.   The preamble contains information necessary for the opera-       tion of the read_header function and will not be described  in  detail       here.    However,  the preamble does contain information that allows a       non-ESPS program to skip over  an  ESPS  header  to  access  the  data       directly.   Note that this can also be achieved by the user level pro-       gram bhd.   The assumption here, is that the user needs to incorporate       into an existing non-ESPS program to ability to read an ESPS file.       From the view point of a non-ESPS program, the preamble is the first 8       long words (32 bytes) of the file.   The preamble is always written in       the Entropic EDR format (see reference [8]), so on a  machine  with  a       different  default  byte order the user program will have to byte swap       the data.  EDR format has the same byte order as Sun workstations,  so       if your machine's order if different, you will have to convert it.       This is the preamble:       struct preamble {          long         machine code;            /* machine which wrote file, see header.h */          long         check c-de;              /* version check code */          long         data -ffset;             /* data offset (in bytes, from 0) in file */          long         reco-d size;             /* record size in bytes */          long         check;-                  /* ESPS magic number, same as main header */          long         edr;                     /* YES if EDR ESPS, NO if native */          long         align pad size;          /* alignment -ad need for some SD files */          long         forei-n h-;              /* pointer to foreign header, -1 if */                              -                 /* there is none */       };       The third long word contains the offset from the beginning of the file       to  the  first  data  record  (in  bytes).    So to skip over the ESPS       Version 3.5                      ERL                           1/22/93       ETM-S-86-13:rap/jtb                                            page 17       header, simply seek to this location in  the  file.    The  next  long       word,  contains  the record size in bytes.   For a better detailing of       the   record   format   use   the   program   fea_element(1-ESPS)   or       gen_element(1-ESPS).       All a non-ESPS need do to read an ESPS file, is to declare this struc-       ture,  read  in  the first part of the file into it and then seek into       the file to the point indicated by data_offset.   If  the  machine  on       which  you  are reading this file has a different byte order from EDR,       the you will have to byte swap these fields after reading them.    The       field  edr  in  the preamble tells you whether you have to worry about       the data format of the data records, with respect to  byte  order  and       floating  point format.   If edr is 1, then the data is in EDR format.       This is the most common data format in  the  workstation  market.   If       your machine's data formats are different than that of a Sun, then you       will have to convert the data.   If the edr flag is 0, then  the  file       is  in the native format of the machine which wrote it.  You will have       to determine that machine type (look at machine_code) and convert from       that  format to that of the destination machine.   In most cases there       is nothing to do, but some cases can be  difficult.   It  is  possible       that  you can ensure that the ESPS file is written in the easiest for-       mat for you to deal with by your non-ESPS program.  See reference  [8]       for details on this.       If foreign_hd in the preamble is not -1,  then  the  file  contains  a       foreign header and this is a pointer to it.   Please note that this is       not the normal way for ESPS programs to  access  the  foreign  header.       That    would   be   via   the   generic   item   foreign_hd_ptr   and       foreign_hd_length.   The foreign header pointer  in  the  preamble  is       provided just for the case of non-ESPS program access.                                       (end)       Version 3.5                      ERL                           1/22/93

⌨️ 快捷键说明

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