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

📄 setup.c

📁 4.8k/s速率FS1016标准语音压缩源码
💻 C
字号:
#include <stddef.h>#include <stdio.h>#include <string.h>#include "celpfilt.h"#include "cli.h"static int CheckOptions(int	analysis, int	synthesis, int	channel_type, float	error_rate, int	write_chan, int	read_chan);FILE		*fopen();/***************************************************************************                                                                         ** ROUTINE*		setup** FUNCTION*		CELP setup* SYNOPSIS**   formal**                       data    I/O*       name            type    type    function*       -------------------------------------------------------------------*	argc		int	i	number of command line arguments*	argv		char	i	array of arguments and file names*	fp_ifile	FILE	o	input file pointer*	fp_ofile	FILE	o	ouput file pointer****************************************************************************** CALLED BY**	celp** CALLS*	cli ***************************************************************************/int Setup(int	argc,char	*argv[],CLI	*UserParams,FILE	**fp_ifile, FILE	**fp_ofile,FILE	**chan_ofp){char		*ifile;		/*  Input file name */char		*ofile;		/*  Output file name */int 		status;/*  Parse command line and return the flag values */	status = cli(argc, argv, UserParams, &ifile, &ofile);/*  If cli doesn't complain */	if (status == ALL_VALID)	{/*  Check for valid option combinations */	  status = CheckOptions(UserParams->analysis, UserParams->synthesis, UserParams->channel_type, 		UserParams->error_rate, UserParams->write_chan, UserParams->read_chan);	  if (status == ALL_VALID)	{/*  Open input speech file */	    if (UserParams->analysis)	{/*  If analysis is being performed, open input speech file */	      if(strcmp(ifile, "None") == 0)	{		printf("*** No input file specified to open for analysis ***\n");		status = INVALID;	      }	      else if ((*fp_ifile = fopen(ifile, "rb")) == NULL)	{	        fprintf(stderr, "*** Error opening input speech file *** \n");	        status = INVALID;	      }	    }	    else	{/*  If a channel is being read, open it */	      if(UserParams->read_chan == BINARY_INT | UserParams->read_chan == BINARY)	{			  
	        if ((*fp_ifile = fopen(UserParams->chan_file, "rb")) == NULL)	{
	          fprintf(stderr, "*** Error opening input channel file *** \n");
	          status = INVALID;
	        }
	      }	      
		  if(UserParams->read_chan == HEX)	{			  
	        if ((*fp_ifile = fopen(UserParams->chan_file, "rt")) == NULL)	{
	          fprintf(stderr, "*** Error opening input channel file *** \n");
	          status = INVALID;
	        }
	      }	    }/*  Open output files */	    if(UserParams->synthesis)	{	      if(strcmp(ofile, "None") == 0)	{			printf("*** No output file specified to open for synthesis ***\n");			status = INVALID;	      }	      else if ((*fp_ofile = fopen(ofile, "wb")) == NULL)	{	        fprintf(stderr, "*** Error opening output speech file *** \n");	        status = INVALID;	      }	    }	    if(UserParams->write_chan== BINARY_INT | UserParams->write_chan == BINARY)	{
	      if ((*chan_ofp = fopen(UserParams->chan_file, "wb")) == NULL)	{
	        fprintf(stderr, "*** Error opening output channel file *** \n");
	        status = INVALID;
	      }
	    }
	    if(UserParams->write_chan== HEX)	{
	      if ((*chan_ofp = fopen(UserParams->chan_file, "wt")) == NULL)	{
	        fprintf(stderr, "*** Error opening output channel file *** \n");
	        status = INVALID;
	      }
	    }
/* Set up filters */  /* Analysis Filters */	    /* High Pass filter for input speech */      	    InputHPFZ = makefilt(InputHPFCoefsZ, InputHPFOrder, InputHPFLength);	    InputHPFP = makefilt(InputHPFCoefsP, InputHPFOrder, InputHPFLength);	    /* Variable filters for determination of residual after LP 		analysis */	    LP_ResZ = makefilt_dynamic(ORDER, RES_LEN);	    LP_ResP = makefilt_dynamic(ORDER, RES_LEN);	    LP_ResP2 = makefilt_dynamic(ORDER, RES_LEN);	    /* Variable filters for determination of residual after Adaptive 		analysis */	    Adapt_ResZ = makefilt_dynamic(ORDER, RES_LEN);	    Adapt_ResP = makefilt_dynamic(ORDER, RES_LEN);	    Adapt_ResP2 = makefilt_dynamic(ORDER, RES_LEN);	    /* Variable filters for updating status of LP and Adaptive residual	  	filters */	    Update_ResZ = makefilt_dynamic(ORDER, RES_LEN);	    Update_ResP = makefilt_dynamic(ORDER, RES_LEN);	    Update_ResP2 = makefilt_dynamic(ORDER, RES_LEN);  /* Synthesis Filters */	    /* Variable filter for LP synthesis */	    LP_Filt = makefilt_dynamic(ORDER, SF_LEN);	    /*  Variable filter for post filter */	    PostZ = makefilt_dynamic(ORDER, SF_LEN);	    PostZ2 = makefilt_dynamic(1, SF_LEN);	    PostP = makefilt_dynamic(ORDER, SF_LEN);	    /*  High Pass filter for output speech */	    OutputHPFZ = makefilt(InputHPFCoefsZ, 2, SF_LEN);	    OutputHPFP = makefilt(InputHPFCoefsP, 2, SF_LEN);	  }	}	return status;}/***************************************************************************                                                                         * ROUTINE*		CheckOptions** FUNCTION*		Check the options set by the user and insure that there*		are no problems.* SYNOPSIS*		CheckOptions(analysis, synthesis, channel_type, error_rate, *			write_chan, read_chan)**   formal**                       data    I/O*       name            type    type    function*       -------------------------------------------------------------------*	analysis	int	 i	Analysis flag*	synthesis	int	 i	Synthesis flag*	channel_type	int	 i	Channel Type flag*	error_rate	int	 i	Error Rate flag*	write_chan	int	 i	Write Channel flag*	read_chan	int	 i	Read Channel flag****************************************************************************/int CheckOptions(int	analysis, int	synthesis, int	channel_type, float	error_rate, int	write_chan, int	read_chan){int	status=ALL_VALID;/*  Insure that either analysis or synthesis is being performed */	if(!analysis && !synthesis)	{	  printf("*** Must run either analysis or synthesis or both ***\n");	  status = INVALID;	}/*  Insure that a channel file is written if no synthesis is being performed */	if(analysis && !synthesis && !write_chan)	{	  printf("*** Since there is no synthesis, a channel should be written ***\n");	  status = INVALID;	}/*  Insure that a chanel file is read if no analysis is being performed */	if(!analysis && !read_chan)	{	  printf("*** If analysis is not performed, a channel file must be read ***\n");	  status = INVALID;	}/*  Insure that analysis is not performed if a channel is being read */	if(read_chan && analysis)	{	  printf("*** Cannot perform analysis if a channel is being read ***\n");	  status = INVALID;	}/*  Cannot read and write a channel file */	if(read_chan && write_chan)	{	  printf("*** Cannot read AND write a channel file ***\n");	  status = INVALID;	}	return status;}

⌨️ 快捷键说明

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