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

📄 param.vtme

📁 speech signal process tools
💻 VTME
📖 第 1 页 / 共 2 页
字号:
internal symbol table from which parameter values can be retrieved.  .i Read_paramshas various parameters to specify the name of the parameter file, tocontrol whether or not ESPS common is processed, and to control whetheror not rule (4) (Section 2.1) is to be enforced.  For example, thecall.vS .nf    /*sd_file is the name of an input SD file*/    read_params("params", SC_CHECK_FILE, sd_file);.fi.vEspecifies that the parameter file is "params" (the ESPS defaultconvention), and that the ESPS common file is to be processed provided that its "filename" entry matches the contents of the variable"sd_file".   Similarly, .vS .nf    read_params("params", SC_CHECK_FILE, NULL);.fi.vEprocesses the parameter file and the common file without regard to any "filename" entry in the common file.  .lp.i Read_paramsdetects following types of errors:  .(lneither parameter nor common file can be opened (returns -1)File contains syntax errorsSymbols multiply definedType conflicts.)lIf the parameter and possibly the common file are opened successfully,.i read_paramsattempts to process them entirely even if errors are encountered,printing appropriate messages on the standard error output.  Each syntaxerror message indicates the line of the parameter file where itoccurred.  However, a program exit will occur after processing iscomplete if any errors were present in the file.  The routine eitherreturns successfully, in which case a symbol table is built, or theprogram exits.  .sh 2 "Reading Parameter Values".lpOnce the internal symbol table has been built by calling .i read_params,programs can retrieve the values of specific symbols by calling the various "getsym" library routines noted in the following table:.nf.TSbox,center;c sc | cl | li.Reading Parameter Values_Type of Symbol	Program to Call_int	getsym_idouble	getsym_dchar	getsym_cstring	getsym_sint array	getsym_iadouble array	getsym_da.TE.fi.lpAs described earlier, if the parameter file indicates that the symbol isindefinite, the user is prompted for a value.  The default value is usedif the user types a RETURN in response to the prompt.  .lpIf, for any of the routines described above, the requested symbol isundefined or has the wrong type, an error message is printed on thestandard error output and a zero or null value is returned.  The symboltable module keeps track of errors; the routine .i symerr_exit(3\-\s-1ESPS\s+1), which takes no arguments and returns no value, causesthe program to exit if any of the getsym routines caused an error.  Thereason for doing things this way is to detect as many errors as possiblein one run (having the getsym routines cause the programs to bomb onerrors may mean the user has to repeatedly edit a parameter file,discovering only one error at a time).  .lpThree types of errors can occur in the getsym routines:  undefinedsymbol, type mismatch, or overflow (number of values given exceedsmaxval).  For all these errors, an error message is printed when the error is detected and calling.i symerr_exit will cause program exit.  .lpAnother useful library routine is.i symtype(3\-\s-1ESPS\s+1), which returns the type of a given symbol.  Inparticular, it returns one of the integer symbolic constants ST_INTVAL,ST_CHRVAL, ST_FLOVAL, ST_STRVAL, ST_FARRAY, ST_IARRAY, or ST_UNDEF(undefined).  .sh 2 "Writing Values to ESPS Common".lpPrograms can leave values in ESPS Common for use by other programs.  To do this, they call the following "putsym" routines (which correspond to the "getsym" routines discussed earlier):.nf.TSbox,center;c sc | cl | li.Writing Value to ESPS Common_Type of Symbol	Program to Call_int	putsym_idouble	putsym_d *char	putsym_c *string	putsym_sint array	putsym_ia *double array	putsym_da *.TE(* = not implemented yet).fi.lpBecause program communication through the Common file is not reliable if the programs involved are all on a series of connected pipes, most ESPS programs do not write the Common file if the output is standard output.  .sh 2 "Example".lpHere is a sketch of code used to process parameters from the parameterand common files:.vS.nf    main(argc, argv)    int argc;    char **argv;    {     .     .     .    /* parse command line for parameters */    while ((c = getopt(argc, argv, "p:")) != EOF)	switch (c)         {	    case 'p':		prange = optarg;		pflag++;		break;	    default:		SYNTAX;	}     .     .     .    /*process input SD file -- name is sd_file, header is ih*/     .     .     .    /*set default values for start and nan*/    start = 1;    nan = MAXLONG;    /*build parameter symbol table*/    read_params("params", SC_CHECK_FILE, sd_file);    /* now read in the values of the parameters from the symbol table */    /*start and nan are optional in parameter file*/    if (sym_type("start") != ST_UNDEF) start = getsym_i("start");    if (sym_type("nan") != ST_UNDEF) nan = getsym_i("nan");   /*the other parameters are not optional*/    decrem = getsym_s ("decrem");    harmonic_mult = getsym_d ("harmonic_mult");    symerr_exit();      /* exit if any errors occurred */    last = start + nan - 1;    /*command-line option might override start and last*/    if (pflag) range_switch(prange, &start, &last, 0);     .     .     .    /*write values to ESPS Common*/    if (strcmp(oname, "<stdout>") != 0) {        if (putsym_s("filename", sd_file) == -1)	    (void) fprintf (stderr, "error writing filename symbol in Common.\n");        if (putsym_i("start", start) == -1)	    (void) fprintf (stderr, "error writing start symbol in Common.\n");        if (putsym_i("nan", nan) == -1)	    (void) fprintf (stderr, "error writing nan symbol in Common.\n");    }    exit(0);    }.fi.vE.lpThis example includes an example of using the library routine.i range_switch(3\-\s-1ESPS\s+1) to aid in processing options of the form \fB\-p\fIstart:last\fR.  .sh 2 "Parameter file implementation notes".lpThe routine.i read_paramsis implemented as a YACC grammar that calls a lexical analyzer built byLEX.  As the input is parsed, symbol in Commons are added to a hash table.  LEXimposes a couple of limitations on the input:  tokens (includingcharacter strings) can be no more than 200 characters long (in the inputform, including quotes and backslashes), and there may be no nullcharacters (ASCII 0) in the input (LEX will interpret a null characteras end of file).  The hash table has a limited size; it is large enoughso this is not a concern.  Strings and identifier names are stored indynamic memory, as are arrays.  Arrays are stored internally as linkedlists, mainly because these are easier to build recursively using YACCrules.  .lpThe programmer should not depend on any of these characteristics ofthe implementation, as all are subject to change (though I doubt we'llscrap LEX and YACC)..sh 1 "Possible Changes".lpIncluded files may be added to parameter files. If nesting is allowed,only a fairly shallow level of nesting will be permitted. One possiblesyntax is a line containing only "@filename".  The format of parameterfiles might also be changed to something more user-friendly.  .sh 1 "Relation Between Parameter Names and Header Items".lpIf the value of a parameter affects data in output \s-1ESPS\s+1 files, then theparameter value should be stored in the output file header. The namesof parameters should be the same as the names of header items; thus wehave parameters like "order" corresponding to the structure tag "order".Some optional header parameters correspond to rational functions in theZ domain; these parameters are specified as two floating array parameters,one with the suffix "_z" (to represent the zero polynomial) and one withthe suffix "_p" (to represent the pole polynomial). Thus to specify afilter transfer function, we might have.(lfloat filter_z = { b0, b1, b2 },      filter_p = { a0, a1, a2, a3};.)lwhere the bn and an terms are replaced by appropriate values..lpParameters that only affect terminal or graphic output for a specificprogram may have arbitrary names and are not stored in file headers; allnames must be documented along with the programs they affect.  See the "ESPS PARAMETERS" sections of [1, Section 1] man pages.  .sp 3.ce 1(end)

⌨️ 快捷键说明

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