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

📄 hdrproc.c

📁 speech signal process tools
💻 C
字号:
/*	 This material contains proprietary software of Entropic Processing, Inc. Any reproduction, distribution, or publication without the the prior	    written permission of Entropic Processing, Inc. is strictly prohibited. Any public distribution of copies of this work authorized in writing by Entropic Processing, Inc. must bear the notice			       	Copyright 1986, Entropic Proccessing, Inc	(C) 1985, Entropic Processing, Inc.         */#ifdef SCCSstatic char *sccsid = "@(#)hdrproc.c	1.7 8/20/86 EPI";#endif/*  Header processing for pitch tracker */char   *savestring (), *mktemp (), *strcpy (), *string;extern int  optind;extern char *optarg;short   getmthd ();double atof();/* Temporary file name template. We write all the pitch info there first,   then write out the header followed by the data. */double  tmpd[NPR];char   *tmp_name = "/tmp/ptrXXXXXX";char   *param_file = "params",       *inp_file = "<stdin>";struct header  *ih,               *oh,               *tmhd;int     pos_nan;while ((c = getopt (argc, argv, "b:s:p:x:h:")) != EOF){    switch (c)    {	case 'b':		bne = atof(optarg);		bne_thr = 2.0 * bne;		printf("bne = %f\n", bne);		break;	case 'p': 	    param_file = optarg;	    break;	case 'x': 	    debug_level = atoi (optarg);	    break;	case 'h': 	    if ((hptr = fopen (optarg, "w")) == NULL)		CANTOPEN ("ptrack", optarg);	    break;	default: 	    USAGE ("ptrack [-p param] [-x level] [-h hisfile] [in] [out]");    }}if (optind < argc){    inp_file = savestring (argv[optind++]);    if (strcmp (inp_file, "-") == 0)	inp_file = "<stdin>";    else	TRYOPEN ("ptrack", inp_file, "r", ifd);}if ((ih = read_header (ifd)) == NULL)    NOTSPS ("ptrack", inp_file);/* Check file type. */if (ih -> common.type != FT_SD){    fprintf (stderr, "ptrack: input file has illegal type\n");    exit (1);}if (optind < argc && (outptr = fopen (argv[optind], "w")) == NULL)    CANTOPEN ("ptrack", argv[optind]);/* Open temporary file */if ((anaptr = fopen (mktemp (tmp_name), "w+")) == NULL){    perror ("ptrack: can't open temporary file");    exit (1);}/* -------------------- read parameter file -------------------- */read_param (param_file);istan = getsym_i ("start");	/* SPS modification START replaces ISTAN 				*/frmlen = getsym_i ("frmlen");stepsz = getsym_i ("stepsz");nan = getsym_i ("nan");if (istan == 0)    istan = frmlen + 45;if (istan - frmlen - 45 < 0){    istan = frmlen + 45;    fprintf (stderr, "WARNING: First sample analyzed = %d\n", istan);}pos_nan = (ih -> common.ndrec) - 3 * frmlen - istan + 1;if (nan == 0)    nan = pos_nan;if (nan > pos_nan){    nan = pos_nan;    fprintf (stderr, "WARNING: Last sample processed = %d\n", nan);}lpf_num[0] =.29296875;lpf_num[1] =.5859375;lpf_num[2] =.29296875;lpf_den[0] = 1.;lpf_den[1] = 0.;lpf_den[2] =.171875;ns = getsym_da ("lpf_num", tmpd, NPR);if (tmpd[0] !=.29296875 || tmpd[1] !=.5859375 || tmpd[2] !=.29296875)    Fprintf (stderr, "WARNING: num_LPF specified different from the one in PTRACK doc\n");for (i = 0; i < NPR; i++)    lpf_num[i] = tmpd[i];ds = getsym_da ("lpf_den", tmpd, NPR);if (tmpd[0] != 1.0 || tmpd[1] != 0.|| tmpd[2] !=.171875)    Fprintf (stderr, "WARNING: den_LPF specified different from the one in PTRACK doc\n");for (i = 0; i < NPR; i++)    lpf_den[i] = tmpd[i];/*ns = getsym_da ("prefilter_num", tmpd, NPR);if (){  Fprintf(stderr, "Prefilter specification is not supported yet\n");  exit(1);}*/wflt_order = getsym_i ("wflt_order");p_method = getsym_i ("p_method");				/* SPS modification P_METHOD for METHOD */u_pflt_order = getsym_i ("u_pflt_order");v_pflt_order = getsym_i ("v_pflt_order");pt_wsize = getsym_i ("pt_wsize");uv_thresh = getsym_d ("uv_thresh");pitch_range_min = getsym_i ("min_pp");pitch_range_max = getsym_i ("max_pp");coh_data = 0;string = getsym_s ("coh_data");if (strcmp (string, "RAW") == 0)    coh_data = 1;if (strcmp (string, "raw") == 0)    coh_data = 1;if (strcmp (string, "r") == 0)    coh_data = 1;if (strcmp (string, "RESIDUAL") == 0)    coh_data = 2;if (strcmp (string, "residual") == 0)    coh_data = 2;if (strcmp (string, "w") == 0)    coh_data = 2;if (strcmp (string, "BOTH") == 0)    coh_data = 3;if (strcmp (string, "both") == 0)    coh_data = 3;if (strcmp (string, "b") == 0)    coh_data = 3;if (coh_data == 0){    fprintf (stderr, "Wrong Data Type. coh_data = BOTH used\n");    coh_data = BOTH;}coh_method = 0;string = getsym_s ("coh_method");if (strcmp (string, "AUTO_COH") == 0)    coh_method = 1;if (strcmp (string, "auto_coh") == 0)    coh_method = 1;if (strcmp (string, "a") == 0)    coh_method = 1;if (strcmp (string, "STR2_COH") == 0)    coh_method = 2;if (strcmp (string, "str2_coh") == 0)    coh_method = 2;if (strcmp (string, "s") == 0)    coh_method = 2;if (coh_method != AUTO_COH && coh_method != STR2_COH){    Fprintf (stderr, "Unknown coherence estimation method\n");    exit (1);}/* These next parameter entries were added for the April 23, 1986  SPS release */win_type = NONE;/* not yet supportedwin_type = getsym_i ("win_type");if(win_type != NONE){ Fprintf(stderr, "Windowing of data is not supported yet"); exit(1);}*/dcrem = NO;/*dcrem = getsym_i ("dcrem");if( dcrem != NO) { Fprintf(stderr, "DC removal is not supported yet\n"); exit(1);}*/coh_window_frac = -99.;/*coh_window_frac = getsym_d ("coh_window_frac");if( coh_window_frac  != -99) { Fprintf(stderr, "Coh_window_frac specification is not supported yet\n"); exit(1);}*/pb_offset = -99;/*pb_offset = getsym_i ("pb_offset");if( pb_offset != -99) { Fprintf(stderr, "PB_offset specification is not supported yet\n"); exit(1);}*/harmonic_mult = -99.;/*harmonic_mult = getsym_d("harmonic_mult");if( harmonic_mult != -99.) { Fprintf(stderr, "harmonic_mult specification is not supported yet\n"); exit(1);}*/tm_uv_thresh = -99.;/*tm_uv_thresh = getsym_d ("tm_uv_thresh");if( tm_uv_thresh != -99.) { Fprintf(stderr, "Tm_uv_thresh specification is not supported yet\n"); exit(1);}*/am_uv_thresh = -99.;/*am_uv_thresh = getsym_d ("am_uv_thresh");if( am_uv_thresh != -99.) { Fprintf(stderr, "am_uv_thresh removal is not supported yet\n"); exit(1);}*/hp_thresh = -99.;/*hp_thresh = getsym_d ("hp_thresh");if( hp_thresh != -99.) { Fprintf(stderr, "Hp_thresh specification is not supported yet\n"); exit(1);}*/gain_halt = -99.;/*gain_halt = getsym_d ("gain_halt");if( gain_halt != -99.) { Fprintf(stderr, "Gain_halt specification is not supported yet\n"); exit(1);}*/pulse_search = -99;/*pulse_search = getsym_i ("pulse_search");if( pulse_search != -99) { Fprintf(stderr, "Pulse_search specification is not supported yet\n"); exit(1);}*/min_coh_len = 20;/*min_coh_len = getsym_i ("min_coh_len");if( min_coh_len != 20) { Fprintf(stderr, "Min_coh_len specification is not supported yet\n"); exit(1);}*/max_coh_len = 32768;		/* max_pp * coh_window_frac; *//*max_coh_len = getsym_i ("max_coh_len");if( max_coh_len != 32768) { Fprintf(stderr, "Max_coh_len specification is not supported yet\n"); exit(1);}*/symerr_exit ();/* -------------------- generate output header -------------------- */if ((oh = new_header (FT_PIT)) == NULL)    Fprintf (stderr, "Output file is not a valid SPS file type\n");add_source_file (oh, inp_file, ih);/* CHANGE HEREoh -> hd.pit -> frmlen = frmlen;*/oh -> hd.pit -> spares[0] = frmlen;oh -> hd.pit -> stepsz = stepsz;oh -> hd.pit -> wflt_order = wflt_order;if (istan == frmlen + 45){    oh -> hd.pit -> start = 0;    oh -> hd.pit -> nan = nan + frmlen + 45;}else{    oh -> hd.pit -> start = istan;    oh -> hd.pit -> nan = nan;}oh -> common.tag = yes;oh -> hd.pit -> src_sf = ih -> hd.sd -> sf;oh -> hd.pit -> min_pp = pitch_range_min;oh -> hd.pit -> max_pp = pitch_range_max;strcpy (oh -> common.prog, "ptrack");#ifdef SCCSstrcpy (oh -> common.vers, "1.2");#elsestrcpy (oh -> common.vers, "0.1");#endifoh -> hd.pit -> p_method = C_PDM;oh -> hd.pit -> pt_wsize = pt_wsize;oh -> hd.pit -> uv_thresh = uv_thresh;oh -> hd.pit -> u_pflt_order = u_pflt_order;oh -> hd.pit -> v_pflt_order = v_pflt_order;/* SPS header items for April 23, 1986 release */oh -> hd.pit -> win_type = win_type;oh -> hd.pit -> coh_method = coh_method;oh -> hd.pit -> dcrem = dcrem;oh -> hd.pit -> coh_window_frac = coh_window_frac;oh -> hd.pit -> pb_offset = pb_offset;oh -> hd.pit -> harmonic_mult = harmonic_mult;oh -> hd.pit -> tm_uv_thresh = tm_uv_thresh;oh -> hd.pit -> am_uv_thresh = am_uv_thresh;oh -> hd.pit -> hp_thresh = hp_thresh;oh -> hd.pit -> gain_halt = gain_halt;oh -> hd.pit -> pulse_search = pulse_search;oh -> hd.pit -> min_coh_len = min_coh_len;oh -> hd.pit -> max_coh_len = max_coh_len;oh -> hd.pit -> coh_data = coh_data;(void) strcpy (oh -> common.progdate, "April 25, 1986");				/* needs to be done right next time around 				*/oh -> variable.refer = inp_file;oh -> hd.pit -> lpf = new_zfunc (ns, ds, lpf_num, lpf_den);/* add header to temporary file */tmhd = copy_header (oh);write_header (tmhd, anaptr);/*printf("istan is %d, frmlen is %d, nan is %d, pos_nan is %d, order is %d\n",        istan, frmlen, nan, pos_nan, wflt_order);printf("u_pflt is %d, v_pflt is %d, pt_wsize is %d\n",        u_pflt_order, v_pflt_order, pt_wsize);printf("uv_thresh is %f, pitch_range_min is %d, pitch_range_max is %d\n",        uv_thresh, pitch_range_min, pitch_range_max);*/

⌨️ 快捷键说明

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