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

📄 sdssdtoa.c

📁 speech signal process tools
💻 C
字号:
/* This is a modified version of sdstoa.   It is intended to * convert sds sampled data file to a format to be read by * atosps, as a way of converting sds sd file to sps. *  * Original program by Joe Buck, modified for SPS by Alan Parker. * * 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 Processing, Inc." * 				 */#ifndef lintstatic char *sccs_id = "@(#)sdssdtoa.c	1.3	5/6/86 EPI";#endif#include <stdio.h>#include "tagdef.h"#include <sds/sds.h>char *Program = "sdssptoa";char *in_file = "<stdin>";char *cvt_tt();main (argc, argv)char  **argv;{    FILE * istrm = stdin, *ostrm = stdout;    struct header  *h;    register int    i;    if (argc > 1 && strcmp (argv[1], "-") != 0) {	TRYOPEN (Program, argv[1], "r", istrm);	in_file = argv[1];    }    if (argc > 2 && strcmp (argv[2], "-") != 0) {	TRYOPEN (Program, argv[2], "w", ostrm);    }    if ((h = read_header (istrm)) == NULL) {	NOTSDS (Program, in_file);    }    else if (h->hd_dtype == 'm') {	fprintf (stderr, "%s: mixed-mode files are not supported\n",Program);	exit (1);    }    if (h->hd_type != FT_SAMPLED_DATA) {	fprintf(stderr, "%s: not sds sd file\n",Program);	exit (1);    }    dumphead (ostrm, h, 1);    (void) fflush (ostrm);    for (i = 0; i < h->hd_ndrec; i++)	dumprec (istrm, ostrm, h);    exit (0);}dumphead (o, h, first)register    FILE * o;register struct header *h;int first;{    register int    i;/* Headers start with { and end with }, and may be nested */    fprintf (o, "{\n");    if (h->hd_type != FT_SAMPLED_DATA)  {	fprintf(stderr,"%s: Non sampled data header found.\n", Program);	exit (1);    }    fprintf (o, "%02x %x\n", TAG_type, 9);    if (first == 1) {	fprintf(o,"%02x ",TAG_comment);	fprintf(o,"Converted from sds file %s by sdssdtoa.\r\n",in_file);    }    if (h->hd_src_sf)	fprintf (o, "%02x %.7g\n", TAG_src_sf, h->hd_src_sf);    if (h->hd_prog[0])	fprintf (o, "%02x %.16s\n", TAG_prog, h->hd_prog);    if (h->hd_version[0])	fprintf (o, "%02x %.8s\n", TAG_vers, h->hd_version);    if (h->hd_ndrec)	fprintf (o, "%02x %x\n", TAG_ndrec, h->hd_ndrec);    switch (h->hd_dtype) {	case 'd': 	fprintf (o, "%02x %x\n", TAG_ndouble, 1);	break;	case 'f': 	fprintf (o, "%02x %x\n", TAG_nfloat, 1);	break;	case 'l': 	fprintf (o, "%02x %x\n", TAG_nlong, 1);	break;	case 'w': 	fprintf (o, "%02x %x\n", TAG_nshort, 1);	break;	case 'c': 	fprintf (o, "%02x %x\n", TAG_nchar, 1);	break;    }    if (h->hd_scale)	fprintf (o, "%02x %.7g\n", TAG_scale, h->hd_scale);    if (h->hd_dcrem)	fprintf (o, "%02x %.7g\n", TAG_dcrem, h->hd_dcrem);    if (h->hd_v_exite)	fprintf (o, "%02x %x\n", TAG_v_excit_method, h->hd_v_exite);    if (h->hd_uv_exite)	fprintf (o, "%02x %x\n", TAG_uv_excit_method, h->hd_uv_exite);    if (h->hd_nchan)	fprintf (o, "%02x %x\n", TAG_nchan, h->hd_nchan);    if (h->hd_mulaw)	fprintf (o, "%02x %x\n", TAG_q_method, h->hd_mulaw);    if (h->hd_sf)	fprintf (o, "%02x %.7g\n", TAG_sf, h->hd_sf);    for (i = 0; i < MAX_SOURCES && h->hd_source[i]; i++)	fprintf (o, "%02x %s\n", TAG_source, h->hd_source[i]);    if (h->hd_pre)	dump_z (o, TAG_prefilter, h->hd_pre);    if (h->hd_typtxt)	fprintf (o, "%02x %s\n", TAG_typtxt,		cvt_tt (h->hd_typtxt));    if (h->hd_refer_file)	fprintf (o, "%02x %s\n", TAG_refer,		h->hd_refer_file);    for (i = 0; i < MAX_SOURCES && h->hd_srchead[i]; i++)	dumphead (o, h->hd_srchead[i],0);    fprintf (o, "}\n");}dumprec (in, out, h)FILE * in, *out;struct header  *h;{    double  buf[1024];    register int    i;    get_ddata (in, h->hd_dtype, buf, h->hd_ldrec);    if (h->hd_dtype == 'f')	for (i = 0; i < h->hd_ldrec; i++)	    fprintf (out, "%.7g ", buf[i]);    else if (h->hd_dtype == 'd')	for (i = 0; i < h->hd_ldrec; i++)	    fprintf (out, "%.15g ", buf[i]);    else	for (i = 0; i < h->hd_ldrec; i++)	    fprintf (out, "%d ", (long) buf[i]);    putc ('\n', out);    return;}dump_z (o, tag, z)FILE * o;int     tag;struct zfunc   *z;{    register int    i;    fprintf (o, "%02x %d %d ", tag, z->nsiz, z->dsiz);    for (i = 0; i < z->nsiz; i++)	fprintf (o, "%.7g ", z->zeros[i]);    for (i = 0; i < z->dsiz; i++)	fprintf (o, "%.7g ", z->poles[i]);    fputc ('\n', o);}char *cvt_tt (s)char   *s;{    register char  *p = s;    while (*p) {	if (*p == '\n')	    *p = '\r';	p++;    }    return s;}bomb () {    fprintf (stderr, "%s: error reading %s\n", Program, in_file);    exit (1);}

⌨️ 快捷键说明

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