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

📄 spsamo.c

📁 speech signal process tools
💻 C
字号:
/*---------------------------------------------------------------------------+| sdsamo: convert sds file to amasm object file (amsim format)		     || Joseph T. Buck							     || convered to SPS by Alan Parker+---------------------------------------------------------------------------*/#ifdef SCCS	static char *sccsid = "@(#)spsamo.c	1.2 6/25/86";#define VERSION "1.2"#else#define VERSION "debug"#endif#include <sps/sps.h>#include <stdio.h>#define SIZ_S (sizeof (short))extern int optind,errno;extern char *optarg, *malloc();main (argc, argv)int     argc;char  **argv;{    struct header  *h;    int     start = 1, np = -1, dloc = 0, c, err = 0, gflag = 0;    char   *inp_file = "<stdin>";    FILE * istrm = stdin, *ostrm = stdout;    float  *data;    double  gain, atof ();    while ((c = getopt (argc, argv, "l:s:n:g:")) != EOF) {	switch (c) {	    case 'l': 		dloc = atoh (optarg);		break;	    case 's': 		start = atoi (optarg);		break;	    case 'n': 		np = atoi (optarg);		break;	    case 'g': 		gain = atof (optarg);		gflag++;		break;	    default: 		exit (1);	}    }/* if in_name is not present, or is "-", read from stdin */    if (optind != argc) {	inp_file = argv[optind++];	if (strcmp (inp_file, "-") == 0)	    inp_file = "<stdin>";	else	    TRYOPEN ("spsamo", inp_file, "r", istrm);    }    if ((h = read_header (istrm)) == NULL)	NOTSPS ("spsamo", inp_file);    if (h -> common.type != FT_SD) {	fprintf (stderr, "spsamo: %s is not sampled data\n", inp_file);	exit (1);    }    if (np < 0)	np = h -> common.ndrec - start + 1;    if (start > h -> common.ndrec || start + np - 1 > h -> common.ndrec) {	fprintf (stderr, "spsamo: %s has only %d points\n", 		inp_file, h -> common.ndrec);	exit (1);    }    if (dloc + np > 65536)	np = 65536 - dloc;    if (optind != argc)	TRYOPEN ("spsamo", argv[optind], "w", ostrm);    if (gflag)    	fprintf (ostrm, "# %s, points %d to %d, gain %g\n", inp_file, start, 		start + np - 1, gain);    else    	fprintf (ostrm, "# %s, points %d to %d\n", inp_file, start, 		start + np - 1);    fprintf (ostrm, "dmem %04x\n", dloc);/* skip the required number of points with fseek. If this does not work,   do it with reads. */    skiprec (istrm, start - 1, size_rec (h));/* Now convert the data */    data = (float *) malloc (np * sizeof (float));    get_sd_recf (data, np, h, istrm);    if (gflag) {	while (np--) {	    int     idata;	    if (*data >= 0) idata = 0.5 + gain * *data++;	    else idata = - (int) (0.5 - gain * *data++);	    idata &= 0xffff;	    fprintf (ostrm, "%04x\n", idata);	}    }    else	while (np--) {	    int     idata;	    if (*data >= 0) idata = 0.5 + *data++;	    else idata = - (int) (0.5 - *data++);	    idata &= 0xffff;	    fprintf (ostrm, "%04x\n", idata);	}    fprintf (ostrm, ";\n");    exit (err);}

⌨️ 快捷键说明

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