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

📄 atospsg.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 2 页
字号:
/* atosps: converts spstoa(1-ESPS) back to a binary ESPS data file * * 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" * * Author: Joe Buck, Alan Parker, Ajaipal S. Virdy * * Based on atosds, version 1.1. * Converted to SPS by Alan Parker * ESPS FEA file support by Ajaipal S. Virdy */#ifdef SCCS    static char *sccs_id = "@(#)atospsg.c	3.12		7/8/96	ESI";#endif#include <stdio.h>#include <esps/esps.h>#include <esps/fea.h>#include <esps/unix.h>#include <esps/filt.h>#include "tagdef.h"#define geth(a) a=atoh(buf+3)#define getf(a) a=atof(buf+3)/* * E S P S *  F U N C T I O N S *   R E F E R E N C E D */char	*savestring();char	*get_cmd_line();void	addstr();/* * L O C A L *  F U N C T I O N S *   R E F E R E N C E D */char	*nextval();char	*cvt_typtxt();char	*index();struct zfunc *make_z();static void 	make_gens();/* * G L O B A L *  V A R I A B L E S */char	*ProgName = "atosps";char	*in_file = "<stdin>";int	deleted_hdr = 0;main (argc, argv)char  **argv;{    FILE    *istrm = stdin;    FILE    *ostrm = stdout;    register struct header *h = new_header (0);    register int    i;    char    buf[50];    char    combuf[100];    int	    cvt_fearec ();    if (argc != 3) {	Fprintf (stderr,	"Usage: %s infile outfile\n", argv[0]);	exit (1);    }    if (argc > 1 && strcmp (argv[1], "-") != 0) {	TRYOPEN (ProgName, argv[1], "r", istrm);	in_file = argv[1];    }    if (!fgets (buf, 10, istrm)) {	Fprintf (stderr, "%s: %s is empty.\n", ProgName, in_file);	exit (1);    }    else if (strcmp (buf, "{\n") != 0) {	    Fprintf (stderr,	    "%s: %s has the wrong format.\n", ProgName, in_file);    }    if (argc > 2 && strcmp (argv[2], "-") != 0) {	TRYOPEN (ProgName, argv[2], "w", ostrm);    }    (void) readhead (istrm, h, -1);    if (deleted_hdr) {	(void) sprintf (combuf, "%d header%s deleted during conversion.\n",	deleted_hdr, (deleted_hdr == 1) ? " was" : "s were");	(void) add_comment (h, combuf);    }    add_comment(h, get_cmd_line(argc, argv));/* this file will be in NATIVE format, since fwrites are used*/    h->common.edr = NO;	    write_header (h, ostrm);    switch (h->common.type) {	case FT_SD:	case FT_FILT:	    for (i = 0; i < h->common.ndrec; i++)		readrec (istrm, ostrm, h); 	    break;	case FT_FEA:	    cvt_fearec (istrm, ostrm, h);	    break;    }    exit (0);}/* When readhead is called, the opening "{" line has already been read */readhead (in, h, lev)FILE	*in;register struct header *h;int	lev;{    /* Global Variables Referenced     * char	*in_file;     */#define BUFFER_SIZE 8000    char    *buf;    int     len;    int     nxthead = 0;    int	    nxtsrc = 0;    int	    tag;    short   type = 0;    short   item = 0;    char    gen_name[128];    int     gen_type;    long    gen_size;    char    **code_list;    int     i;    /* Local Functions Referenced */    int	    cvt_feahdr ();#if !defined(DEC_ALPHA) && !defined(HP700)    char    *calloc ();#endif    buf = malloc(BUFFER_SIZE);    assert(buf);    while (1) {	if (!fgets (buf, BUFFER_SIZE, in)) {	    Fprintf (stderr, "%s: Unexpected EOF in %s\n", ProgName, in_file);	    exit (1);	}	len = strlen (buf);	if (buf[0] == '}')	    return;	else if (buf[0] == '{') {		if (buf[1] == '{') {	/* reference header */		    h->variable.refhd = new_header (0);		    readhead (in, h->variable.refhd, lev-1);		} else		    if (buf[1] == '}')	    /* illegal header */			deleted_hdr++;		    else		    /* legal header */		    {			h->variable.srchead[nxthead] = new_header (0);			readhead (in, h->variable.srchead[nxthead], lev-1);			nxthead += 1;		    }	}	else {	    if (sscanf (buf, "%x", &tag) != 1)		synerr ("bad header tag", lev);	    switch (tag) {		case TAG_type:		    if(h->common.type != 0) {			Fprintf(stderr,			"%s: Type already set (%d); bad file!\n",			ProgName, h->common.type);			(void) fflush(stderr);			exit(1);		    }		    geth(h->common.type);		    type = h->common.type;		    switch (h->common.type) {			case FT_SD:			    if ((h->hd.sd = (struct sd_header *) 			     calloc(1,SD_SIZE)) == NULL) {			     spsassert(0,"calloc failed");			    }			    break;			case FT_FILT:			    if ((h->hd.filt = (struct filt_header *) 			     calloc(1,FILT_SIZE)) == NULL) {			     spsassert(0,"calloc failed");			    }			    break;			case FT_FEA:			    if ((h->hd.fea = (struct fea_header *) 			     calloc(1,FEA_SIZE)) == NULL) {			     spsassert(0,"calloc failed");			    }			    break;			default:			    Fprintf(stderr,"%s: Bad file type code %d.\n",			    ProgName, h->common.type);			    exit (1);		    }		case TAG_check:	  	    geth(h->common.check);		    break;		case TAG_date:		    buf[len-1] = '\0';		    (void) strncpy (h->common.date, buf+3, DATESIZE);		    break;		case TAG_hdvers:		    buf[len-1] = '\0';		    (void) strncpy (h->common.hdvers, buf+3, VERSIONSIZE);		    break;		case TAG_prog:		    buf[len-1] = '\0';		    (void) strncpy (h->common.prog, buf+3, PROGSIZE);		    break;		case TAG_vers:		    buf[len-1] = '\0';		    (void) strncpy (h->common.vers, buf+3, VERSIONSIZE);		    break;		case TAG_progdate:		    buf[len-1] = '\0';		    (void) strncpy (h->common.progdate, buf+3, DATESIZE);		    break;		case TAG_user:		    buf[len-1] = '\0';		    (void) strncpy (h->common.user, buf+3, USERSIZ);		    break;		case TAG_ndrec:		    geth(h->common.ndrec);		    break;		case TAG_tag:		    geth(h->common.tag);		    break;		case TAG_ndouble:		    if (type == FT_SD || type == FT_FILT) 			geth(h->common.ndouble);		    break;		case TAG_nfloat:		    if (type == FT_SD || type == FT_FILT) 			geth(h->common.nfloat);		    break;		case TAG_nlong:		    if (type == FT_SD || type == FT_FILT) 			geth(h->common.nlong);		    break;		case TAG_nshort:		    if (type == FT_SD || type == FT_FILT) 			geth(h->common.nshort);		    break;		case TAG_nchar:		    if (type == FT_SD || type == FT_FILT) 			geth(h->common.nchar);		    break;		case TAG_spare:		    geth(item);		    if (!fgets (buf, BUFFER_SIZE, in)) {			Fprintf (stderr, "%s: Unexpected EOF in %s\n", 			ProgName, in_file);			exit (1);		    }		    if (type == 0) h->common.spares[item] = atoh(buf);		    if (type == FT_SD) h->hd.sd->spares[item] = atoh(buf);		    if (type == FT_FILT) h->hd.filt->spares[item] = atoh(buf);		    break;		case TAG_source: 		    buf[len - 1] = 0;		    h->variable.source[nxtsrc++] = savestring (buf + 3);		    break;		case TAG_typtxt: 		    buf[len - 1] = '\0';		    h->variable.typtxt = savestring (cvt_typtxt (buf + 3));		    break;		case TAG_comment: 		    buf[len - 1] = '\0';		    h->variable.comment = savestring (cvt_typtxt (buf + 3));		    break;		case TAG_refer: 		    buf[len - 1] = '\0';		    h->variable.refer = savestring (buf + 3);		    break;		case TAG_src_sf:		    if (type == FT_SD) getf(h->hd.sd->src_sf);		    break;		case TAG_dcrem:		    if(type == FT_SD) getf(h->hd.sd->dcrem);		    break;		case TAG_equip:		    if (type == FT_SD) geth(h->hd.sd->equip);		    break;		case TAG_max_value:		    if (type == FT_SD) getf(h->hd.sd->max_value);		    break;		case TAG_sf:		    if (type == FT_SD) getf(h->hd.sd->sf);		    break;		case TAG_synt_method:		    if (type == FT_SD) geth(h->hd.sd->synt_method);		    break;		case TAG_scale:		    if (type == FT_SD) getf(h->hd.sd->scale);		    break;		case TAG_q_method:		    if (type == FT_SD) geth(h->hd.sd->q_method);		    break;		case TAG_v_excit_method:		    if (type == FT_SD) geth(h->hd.sd->v_excit_method);		    break;		case TAG_uv_excit_method:

⌨️ 快捷键说明

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