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

📄 spstoag.c

📁 speech signal process tools
💻 C
字号:
/* sps to ascii converter.  Converts an sps data file to an ascii file * suitable for mailing or movement across different machine types. * Original program by Joe Buck, modified for SPS by Alan Parker. *  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) 1987 Entropic Speech, Inc.; All rights reserved" * 				 */static char *sccs_id = "@(#)spstoag.c	1.1	6/11/87 ESI";#include <stdio.h>#include <sps/sps.h>#include "tagdef.h"char *Program = "spstoa";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) {	NOTSPS (Program, in_file);    }    dumphead (ostrm, h, 1);    (void) fflush (ostrm);    for (i = 0; i < h->common.ndrec; i++)	dumprec (istrm, ostrm, h);    exit (0);}dumphead (o, h, first)register    FILE * o;register struct header *h;int first;{    register int    i;    char sbuf[100];/* Headers start with { and end with }, and may be nested */    fprintf (o, "{\n");/* * common part of header */    fprintf (o, "%02x %x\n", TAG_type, h->common.type);    fprintf (o, "%02x %x\n", TAG_check, h->common.check);    if (h->common.date[0])	fprintf (o, "%02x %.26s\n", TAG_date, h->common.date);    if (h->common.hdvers[0])	fprintf (o, "%02x %.8s\n", TAG_hdvers, h->common.hdvers);    if (h->common.prog[0])	fprintf (o, "%02x %.16s\n", TAG_prog, h->common.prog);    if (h->common.vers[0])	fprintf (o, "%02x %.8s\n", TAG_vers, h->common.vers);    if (h->common.progdate[0])	fprintf (o, "%02x %.26s\n", TAG_progdate, h->common.progdate);    if (h->common.ndrec)	fprintf (o, "%02x %x\n", TAG_ndrec, h->common.ndrec);    if (h->common.tag)	fprintf (o, "%02x %x\n", TAG_tag, h->common.tag);    if (h->common.ndouble)	fprintf (o, "%02x %x\n", TAG_ndouble, h->common.ndouble);    if (h->common.nfloat)	fprintf (o, "%02x %x\n", TAG_nfloat, h->common.nfloat);    if (h->common.nlong)	fprintf (o, "%02x %x\n", TAG_nlong, h->common.nlong);    if (h->common.nshort)	fprintf (o, "%02x %x\n", TAG_nshort, h->common.nshort);    if (h->common.nchar)	fprintf (o, "%02x %x\n", TAG_nchar, h->common.nchar);    for (i=0; i<NSPARES && h->common.spares[i]; i++)	fprintf (o, "%02x %x\n%x\n", TAG_spare, i, h->common.spares[i]);/*  * variable part of header */    for (i = 0; i < MAX_SOURCES && h->variable.source[i]; i++)	fprintf (o, "%02x %s\n", TAG_source, h->variable.source[i]);    if (h->variable.typtxt)	fprintf (o, "%02x %s\n", TAG_typtxt, cvt_tt (h->variable.typtxt));    if (first == 1) {	sprintf (sbuf, "Converted from %s by spstoa.\n",in_file);	add_comment(h,sbuf);    }    if (h->variable.comment)	fprintf (o, "%02x %s\n", TAG_comment, cvt_tt (h->variable.comment));    if (h->variable.refer)	fprintf (o, "%02x %s\n", TAG_refer, h->variable.refer);/*  * type specific part of header */    switch (h->common.type) {     case FT_SD:	fprintf(o, "%02x %x\n", TAG_equip, h->hd.sd->equip);		fprintf(o, "%02x %g\n", TAG_max_value, h->hd.sd->max_value);		fprintf(o, "%02x %.7g\n", TAG_sf, h->hd.sd->sf);		fprintf(o, "%02x %.7g\n", TAG_src_sf, h->hd.sd->src_sf);		fprintf(o, "%02x %x\n", TAG_synt_method, h->hd.sd->synt_method);	fprintf(o, "%02x %.7g\n", TAG_scale, h->hd.sd->scale);		fprintf(o, "%02x %.7g\n", TAG_dcrem, h->hd.sd->dcrem);		fprintf(o, "%02x %x\n", TAG_q_method, h->hd.sd->q_method);		fprintf(o, "%02x %x\n", TAG_v_excit_method, h->hd.sd->v_excit_method);	fprintf(o, "%02x %x\n", TAG_uv_excit_method, 				h->hd.sd->uv_excit_method);		if(h->hd.sd->spare1)	   fprintf(o, "%02x %x\n", TAG_spare1, h->hd.sd->spare1);		fprintf(o, "%02x %x\n", TAG_nchan, h->hd.sd->nchan);		fprintf(o, "%02x %x\n", TAG_synt_interp, h->hd.sd->synt_interp);		fprintf(o, "%02x %x\n", TAG_synt_pwr, h->hd.sd->synt_pwr);		fprintf(o, "%02x %x\n", TAG_synt_rc, h->hd.sd->synt_rc);		fprintf(o, "%02x %x\n", TAG_synt_order, h->hd.sd->synt_order);	        for (i=0; i<SD_SPARES && h->hd.sd->spares[i]; i++)	   fprintf (o, "%02x %x\n%x\n", TAG_spare, i, h->hd.sd->spares[i]);	if (h->hd.sd->prefilter)	   dump_z (o, TAG_prefilter, h->hd.sd->prefilter);	if (h->hd.sd->de_emp)	   dump_z (o, TAG_de_emp, h->hd.sd->de_emp);	break;     default:	fprintf(stderr,"spstoa: unknown header type %d",h->common.type);	fprintf(stderr,"spstoa: this version only works on SD files.\n");	exit (1);    }    for (i = 0; i < MAX_SOURCES && h->variable.srchead[i]; i++)	dumphead (o, h->variable.srchead[i]);    fprintf (o, "}\n");}dumprec (in, out, h)FILE * in, *out;struct header  *h;{    double  dbuf[1024];    float fbuf[1024];    long lbuf[1024];    short sbuf[1024];    char cbuf[1024];    register int    i;    long    pos;    if (h->common.tag) {	if (!fread ((char *) &pos, sizeof pos, 1, in))	    bomb ();	fprintf (out, "%lx \n", pos);    }    if (h->common.ndouble) {	if (!fread ((char *) dbuf, sizeof (double), h->common.ndouble, in))	    bomb ();	for (i=0; i< h->common.ndouble; i++)	    fprintf(out, "%.16g \n", dbuf[i]);    }    if (h->common.nfloat) {	if (!fread ((char *) fbuf, sizeof (float), h->common.nfloat, in))	    bomb ();	for (i=0; i< h->common.nfloat; i++)	    fprintf(out, "%.8g \n", fbuf[i]);    }    if (h->common.nlong) {	if (!fread ((char *) lbuf, sizeof (long), h->common.nlong, in))	    bomb ();	for (i=0; i< h->common.nlong; i++)	    fprintf(out, "%ld \n", lbuf[i]);    }    if (h->common.nshort) {	if (!fread ((char *) sbuf, sizeof (short), h->common.nshort, in))	    bomb ();	for (i=0; i< h->common.nshort; i++)	    fprintf(out, "%d \n", sbuf[i]);    }    if (h->common.nchar) {	if (!fread (cbuf, sizeof (char), h->common.nchar, in))	    bomb ();	for (i=0; i< h->common.nchar; i++)	    fprintf(out, "%x \n", cbuf[i]);    }    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 + -