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

📄 ref_cof.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 2 页
字号:
/** This material contains proprietary software of Entropic Speech, Inc.* Any reproduction, distribution, or publication without the prior* written permission of Entropic Speech, Inc. is strictly prohibited.* Any public distribution of copies of this work authorized in writing by* Entropic Speech, Inc. must bear the notice**    "Copyright (c) 1986, 1987 Entropic Speech, Inc.; All rights reserved"**  Module Name: ref_cof.c**  Written By:   Brian Sublett   6/27/86*  Revised By    John Shore (clean up and FEA_ANA support)*  Revised BY:   David Burton (added -a option)*  Revised By:   John Shore (remove ndrec dependence, add -r -p options,		 clean up, found a couple of bugs for multiple frames)*  Checked by: **  Purpose:  This program reads data from an SPS SD file*	     and computes the reflection coefficients and*	     power for the purposes of plotting the maximum*	     entropy spectrum.  The output is written to an*	     SPS FEA_ANA file.**  Secrets:  The user is required to enter the names of*	     the input SD file and the output FEA_ANA file.*	     all important parameters such as the filter*	     order, the data block length for each spectrum,*	     the starting point for the analysis, and the*	     number of data blocks to process should be*	     found in the parameter file.**********************************************************/# ifdef SCCS	static char *sccs_id = "%W% %G%";# endif# include <stdio.h># include <sps/sps.h># include <sps/sd.h># include <sps/ana.h># include <sps/fea.h># include <sps/anafea.h># include <values.h>/* * these defines for max quantities will be removed when  * sps.h gets them */#define SPSMAXLONG	MAXLONG/*** User defines go here. ***/#define SYNTAX USAGE("ref_cof [-P param] [-r range] [-n nframes] [-s syncflag] [-f filtername] [-a method] [-x debug_level] file.sd file.fana")#define Fprintf (void)fprintf#define DEF_ORDER 15#define DEF_FRAMELEN 1000# define DA_MAX 8192    /* Maximum input data array size. */# define FILNAMSIZE 40  /* Maximum size of filter name + 4 */# define PI 3.141592654#define AUTOC 1#define BURG 2#define COV 3#define MBURG 4#define STRCOV 5#define VBURG 6#define ERROR_EXIT(text) {(void) fprintf(stderr, "ref_cof: %s - exiting\n", text); exit(1);}char *strcpy ();char *calloc();char *get_cmd_line();void symerr_exit();void lrange_switch();void add_genzfunc();int bestauto();int symtype();int get_atal();int debug_level = 0;char *local_no_yes[] = {"NO", "YES", NULL};char *analysis_methods[] ={"NONE", "AUTOC", "BURG", "COV", "MBURG", "STRCOV", "VBURG", NULL};int initflag; /* hack to make bestauto work */main (argc, argv)int argc;char *argv[];{    FILE *fopen (), *fpin, *fpout;    char *in_file, *out_file;/* CHANGE: opening up a temporary file later on. */    char *temp_file = "/tmp/refXXXXXX";    FILE *fptemp;    struct header *ih, *oh;    struct anafea *recp;    char *param_file = "params";    char comment[100];/* CHANGE: added da_max and nget.  */    int i,j,k, da_max, nget;    int sinc;    short sinc_flag = NO;    double sin (), arg;    float *x, *xin, *rc;    double *r;/* CHANGE: added nleft.  */    long start, start_p, fsize, nleft;    int order = DEF_ORDER;    int c, knt;    int nframes = 1;    double sqrt (), atof ();    float lpcfilter[DA_MAX], res_energy;    float gain;/* CHANGE: dc and dly become double arrays, xn becomes a double. */    double *dc, *dly, xn;    float *fzeros, *fpoles, *state;    double *zeros, *poles;    char *filter_name, na_name[40], da_name[40];    struct zfunc *pzfunc;    int nsiz, dsiz, siz;    short pre = NO;    char		*cmd_line;	    /*to hold command line*//* CHANGE: use mktemp to name a temporary file. */    extern char *mktemp ();    extern char *optarg;    extern optind;    char *analysis;    int method;    long first, last;    int a_flag = 0;    /* flag for analysis method option*/    int r_flag = 0;    /* flag for range option*/    int n_flag = 0;    /* flag for nframes option*/    char    *prange = NULL;	/* string for range specification (-p) */    int	    more = 1;		/* flag to indicate more sampled data*/    char *Version = "%I%";    char *Date = "%G%";/* Initialization.    */    cmd_line = get_cmd_line(argc, argv);    /*store copy of command line*/    /* Check the command line options. */    while ((c = getopt (argc, argv, "P:p:r:x:f:s:a:")) != EOF)	{	switch (c)	    {	    case 'P':		param_file = optarg;		break;	    case 'r': 		prange = optarg;		r_flag++;		break;	    case 'n':		nframes = atoi(optarg);		if (nframes == 0) nframes = SPSMAXLONG;		n_flag ++;		break;	    case 'x':		if (sscanf(optarg,"%d", &debug_level) != 1)		    {		    Fprintf (stderr,"ref_cof: Error reading -x option. Exitting.\n");		    exit (-1);		    }		if (debug_level != 0) debug_level = 1;		break;	    case 'a':		analysis = optarg;		a_flag++;		break;	    case 'f':		filter_name = optarg;		pre = YES;		break;	    case 's':		if (sscanf(optarg,"%d", &sinc) != 1)		    {		    Fprintf (stderr,"ref_cof: Error reading -s option. Exitting.\n");		    exit (-1);		    }	        sinc_flag = YES;		break;	    default:		SYNTAX;	    }	}        first = 1;    last = DEF_FRAMELEN;    if (r_flag) lrange_switch(prange, &first, &last, 1L);    if (first < 1)	ERROR_EXIT("can't have negative starting point");    if (last == first)	ERROR_EXIT("range must specify more than one point");/* Get the filenames. */    if (optind < argc)	{	in_file = argv [optind++];	if (strcmp (in_file, "-") == 0) 	    {	    fpin = stdin;	    in_file = "<stdin>";	    }	else TRYOPEN("ref_cof", in_file, "r", fpin);	if (debug_level)	    Fprintf (stderr,"Input file is %s\n", in_file);	}    else	{	Fprintf(stderr,"ref_cof: Specify \"-\" for input file to be standard input.\n");	exit (-1);	}    if (optind < argc)	{	out_file = argv [optind++];	if (strcmp (out_file, "-") == 0) 	    {	    fpout = stdout;	    out_file = "<stdout>";	    }	else TRYOPEN("ref_cof", out_file, "w", fpout);	if (debug_level)	    Fprintf (stderr,"Output file is %s\n", out_file);	}    else	{	Fprintf(stderr,"ref_cof: Specify \"-\" for output file to be standard output.\n");	exit (-1);	}    /* Read the input header. */    if ((ih = read_header (fpin)) == NULL)	NOTSPS ("ref_cof", in_file);    if (ih->common.type != FT_SD)	{	Fprintf (stderr,"ref_cof: input file not .sd\n");	exit (1);	}/* Create the output header. */    oh = new_header (FT_FEA);    add_source_file (oh, in_file, ih);    if (add_comment(oh, cmd_line) == 0) 	Fprintf(stderr, 	  "ref_cof: WARNING -- not enough space for command line in comment\n");    (void) strcpy (oh->common.prog, "ref_cof");    (void) strcpy (oh->common.vers, Version);    (void) strcpy (oh->common.progdate, Date);    oh->common.tag = YES;    oh->variable.refer = in_file;/* Read the parameter file. */    read_params(param_file, SC_NOCOMMON, NULL);    if (symtype("order") != ST_UNDEF) order = getsym_i("order");/* initialize header as FEA_ANA */    if (init_anafea_hd(oh, 0, (long) order, 1, 1, 1, 0, 0) != 0)	ERROR_EXIT("error filling FEA_ANA header");    if (r_flag) {	start = first;	fsize = last - first + 1;    }    else {        if (symtype("start") == ST_UNDEF) 	    start = first;	else	    start = (long) getsym_i("start");        if (symtype("fsize") == ST_UNDEF)	    fsize = last - start + 1;	else	    {	    fsize = (long) getsym_i("fsize");/* CHANGE: this option was deleted.  I'm putting it back in.  */	    if (fsize == 0) fsize = ih->common.ndrec - start + 1;	    }    }/* CHANGE: two lines added to set da_max.  *//* Data array sizes will be limited to the smaller of DA_MAX and   fsize in case fsize is very large.    */    if (fsize < DA_MAX) da_max = (int)fsize;    else da_max = DA_MAX;    if (!n_flag)         if (symtype("nframes") != ST_UNDEF) 	    {	    nframes = getsym_i("nframes");/* CHANGE: Shore deleted this option, I put it back in.  */	    if (nframes == 0) 		nframes = (int)(ih->common.ndrec - start + 1)/fsize;	    }    symerr_exit();  /*exit if any of the parameters were missing*//* Start becomes an offset.  *//* CHANGE: This was deleted, I don't know why.  */    start -= 1;	        if (start < 0) ERROR_EXIT("negative starting point");    if (fsize < 0) ERROR_EXIT("can't have negative frame length");    if (!a_flag) {	if(symtype("method") != ST_UNDEF)	    analysis = getsym_s("method");	else             analysis = "AUTOC";    }    if (debug_level)	{

⌨️ 快捷键说明

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