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

📄 wplay.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  This material contains proprietary software of Entropic Speech, Inc.     Any reproduction, distribution, or publication without the 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 1986,1987,1988,1989 Entropic Speech, Inc." 				 Joseph T. Buck, Entropic Processing, Inc.				     Modified by Alan Parker to use DACP on Masscomp at WRL 2/13/86 Modified for ESPS by Alan Parker, Entropic Speech, Inc. Modified by Joe Buck to play previous file while reading next one. Modified by Alan Parker for use with DSP32 board Modified by John Shore to accept SIGnal files and for -a option Syntax: play [options] file		   Options:				-x debug_level		-g gain			gain is a floating value. The file is multiplied by this    		value to form the output data.	-p range							  		range is a range of points. Only those points are played 		the first point is 1						-f range								range is a range of frames (default frame size = 100)			the first frame is 1					-w width							changes the frame size			-s range					range is a range of seconds. For LISTEN compatibility, the		first second is zero					 	-r repeats									number of repetitions					-c chan								channel number					-k clock		D/A clock number	-i		Clip samples	-h hist-file		Specify alternate history file.	-b		bits to shift input data to form output data		postive means right shift, negative means left shift*/#ifndef lint	static char *sccs_id = "@(#)wplay.c	1.13 10/8/91 ESI";#endif/* **************** check these defaults ********************** */#ifndef MAXDA#define MAXDA 32767	        /* max value of this D/A (12 bit) */#endif/* ************************************************************ */#define NUM_BUFS 1#define DUTY 50			/* duty cycle of clock */#include <stdio.h>/* include ESPS header files */#include <esps/esps.h>			/* main header stuff */#include <esps/sd.h>			/* SD file stuff */#include <esps/unix.h>			/* Unix function declarations */#include <esps/fea.h>#include <esps/feasd.h>#include <Objects.h>		/* waves+ header files */#define SYNTAX USAGE \("play [-[sprf] range] [-w fsiz] [-c chan] [-k clock] [-R nrpt] [-g gain] [-i] [-h hist-file] [-x debug-level] file ...");/* Globals */int     debug_level = 0, da_done=1, da_location=0;int P8574_type=1;	/* 1 = P8574, 0 = P8574A */int ARIEL_16=0;		/* 16 Mhz crystal on Ariel/surf card, else 24Mhz */void set_pvd();void pr_sarray();int	dsp32_wait = 5;	/* how long to try for board access-- */				/* used by setup_dsp() in spect.c, */int w_verbose = 0;long max_buff_bytes = 2000000;  /* limit on size of signal data buffers */FILE *fopen(), *fdopen();double fabs();/* Externals */void lrange_switch();void frange_switch();extern  int optind;extern  char *optarg;double	atof();char    *getsym_s();void    dac_error();char	*sd_open();double  get_genhd_val();main (argc, argv)int argc;char **argv;{    int     c, i;    int     nrep = 1;    char    *p_switch = NULL, *s_switch = NULL, *f_switch = NULL;    FILE    *istrm, *hfile;    char    *hist = "play.his";    struct  header  *ih;    long    start_p = 1, end_p, start_f, end_f;    double   start_s, end_s;    int     isf, np=0, fwidth = 100, gflag = 0;    double  d_isf;    int	    bflag=0, bits, left, right;    int     nptot = 0,  nofile=0;    int     max = 0, clip = 0, iflag = 0, aflag = 0;    float   *dataf;    short   *data = NULL;    int     argind, devpn = -1,  write_hfile=0;    double  gain=1;    char    dadev[30], clkdev[30], *filename=NULL, *firstfile;    int     filecount=0;    int	    in_progress = 0, prev_np = 0, prev_isf = 0;    int	    range_given = 0;    int     qflag=0;	/* if 1 then suppress all normal messages */    int     data_type = SHORT; /* holds type of data in sampled data files*/    int     dsp_type;    char    *ProgName="wplay";    if (dsp32c_is_available())       dsp_type = DSP32C_VME;    else if (dsp32_is_available())       dsp_type = DSP32_FAB2;    else {       Fprintf(stderr,"%s: No DSP board available.\n",ProgName);       exit(1);       }    while ((c = getopt (argc, argv, "R:p:s:r:c:k:w:f:g:x:iah:b:C:D:q")) != EOF) {	switch (c) {	    case 'x':		debug_level = atoi (optarg);		break;	    case 'g':	        gflag++;		gain = atof (optarg);		break;	    case 'c': 		fprintf(stderr,"play: c option ignored in Sun/waves version.");		break;	    case 'R': 		nrep = atoi (optarg);		break;	    case 'p': 		range_given++;		p_switch = optarg;		break;	    case 'r': 		range_given++;		p_switch = optarg;		break;	    case 'f':		range_given++;		f_switch = optarg;		break;	    case 'w':		fwidth = atoi (optarg);		break;	    case 's': 		range_given++;		s_switch = optarg;		break;	    case 'k':		fprintf(stderr,"play: k option ignored in Sun/waves version.");		break;	    case 'i':		iflag++;		break;	    case 'a':		aflag++;		break;	    case 'h':		hist = optarg;		break;	    case 'b':		bflag++;		bits = atoi(optarg);		break;	    case 'C':		fprintf(stderr,"play: C option ignored in Sun/waves version.");		(void)strncpy(clkdev,optarg,sizeof clkdev);		break;	    case 'D':		fprintf(stderr,"play: D option ignored in Sun/waves version.");		(void)strncpy(dadev,optarg,sizeof dadev);		break;	    case 'q':		qflag=1;		break;	    default: 		SYNTAX;	}    }  if (debug_level)    Fprintf(stderr,"dsp_type is %d\n",dsp_type);    if (bflag && gflag) {	Fprintf(stderr,"play: can't use both -b and -g\n");	exit(1);    }    if (aflag && (bflag || gflag)) {      Fprintf(stderr,"play: can't use -a with -b or -g\n");      exit(1);    }    if (optind >= argc)      nofile = 1;    else      filename = argv[optind];    (void)read_params((char *)NULL,SC_CHECK_FILE,filename);    if (nofile) {      if(symtype("filename") == ST_UNDEF) {	Fprintf(stderr,"play: no input file\n");	SYNTAX;      }      filename = getsym_s("filename");    }    firstfile = filename;    if ((hfile = fopen(hist,"w")) == NULL) {      if (!qflag) {	Fprintf(stderr,"play: warning can't open hist file; will use stderr.\n"); 	hfile = stderr;      }      else	hfile = fopen("/dev/null", "w");    }    if(debug_level) Fprintf(stderr,"play: clk: %s, d/a: %s\n",clkdev,dadev);    argind = optind;    while (nrep > 0) {      optind = argind;      while (optind < argc || nofile) {	filecount++;	if (!nofile) filename = argv[optind];	/* open the input file */	filename = sd_open("play", filename, &ih, &istrm);		/* if input is a pipe (ndrec is -1) then assume 10 seconds of data */	if (ih->common.ndrec == -1)	  ih->common.ndrec = 10 * *get_genhd_d("record_freq",ih);	if (aflag && !(get_genhd_val("max_value",ih,0) > 0)) {	  if (!qflag) {	    Fprintf(stderr,	     "play: input doesn't have max_value > 0; ignoring -a option.\n");	    Fprintf(stderr,	     "\tUse setmax (1-ESPS) to set max_value in header.\n");	    aflag = 0;	  }	}	end_p = ih -> common.ndrec;	if((isf = *get_genhd_d("record_freq",ih)) <= 0) {	  Fprintf(stderr,"play: %s sample frequency is <= zero; exiting\n",		  filename);	  exit(1);	}	start_s = (start_p - 1) / isf;	end_s = (end_p + isf - 1) / isf;	start_f = (start_p - 1) / fwidth + 1;	end_f = (end_p + fwidth - 1) / fwidth;		if(!range_given) {	  if(symtype("start") != ST_UNDEF)	    start_p = getsym_i("start");	  if(symtype("nan") != ST_UNDEF)	    end_p = start_p + getsym_i("nan") -  1;	}		if(!aflag && !bflag && !gflag && symtype("shift") != ST_UNDEF) {	  bits = getsym_i("shift");	  if (bits != 0) {	    if (!qflag)	      Fprintf(stderr,		  "play: using shift (-b option) value of %d from Common file.\n",bits);	    bflag++;	  }	}	if(!aflag && !gflag && !bflag && symtype("gain") != ST_UNDEF) {	  gain = getsym_d("gain");	  if ((gain < .999999) || (gain > 1.000001)) {	    if (!qflag)	      Fprintf(stderr,		  "play: using gain (-g option) value of %lg from Common file.\n",gain);	    gflag++;	    }	}		        if (bflag)          if (bits < 0) left = bits*-1;	  else right = bits;		if (p_switch)	  lrange_switch (p_switch, &start_p, &end_p, 1);	else if (s_switch) {	  frange_switch (s_switch, &start_s, &end_s);	  start_p = start_s * isf + 1;	  end_p = end_s * isf;	  if (end_p <= start_p) end_p += isf;	}	else if (f_switch) {	  lrange_switch (f_switch, &start_f, &end_f, 1);	  start_p = (start_f - 1) * fwidth + 1;	  end_p = end_f * fwidth;	}		np = end_p - start_p + 1;		if(start_p > ih->common.ndrec) {	  Fprintf (stderr, "play: start point (%ld) > number of points (%ld)\n",		   start_p, ih -> common.ndrec);	  exit(1);	}		if (start_p > end_p) {	  Fprintf (stderr, "play: start point (%ld) > end point (%ld)\n",		   start_p, end_p);	  exit (1);	}		if (end_p > ih -> common.ndrec) {	  if (!qflag) {	    Fprintf (stderr, "play: end point (%ld) > number of points (%ld)\n",		   end_p, ih->common.ndrec);	    Fprintf (stderr, "play: end point reset to last point.\n");	  }	  end_p = ih->common.ndrec;	}	

⌨️ 快捷键说明

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