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

📄 demux.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 2 页
字号:
			input_sf;	if(debug_level) {		Fprintf(stderr,"Output start_time: ");		for(i=0; i<num_channels;i++)			Fprintf(stderr,"%g ",in_start_time[i]);		Fprintf(stderr,"\n");	}			if(!Sflag) {		out_type = input_type;	}else {		switch (input_type){		case DOUBLE_CPLX:			out_type=DOUBLE;			break;		case FLOAT_CPLX:			out_type=FLOAT;			break;		case LONG_CPLX:			out_type=LONG;			break;		case SHORT_CPLX:			out_type=SHORT;			break;		case BYTE_CPLX:			out_type=BYTE;			break;		default:			fprintf(stderr,			 "demux: invalid input data type with -S option.\n");			exit(1);		}	}	if(debug_level) {		Fprintf(stderr,"Input File: %s\n",input_file);		Fprintf(stderr,"Number of channels: %d\n  ",num_channels);		for(i=0;i<num_channels;i++)			Fprintf(stderr,"%d ",channels[i]);		Fprintf(stderr,"\n");		Fprintf(stderr,"Prototype: %s\n",prototype);		Fprintf(stderr,"Range: %s\n",r_range);		Fprintf(stderr,"Sflag: %d\n",Sflag);		Fprintf(stderr,"param_file: %s\n",param_file);		Fprintf(stderr,"start_point: %d, end_point: %d\n",			start_point, end_point);		Fprintf(stderr,"Out Files: ");		for(i=0;i<num_out_files;i++)			Fprintf(stderr,"%s ",ofile[i]);		Fprintf(stderr,"\n");	}	oh = (struct header **)calloc((unsigned)num_channels,sizeof(struct header *));	out_fd = (FILE **)calloc((unsigned)num_channels,sizeof(FILE *));	for(i=0;i<num_out_files;i++) {		ofile[i] = eopen(ProgName,ofile[i],"w",FT_FEA,FEA_SD,			&oh[i], &out_fd[i]);		oh[i] = new_header(FT_FEA);			(void)copy_genhd(oh[i],ih,NULL);		if(init_feasd_hd(oh[i],out_type,(long)num_channels_file,			in_start_time,YES,input_sf)){			ERROR_EXIT("error creating output header");		}		add_source_file(oh[i],input_file,ih);		add_comment (oh[i], get_cmd_line(argc, argv));		(void) strcpy (oh[i] ->common.prog, ProgName);		(void) strcpy (oh[i] ->common.vers, Version);		(void) strcpy (oh[i] ->common.progdate, Date);		write_header(oh[i],out_fd[i]);	}	fea_skiprec(in_fd,start_point-1,ih);	in_feasd = allo_feasd_recs(ih,input_type,(long)BUFSIZ,NULL,YES);	out_feasd = (struct feasd **)calloc((unsigned)num_out_files,			sizeof(struct feasd *));	if(num_out_files == 1) {		long to_read, total_recs;	        long total_read = 0;		short **s_ptr_i = (short **)in_feasd->ptrs;		long **l_ptr_i = (long **)in_feasd->ptrs;		float **f_ptr_i = (float **)in_feasd->ptrs;		double **d_ptr_i = (double **)in_feasd->ptrs;		char **c_ptr_i = (char **)in_feasd->ptrs;		long_cplx **lc_ptr_i = (long_cplx **)in_feasd->ptrs;		float_cplx **fc_ptr_i = (float_cplx **)in_feasd->ptrs;		double_cplx **dc_ptr_i = (double_cplx **)in_feasd->ptrs;		short_cplx **sc_ptr_i = (short_cplx **)in_feasd->ptrs;		byte_cplx **bc_ptr_i = (byte_cplx **)in_feasd->ptrs;		short **s_ptr_o;  short_cplx **sc_ptr_o;		long **l_ptr_o;	  long_cplx **lc_ptr_o;		float **f_ptr_o;  float_cplx **fc_ptr_o;		double **d_ptr_o; double_cplx **dc_ptr_o;		char **c_ptr_o;	  byte_cplx **bc_ptr_o;		int k=typesiz(out_type);		*out_feasd = allo_feasd_recs(oh[0],out_type,(long)BUFSIZ,			NULL,YES);		s_ptr_o = (short **)out_feasd[0]->ptrs;		l_ptr_o = (long **)out_feasd[0]->ptrs;		f_ptr_o = (float **)out_feasd[0]->ptrs;		d_ptr_o = (double **)out_feasd[0]->ptrs;		c_ptr_o = (char **)out_feasd[0]->ptrs;		sc_ptr_o = (short_cplx **)out_feasd[0]->ptrs;		lc_ptr_o = (long_cplx **)out_feasd[0]->ptrs;		fc_ptr_o = (float_cplx **)out_feasd[0]->ptrs;		dc_ptr_o = (double_cplx **)out_feasd[0]->ptrs;		bc_ptr_o = (byte_cplx **)out_feasd[0]->ptrs;		total_recs = end_point-start_point+1;		if (total_recs < BUFSIZ) 			to_read = total_recs; 		else			to_read = BUFSIZ;		while(nread=get_feasd_recs(in_feasd,0L,to_read, ih,in_fd)){			total_read += nread;			if (total_read + to_read > total_recs) {				to_read = total_recs-total_read;			}			for (i=0; i<nread; i++) {			  int j;			  switch (out_type) {			    case DOUBLE:			      for(j=0; j<num_channels; j++) 			        d_ptr_o[i][j] = d_ptr_i[i][channels[j]];			      break;			    case FLOAT:			      for(j=0; j<num_channels; j++) 			        f_ptr_o[i][j] = f_ptr_i[i][channels[j]];			      break;			    case LONG:			      for(j=0; j<num_channels; j++) 			        l_ptr_o[i][j] = l_ptr_i[i][channels[j]];			      break;			    case SHORT:			      for(j=0; j<num_channels; j++) 			        s_ptr_o[i][j] = s_ptr_i[i][channels[j]];			      break;			    case BYTE:			      for(j=0; j<num_channels; j++) 			        c_ptr_o[i][j] = c_ptr_i[i][channels[j]];			      break;			    case DOUBLE_CPLX:			      for(j=0; j<num_channels; j++) 			        dc_ptr_o[i][j] = dc_ptr_i[i][channels[j]];			      break;			    case FLOAT_CPLX:			      for(j=0; j<num_channels; j++) 			        fc_ptr_o[i][j] = fc_ptr_i[i][channels[j]];			      break;			    case LONG_CPLX:			      for(j=0; j<num_channels; j++) 			        lc_ptr_o[i][j] = lc_ptr_i[i][channels[j]];			      break;			    case SHORT_CPLX:			      for(j=0; j<num_channels; j++) 			        sc_ptr_o[i][j] = sc_ptr_i[i][channels[j]];			      break;			    case BYTE_CPLX:			      for(j=0; j<num_channels; j++) 			        bc_ptr_o[i][j] = bc_ptr_i[i][channels[j]];			      break;			    default:			      spsassert(0,"unkown type in switch");			  }			}		        if(put_feasd_recs(out_feasd[0],0L,nread,			     oh[0], out_fd[0]))					ERROR_EXIT("error writing out file");		if (to_read == 0) break;		}	}	else if(num_out_files == num_channels){		long to_read, total_recs;		int k=typesiz(out_type);		short **s_ptr = (short **)in_feasd->ptrs, *s_data;		long **l_ptr = (long **)in_feasd->ptrs, *l_data;		float **f_ptr = (float **)in_feasd->ptrs, *f_data;		double **d_ptr = (double **)in_feasd->ptrs, *d_data;		char **c_ptr = (char **)in_feasd->ptrs, *c_data;		short_cplx **sc_ptr = (short_cplx **)in_feasd->ptrs, *sc_data;		long_cplx **lc_ptr = (long_cplx **)in_feasd->ptrs, *lc_data;		float_cplx **fc_ptr = (float_cplx **)in_feasd->ptrs, *fc_data;		double_cplx **dc_ptr = (double_cplx **)in_feasd->ptrs, *dc_data;		byte_cplx **bc_ptr = (byte_cplx **)in_feasd->ptrs, *bc_data;	        long total_read = 0;		for(i=0;i<num_out_files;i++)			out_feasd[i]=allo_feasd_recs(oh[i],out_type,				(long)BUFSIZ,NULL,NO);		total_recs = end_point-start_point+1;		if (total_recs < BUFSIZ) 			to_read = total_recs; 		else			to_read = BUFSIZ;		while(nread=get_feasd_recs(in_feasd,0L,to_read, ih,in_fd)){			total_read += nread;			if (total_read + to_read > total_recs) {				to_read = total_recs-total_read;			}			for (i=0; i<num_out_files; i++) {			  int j;			  switch (out_type) {			    case DOUBLE:			      d_data   = (double *)out_feasd[i]->data;			      for(j=0; j<nread; j++) 			        d_data[j] = d_ptr[j][channels[i]];			      break;			    case FLOAT:			      f_data   = (float *)out_feasd[i]->data;			      for(j=0; j<nread; j++) 			        f_data[j] = f_ptr[j][channels[i]];			      break;			    case LONG:			      l_data   = (long *)out_feasd[i]->data;			      for(j=0; j<nread; j++) 			        l_data[j] = l_ptr[j][channels[i]];			      break;			    case SHORT:			      s_data   = (short *)out_feasd[i]->data;			      for(j=0; j<nread; j++) 			        s_data[j] = s_ptr[j][channels[i]];			      break;			    case BYTE:			      c_data   = (char *)out_feasd[i]->data;			      for(j=0; j<nread; j++) 			        c_data[j] = c_ptr[j][channels[i]];			      break;			    case DOUBLE_CPLX:			      dc_data   = (double_cplx *)out_feasd[i]->data;			      for(j=0; j<nread; j++) 			        dc_data[j] = dc_ptr[j][channels[i]];			      break;			    case FLOAT_CPLX:			      fc_data   = (float_cplx *)out_feasd[i]->data;			      for(j=0; j<nread; j++) 			        fc_data[j] = fc_ptr[j][channels[i]];			      break;			    case LONG_CPLX:			      lc_data   = (long_cplx *)out_feasd[i]->data;			      for(j=0; j<nread; j++) 			        lc_data[j] = lc_ptr[j][channels[i]];			      break;			    case SHORT_CPLX:			      sc_data   = (short_cplx *)out_feasd[i]->data;			      for(j=0; j<nread; j++) 			        sc_data[j] = sc_ptr[j][channels[i]];			      break;			    case BYTE_CPLX:			      bc_data   = (byte_cplx *)out_feasd[i]->data;			      for(j=0; j<nread; j++) 			        bc_data[j] = bc_ptr[j][channels[i]];			      break;			    default:			      spsassert(0,"unkown type in switch");			  }			  if(put_feasd_recs(out_feasd[i],0L,nread,			     oh[i], out_fd[i]))					ERROR_EXIT("error writing out file");			}		if (to_read == 0) break;		}	}					return 0;		}longget_chans(hd)struct header *hd;{	return get_fea_siz("samples",hd,(short *)NULL, (long **)NULL);}

⌨️ 快捷键说明

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