miio.c

来自「speech signal process tools」· C语言 代码 · 共 1,388 行 · 第 1/3 页

C
1,388 行
字号
		  return 0;	  }	 return i;	}}intmiio_put_float(ptr, n, flag, fp)float *ptr;int n;int flag;FILE *fp;{	int i=n;	spsassert(ptr, "miio_put_float: ptr is NULL");		spsassert(fp,  "miio_put_float: fp is NULL");	spsassert(n >= 0, "miio_put_float: n not > 0");	spsassert(flag == 0 || flag == 1, "miio_put_float: bad flag");	if (n == 0) return(0);	if (flag == NO)	/* no need to translate */		return (fwrite((char *)ptr, sizeof(*ptr), n, fp));	else { 		/* translate from EDR */	 while (n--) {		u2.f_val = *ptr++;		if (fwrite(&u2.byte[3], 1, 1, fp) != 1)		  return 0;		if (fwrite(&u2.byte[2], 1, 1, fp) != 1)		  return 0;		if (fwrite(&u2.byte[1], 1, 1, fp) != 1)		  return 0;		if (fwrite(&u2.byte[0], 1, 1, fp) != 1)		  return 0;	  }	 return i;	}}intmiio_put_int(ptr, n, flag, fp)int *ptr;int n;int flag;FILE *fp;{	int i=n;	spsassert(ptr, "miio_put_int: ptr is NULL");		spsassert(fp,  "miio_put_int: fp is NULL");	spsassert(n >= 0, "miio_put_int: n not > 0");	spsassert(flag == 0 || flag == 1, "miio_put_int: bad flag");	if (n == 0) return(0);	if (flag == NO)	/* no need to translate */		return (fwrite((char *)ptr, sizeof(*ptr), n, fp));	else { 		/* translate from EDR */	 while (n--) {		u2.l_val = *ptr++;		if (fwrite(&u2.byte[3], 1, 1, fp) != 1)		  return 0;		if (fwrite(&u2.byte[2], 1, 1, fp) != 1)		  return 0;		if (fwrite(&u2.byte[1], 1, 1, fp) != 1)		  return 0;		if (fwrite(&u2.byte[0], 1, 1, fp) != 1)		  return 0;	  }	 return i;	}}intmiio_put_long(ptr, n, flag, fp)long *ptr;int n;int flag;FILE *fp;{	int i=n;	spsassert(ptr, "miio_put_long: ptr is NULL");		spsassert(fp,  "miio_put_long: fp is NULL");	spsassert(n >= 0, "miio_put_long: n not > 0");	spsassert(flag == 0 || flag == 1, "miio_put_long: bad flag");	if (n == 0) return(0);	if (flag == NO)	/* no need to translate */		return (fwrite((char *)ptr, sizeof(*ptr), n, fp));	else { 		/* translate from EDR */	 while (n--) {		u2.l_val = *ptr++;		if (fwrite(&u2.byte[3], 1, 1, fp) != 1)		  return 0;		if (fwrite(&u2.byte[2], 1, 1, fp) != 1)		  return 0;		if (fwrite(&u2.byte[1], 1, 1, fp) != 1)		  return 0;		if (fwrite(&u2.byte[0], 1, 1, fp) != 1)		  return 0;	  }	 return i;	}}intmiio_put_short(ptr, n, flag, fp)short *ptr;int n;int flag;FILE *fp;{	int i=n;	spsassert(ptr, "miio_put_short: ptr is NULL");		spsassert(fp,  "miio_put_short: fp is NULL");	spsassert(n >= 0, "miio_put_short: n not > 0");	spsassert(flag == 0 || flag == 1, "miio_put_short: bad flag");	if (n == 0) return(0);	if (flag == NO)	/* no need to translate */		return (fwrite((char *)ptr, sizeof(*ptr), n, fp));	else { 		/* translate from EDR */	 while (n--) {		u3.s_val = *ptr++;		if (fwrite(&u3.byte[1], 1, 1, fp) != 1)		  return 0;		if (fwrite(&u3.byte[0], 1, 1, fp) != 1)		  return 0;	  }	 return i;	}}intmiio_put_char(ptr, n, flag, fp)char *ptr;int n;int flag;FILE *fp;{	spsassert(ptr, "miio_put_char: ptr is NULL");		spsassert(fp,  "miio_put_char: fp is NULL");	spsassert(n >= 0, "miio_put_char: n not > 0");	spsassert(flag == 0 || flag == 1, "miio_put_char: bad flag");	if (n == 0) return(0);	return (fwrite((char *)ptr, sizeof(*ptr), n, fp));}intmiio_put_byte(ptr, n, flag, fp)char *ptr;int n;int flag;FILE *fp;{	spsassert(ptr, "miio_put_byte: ptr is NULL");		spsassert(fp,  "miio_put_byte: fp is NULL");	spsassert(n >= 0, "miio_put_byte: n not > 0");	spsassert(flag == 0 || flag == 1, "miio_put_byte: bad flag");	if (n == 0) return(0);	return (fwrite((char *)ptr, sizeof(*ptr), n, fp));}#endifint miio_get_dcplx(ptr, n, flag, mach, fp)double_cplx *ptr;int n;int flag;int mach;FILE *fp;{	int item_count = 0;	spsassert(ptr, "miio_get_dcplx: ptr is NULL");	spsassert(fp,  "miio_get_dcplx: fp is NULL");	spsassert(n >= 0, "miio_get_dcplx: n not > 0");	spsassert(flag == NO || flag == YES, "miio_get_dcplx: bad flag");	if (n == 0) return 0;	while (n--) {		if (miio_get_double(&ptr->real, 1, flag, mach, fp) != 1)			break;		if (miio_get_double(&ptr->imag, 1, flag, mach, fp) != 1)			miio_input_error("dcplx");		ptr++;		item_count++;	}	return item_count;}int miio_get_fcplx(ptr, n, flag, mach, fp)float_cplx *ptr;int n;int flag;int mach;FILE *fp;{	int item_count = 0;	spsassert(ptr, "miio_get_fcplx: ptr is NULL");	spsassert(fp,  "miio_get_fcplx: fp is NULL");	spsassert(n >= 0, "miio_get_fcplx: n not > 0");	spsassert(flag == NO || flag == YES, "miio_get_fcplx: bad flag");	if (n == 0) return 0;	while (n--) {		if (miio_get_float(&ptr->real, 1, flag, mach, fp) != 1)			break;		if (miio_get_float(&ptr->imag, 1, flag, mach, fp) != 1)			miio_input_error("fcplx");		ptr++;		item_count++;	}	return item_count;}int miio_get_lcplx(ptr, n, flag, mach, fp)long_cplx *ptr;int n;int flag;int mach;FILE *fp;{	int item_count = 0;	spsassert(ptr, "miio_get_lcplx: ptr is NULL");	spsassert(fp,  "miio_get_lcplx: fp is NULL");	spsassert(n >= 0, "miio_get_lcplx: n not > 0");	spsassert(flag == NO || flag == YES, "miio_get_lcplx: bad flag");	if (n == 0) return 0;	while (n--) {		if (miio_get_long(&ptr->real, 1, flag, mach, fp) != 1)			break;		if (miio_get_long(&ptr->imag, 1, flag, mach, fp) != 1)			miio_input_error("lcplx");		ptr++;		item_count++;	}	return item_count;}int miio_get_scplx(ptr, n, flag, mach, fp)short_cplx *ptr;int n;int flag;int mach;FILE *fp;{	int item_count = 0;	spsassert(ptr, "miio_get_scplx: ptr is NULL");	spsassert(fp,  "miio_get_scplx: fp is NULL");	spsassert(n >= 0, "miio_get_scplx: n not > 0");	spsassert(flag == NO || flag == YES, "miio_get_scplx: bad flag");	if (n == 0) return 0;	while (n--) {		if (miio_get_short(&ptr->real, 1, flag, mach, fp) != 1)			break;		if (miio_get_short(&ptr->imag, 1, flag, mach, fp) != 1)			miio_input_error("scplx");		ptr++;		item_count++;	}	return item_count;}int miio_get_bcplx(ptr, n, flag, mach, fp)byte_cplx *ptr;int n;int flag;int mach;FILE *fp;{	int item_count = 0;	spsassert(ptr, "miio_get_bcplx: ptr is NULL");	spsassert(fp,  "miio_get_bcplx: fp is NULL");	spsassert(n >= 0, "miio_get_bcplx: n not > 0");	spsassert(flag == NO || flag == YES, "miio_get_bcplx: bad flag");	if (n == 0) return 0;	while (n--) {		if (miio_get_byte(&ptr->real, 1, flag, mach, fp) != 1)			break;		if (miio_get_byte(&ptr->imag, 1, flag, mach, fp) != 1)			miio_input_error("bcplx");		ptr++;		item_count++;	}	return item_count;}intmiio_put_dcplx(ptr, n, flag, fp)double_cplx *ptr;int n;int flag;FILE *fp;{	int i=n;		spsassert(ptr, "miio_put_dcplx: ptr is NULL");	spsassert(fp, "miio_put_dcplx: fp is NULL");	spsassert(n >= 0, "miio_put_dcplx: n not > 0");	spsassert(flag == 0 || flag == 1, "miio_put_dcplx: bad flag");	if (n == 0) return 0;	while (n--) {		if(miio_put_double(&ptr->real, 1, flag, fp) != 1)			return 0;		if(miio_put_double(&ptr->imag, 1, flag, fp) != 1)			return 0;		ptr++;	}	return i;}intmiio_put_fcplx(ptr, n, flag, fp)float_cplx *ptr;int n;int flag;FILE *fp;{	int i=n;		spsassert(ptr, "miio_put_fcplx: ptr is NULL");	spsassert(fp, "miio_put_fcplx: fp is NULL");	spsassert(n >= 0, "miio_put_fcplx: n not > 0");	spsassert(flag == 0 || flag == 1, "miio_put_fcplx: bad flag");	if (n == 0) return 0;	while (n--) {		if(miio_put_float(&ptr->real, 1, flag, fp) != 1)			return 0;		if(miio_put_float(&ptr->imag, 1, flag, fp) != 1)			return 0;		ptr++;	}	return i;}intmiio_put_lcplx(ptr, n, flag, fp)long_cplx *ptr;int n;int flag;FILE *fp;{	int i=n;		spsassert(ptr, "miio_put_lcplx: ptr is NULL");	spsassert(fp, "miio_put_lcplx: fp is NULL");	spsassert(n >= 0, "miio_put_lcplx: n not > 0");	spsassert(flag == 0 || flag == 1, "miio_put_lcplx: bad flag");	if (n == 0) return 0;	while (n--) {		if(miio_put_long(&ptr->real, 1, flag, fp) != 1)			return 0;		if(miio_put_long(&ptr->imag, 1, flag, fp) != 1)			return 0;		ptr++;	}	return i;}intmiio_put_scplx(ptr, n, flag, fp)short_cplx *ptr;int n;int flag;FILE *fp;{	int i=n;		spsassert(ptr, "miio_put_scplx: ptr is NULL");	spsassert(fp, "miio_put_scplx: fp is NULL");	spsassert(n >= 0, "miio_put_scplx: n not > 0");	spsassert(flag == 0 || flag == 1, "miio_put_scplx: bad flag");	if (n == 0) return 0;	while (n--) {		if(miio_put_short(&ptr->real, 1, flag, fp) != 1)			return 0;		if(miio_put_short(&ptr->imag, 1, flag, fp) != 1)			return 0;		ptr++;	}	return i;}intmiio_put_bcplx(ptr, n, flag, fp)byte_cplx *ptr;int n;int flag;FILE *fp;{	int i=n;		spsassert(ptr, "miio_put_bcplx: ptr is NULL");	spsassert(fp, "miio_put_bcplx: fp is NULL");	spsassert(n >= 0, "miio_put_bcplx: n not > 0");	spsassert(flag == 0 || flag == 1, "miio_put_bcplx: bad flag");	if (n == 0) return 0;	while (n--) {		if(miio_put_byte(&ptr->real, 1, flag, fp) != 1)			return 0;		if(miio_put_byte(&ptr->imag, 1, flag, fp) != 1)			return 0;		ptr++;	}	return i;}

⌨️ 快捷键说明

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