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

📄 pcm.c

📁 Vovida 社区开源的 SIP 协议源码
💻 C
📖 第 1 页 / 共 5 页
字号:
static intpcm_read_let2f (SF_PRIVATE *psf, float *ptr, int len){	unsigned int readcount, thisread ;	int		bytecount, bufferlen ;	int		index = 0, total = 0 ;	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;	bytecount = len * psf->bytewidth ;	while (bytecount > 0)	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;		thisread = fread (psf->buffer, 1, readcount, psf->file) ;		let2f_array ((tribyte*) (psf->buffer), thisread / psf->bytewidth, ptr, index, 1.0) ;		total += thisread ;		if (thisread < readcount)			break ;		index += thisread / psf->bytewidth ;		bytecount -= thisread ;		} ;	total /= psf->bytewidth ;	if (total < len)		psf->error = SFE_SHORT_READ ;		return total ;} /* pcm_read_let2f */static intpcm_read_bei2f (SF_PRIVATE *psf, float *ptr, int len){	unsigned int readcount, thisread ;	int		bytecount, bufferlen ;	int		index = 0, total = 0 ;	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;	bytecount = len * psf->bytewidth ;	while (bytecount > 0)	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;		thisread = fread (psf->buffer, 1, readcount, psf->file) ;		bei2f_array ((int*) (psf->buffer), thisread / psf->bytewidth, ptr, index, 1.0) ;		total += thisread ;		if (thisread < readcount)			break ;		index += thisread / psf->bytewidth ;		bytecount -= thisread ;		} ;	total /= psf->bytewidth ;	if (total < len)		psf->error = SFE_SHORT_READ ;		return total ;} /* pcm_read_bei2f */static intpcm_read_lei2f (SF_PRIVATE *psf, float *ptr, int len){	unsigned int readcount, thisread ;	int		bytecount, bufferlen ;	int		index = 0, total = 0 ;	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;	bytecount = len * psf->bytewidth ;	while (bytecount > 0)	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;		thisread = fread (psf->buffer, 1, readcount, psf->file) ;		lei2f_array ((int*) (psf->buffer), thisread / psf->bytewidth, ptr, index, 1.0) ;		total += thisread ;		if (thisread < readcount)			break ;		index += thisread / psf->bytewidth ;		bytecount -= thisread ;		} ;	total /= psf->bytewidth ;	if (total < len)		psf->error = SFE_SHORT_READ ;		return total ;} /* pcm_read_lei2f *//*-----------------------------------------------------------------------------------------------*/static intpcm_read_sc2d (SF_PRIVATE *psf, double *ptr, int len, int normalize){	unsigned int readcount, thisread ;	int		bytecount, bufferlen ;	int		index = 0, total = 0 ;	double		normfact ;	normfact = (normalize ? 1.0 / ((double) 0x80) : 1.0) ;	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;	bytecount = len * psf->bytewidth ;	while (bytecount > 0)	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;		thisread = fread (psf->buffer, 1, readcount, psf->file) ;		sc2d_array ((signed char*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;		total += thisread ;		if (thisread < readcount)			break ;		index += thisread / psf->bytewidth ;		bytecount -= thisread ;		} ;	total /= psf->bytewidth ;	if (total < len)		psf->error = SFE_SHORT_READ ;		return total ;} /* pcm_read_sc2d */static intpcm_read_uc2d (SF_PRIVATE *psf, double *ptr, int len, int normalize){	unsigned int readcount, thisread ;	int		bytecount, bufferlen ;	int		index = 0, total = 0 ;	double		normfact ;	normfact = (normalize ? 1.0 / ((double) 0x80) : 1.0) ;	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;	bytecount = len * psf->bytewidth ;	while (bytecount > 0)	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;		thisread = fread (psf->buffer, 1, readcount, psf->file) ;		uc2d_array ((unsigned char*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;		total += thisread ;		if (thisread < readcount)			break ;		index += thisread / psf->bytewidth ;		bytecount -= thisread ;		} ;	total /= psf->bytewidth ;	if (total < len)		psf->error = SFE_SHORT_READ ;		return total ;} /* pcm_read_uc2d */static intpcm_read_bes2d (SF_PRIVATE *psf, double *ptr, int len, int normalize){	unsigned int readcount, thisread ;	int		bytecount, bufferlen ;	int		index = 0, total = 0 ;	double		normfact ;	normfact = (normalize ? 1.0 / ((double) 0x8000) : 1.0) ;	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;	bytecount = len * psf->bytewidth ;	while (bytecount > 0)	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;		thisread = fread (psf->buffer, 1, readcount, psf->file) ;		bes2d_array ((short*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;		total += thisread ;		if (thisread < readcount)			break ;		index += thisread / psf->bytewidth ;		bytecount -= thisread ;		} ;	total /= psf->bytewidth ;	if (total < len)		psf->error = SFE_SHORT_READ ;		return total ;} /* pcm_read_bes2d */static intpcm_read_les2d (SF_PRIVATE *psf, double *ptr, int len, int normalize){	unsigned int readcount, thisread ;	int		bytecount, bufferlen ;	int		index = 0, total = 0 ;	double		normfact ;	normfact = (normalize ? 1.0 / ((double) 0x8000) : 1.0) ;	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;	bytecount = len * psf->bytewidth ;	while (bytecount > 0)	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;		thisread = fread (psf->buffer, 1, readcount, psf->file) ;		les2d_array ((short*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;		total += thisread ;		if (thisread < readcount)			break ;		index += thisread / psf->bytewidth ;		bytecount -= thisread ;		} ;	total /= psf->bytewidth ;	if (total < len)		psf->error = SFE_SHORT_READ ;		return total ;} /* pcm_read_les2d */static intpcm_read_bet2d (SF_PRIVATE *psf, double *ptr, int len, int normalize){	unsigned int readcount, thisread ;	int		bytecount, bufferlen ;	int		index = 0, total = 0 ;	double		normfact ;	normfact = (normalize ? 1.0 / ((double) 0x800000) : 1.0) ;	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;	bytecount = len * psf->bytewidth ;	while (bytecount > 0)	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;		thisread = fread (psf->buffer, 1, readcount, psf->file) ;		bet2d_array ((tribyte*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;		total += thisread ;		if (thisread < readcount)			break ;		index += thisread / psf->bytewidth ;		bytecount -= thisread ;		} ;	total /= psf->bytewidth ;	if (total < len)		psf->error = SFE_SHORT_READ ;		return total ;} /* pcm_read_bet2d */static intpcm_read_let2d (SF_PRIVATE *psf, double *ptr, int len, int normalize){	unsigned int readcount, thisread ;	int		bytecount, bufferlen ;	int		index = 0, total = 0 ;	double		normfact ;	normfact = (normalize ? 1.0 / ((double) 0x800000) : 1.0) ;	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;	bytecount = len * psf->bytewidth ;	while (bytecount > 0)	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;		thisread = fread (psf->buffer, 1, readcount, psf->file) ;		let2d_array ((tribyte*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;		total += thisread ;		if (thisread < readcount)			break ;		index += thisread / psf->bytewidth ;		bytecount -= thisread ;		} ;	total /= psf->bytewidth ;	if (total < len)		psf->error = SFE_SHORT_READ ;		return total ;} /* pcm_read_let2d */static intpcm_read_bei2d (SF_PRIVATE *psf, double *ptr, int len, int normalize){	unsigned int readcount, thisread ;	int		bytecount, bufferlen ;	int		index = 0, total = 0 ;	double		normfact ;	normfact = (normalize ? 1.0 / ((double) 0x80000000) : 1.0) ;	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;	bytecount = len * psf->bytewidth ;	while (bytecount > 0)	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;		thisread = fread (psf->buffer, 1, readcount, psf->file) ;		bei2d_array ((int*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;		total += thisread ;		if (thisread < readcount)			break ;		index += thisread / psf->bytewidth ;		bytecount -= thisread ;		} ;	total /= psf->bytewidth ;	if (total < len)		psf->error = SFE_SHORT_READ ;		return total ;} /* pcm_read_bei2d */static intpcm_read_lei2d (SF_PRIVATE *psf, double *ptr, int len, int normalize){	unsigned int readcount, thisread ;	int		bytecount, bufferlen ;	int		index = 0, total = 0 ;	double		normfact ;	normfact = (normalize ? 1.0 / ((double) 0x80000000) : 1.0) ;	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;	bytecount = len * psf->bytewidth ;	while (bytecount > 0)	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;		thisread = fread (psf->buffer, 1, readcount, psf->file) ;		lei2d_array ((int*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;		total += thisread ;		if (thisread < readcount)			break ;		index += thisread / psf->bytewidth ;		bytecount -= thisread ;		} ;	total /= psf->bytewidth ;	if (total < len)		psf->error = SFE_SHORT_READ ;		return total ;} /* pcm_read_lei2d *//*===============================================================================================**-----------------------------------------------------------------------------------------------**===============================================================================================*/static intpcm_write_s2sc	(SF_PRIVATE *psf, short *ptr, int len){	unsigned int	writecount, thiswrite ;	int	bytecount, bufferlen ;	int		index = 0, total = 0 ;	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;	bytecount = len * psf->bytewidth ;	while (bytecount > 0)	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;		s2sc_array (ptr, index, (signed char*) (psf->buffer), writecount / psf->bytewidth) ;		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;		total += thiswrite ;		if (thiswrite < writecount)			break ;		index += thiswrite / psf->bytewidth ;		bytecount -= thiswrite ;		} ;	total /= psf->bytewidth ;	if (total < len)		psf->error = SFE_SHORT_WRITE ;		return total ;} /* pcm_write_s2sc */static intpcm_write_s2uc	(SF_PRIVATE *psf, short *ptr, int len){	unsigned int	writecount, thiswrite ;	int	bytecount, bufferlen ;	int		index = 0, total = 0 ;	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;	bytecount = len * psf->bytewidth ;	while (bytecount > 0)	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;		s2uc_array (ptr, index, (unsigned char*) (psf->buffer), writecount / psf->bytewidth) ;		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;		total += thiswrite ;		if (thiswrite < writecount)			break ;		index += thiswrite / psf->bytewidth ;		bytecount -= thiswrite ;		} ;	total /= psf->bytewidth ;	if (total < len)		psf->error = SFE_SHORT_WRITE ;		return total ;} /* pcm_write_s2uc */static intpcm_write_s2bes	(SF_PRIVATE *psf, short *ptr, int len){	int		total ;	if (CPU_IS_LITTLE_ENDIAN)		endswap_short_array (ptr, len) ;	total = fwrite (ptr, 1, len * sizeof (short), psf->file) ;	if (CPU_IS_LITTLE_ENDIAN)		endswap_short_array (ptr, len) ;	total /= psf->bytewidth ;	if (total < len)		psf->error = SFE_SHORT_WRITE ;		return total ;} /* pcm_write_s2bes */static intpcm_write_s2les	(SF_PRIVATE *psf, short *ptr, int len){	int		total ;	if (CPU_IS_BIG_ENDIAN)		endswap_short_array (ptr, len) ;	total = fwrite (ptr, 1, len * sizeof (short), psf->file) ;	if (CPU_IS_BIG_ENDIAN)		endswap_short_array (ptr, len) ;	total /= psf->bytewidth ;	if (total < len)		psf->error = SFE_SHORT_WRITE ;		return total ;} /* pcm_write_s2les */static intpcm_write_s2bet	(SF_PRIVATE *psf, short *ptr, int len){	unsigned int	writecount, thiswrite ;	int	bytecount, bufferlen ;

⌨️ 快捷键说明

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