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

📄 pcm.c

📁 Audacity是一款用於錄音和編輯聲音的、免費的開放源碼軟體。它可以執行於Mac OS X、Microsoft Windows、GNU/Linux和其它作業系統
💻 C
📖 第 1 页 / 共 5 页
字号:
			bufferlen = (int) len ;		convert (ptr + total, psf->u.sbuf, bufferlen, psf->norm_float) ;		writecount = psf_fwrite (psf->u.sbuf, sizeof (short), bufferlen, psf) ;		total += writecount ;		if (writecount < bufferlen)				break ;		len -= writecount ;		} ;	return total ;} /* pcm_write_f2bes *//*==============================================================================*/static voidf2les_array (float *src, short *dest, int count, int normalize){	unsigned char	*ucptr ;	float			normfact ;	int				value ;	normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ;	ucptr = ((unsigned char*) dest) + 2 * count ;	while (--count >= 0)	{	ucptr -= 2 ;		value = lrintf (src [count] * normfact) ;		ucptr [0] = value ;		ucptr [1] = value >> 8 ;		} ;} /* f2les_array */static voidf2les_clip_array (float *src, short *dest, int count, int normalize){	unsigned char	*ucptr ;	float			normfact, scaled_value ;	int				value ;	normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x10000) ;	ucptr = ((unsigned char*) dest) + 2 * count ;	while (--count >= 0)	{	ucptr -= 2 ;		scaled_value = src [count] * normfact ;		if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFFFFFF))		{	ucptr [0] = 0xFF ;			ucptr [1] = 0x7F ;			continue ;			} ;		if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x10000000))		{	ucptr [0] = 0x00 ;			ucptr [1] = 0x80 ;			continue ;			} ;		value = lrintf (scaled_value) ;		ucptr [0] = value >> 16 ;		ucptr [1] = value >> 24 ;		} ;} /* f2les_clip_array */static sf_count_tpcm_write_f2les	(SF_PRIVATE *psf, float *ptr, sf_count_t len){	void		(*convert) (float *, short *t, int, int) ;	int			bufferlen, writecount ;	sf_count_t	total = 0 ;	convert = (psf->add_clipping) ? f2les_clip_array : f2les_array ;	bufferlen = ARRAY_LEN (psf->u.sbuf) ;	while (len > 0)	{	if (len < bufferlen)			bufferlen = (int) len ;		convert (ptr + total, psf->u.sbuf, bufferlen, psf->norm_float) ;		writecount = psf_fwrite (psf->u.sbuf, sizeof (short), bufferlen, psf) ;		total += writecount ;		if (writecount < bufferlen)			break ;		len -= writecount ;		} ;	return total ;} /* pcm_write_f2les *//*==============================================================================*/static voidf2let_array (float *src, tribyte *dest, int count, int normalize){	unsigned char	*ucptr ;	float 			normfact ;	int				value ;	normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ;	ucptr = ((unsigned char*) dest) + 3 * count ;	while (--count >= 0)	{	ucptr -= 3 ;		value = lrintf (src [count] * normfact) ;		ucptr [0] = value ;		ucptr [1] = value >> 8 ;		ucptr [2] = value >> 16 ;		} ;} /* f2let_array */static voidf2let_clip_array (float *src, tribyte *dest, int count, int normalize){	unsigned char	*ucptr ;	float			normfact, scaled_value ;	int				value ;	normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ;	ucptr = ((unsigned char*) dest) + 3 * count ;	while (--count >= 0)	{	ucptr -= 3 ;		scaled_value = src [count] * normfact ;		if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFFFFFF))		{	ucptr [0] = 0xFF ;			ucptr [1] = 0xFF ;			ucptr [2] = 0x7F ;			continue ;			} ;		if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x10000000))		{	ucptr [0] = 0x00 ;			ucptr [1] = 0x00 ;			ucptr [2] = 0x80 ;			continue ;		} ;		value = lrintf (scaled_value) ;		ucptr [0] = value >> 8 ;		ucptr [1] = value >> 16 ;		ucptr [2] = value >> 24 ;		} ;} /* f2let_clip_array */static sf_count_tpcm_write_f2let	(SF_PRIVATE *psf, float *ptr, sf_count_t len){	void		(*convert) (float *, tribyte *, int, int) ;	int			bufferlen, writecount ;	sf_count_t	total = 0 ;	convert = (psf->add_clipping) ? f2let_clip_array : f2let_array ;	bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ;	while (len > 0)	{	if (len < bufferlen)			bufferlen = (int) len ;		convert (ptr + total, (tribyte*) (psf->u.ucbuf), bufferlen, psf->norm_float) ;		writecount = psf_fwrite (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ;		total += writecount ;		if (writecount < bufferlen)			break ;		len -= writecount ;		} ;	return total ;} /* pcm_write_f2let *//*==============================================================================*/static voidf2bet_array (float *src, tribyte *dest, int count, int normalize){	unsigned char	*ucptr ;	float 			normfact ;	int				value ;	normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ;	ucptr = ((unsigned char*) dest) + 3 * count ;	while (--count >= 0)	{	ucptr -= 3 ;		value = lrintf (src [count] * normfact) ;		ucptr [0] = value >> 16 ;		ucptr [1] = value >> 8 ;		ucptr [2] = value ;		} ;} /* f2bet_array */static voidf2bet_clip_array (float *src, tribyte *dest, int count, int normalize){	unsigned char	*ucptr ;	float			normfact, scaled_value ;	int				value ;	normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x100) ;	ucptr = ((unsigned char*) dest) + 3 * count ;	while (--count >= 0)	{	ucptr -= 3 ;		scaled_value = src [count] * normfact ;		if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFFFFFF))		{	ucptr [0] = 0x7F ;			ucptr [1] = 0xFF ;			ucptr [2] = 0xFF ;			continue ;			} ;		if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x10000000))		{	ucptr [0] = 0x80 ;			ucptr [1] = 0x00 ;			ucptr [2] = 0x00 ;			continue ;		} ;		value = lrint (scaled_value) ;		ucptr [0] = value >> 24 ;		ucptr [1] = value >> 16 ;		ucptr [2] = value >> 8 ;		} ;} /* f2bet_clip_array */static sf_count_tpcm_write_f2bet	(SF_PRIVATE *psf, float *ptr, sf_count_t len){	void		(*convert) (float *, tribyte *, int, int) ;	int			bufferlen, writecount ;	sf_count_t	total = 0 ;	convert = (psf->add_clipping) ? f2bet_clip_array : f2bet_array ;	bufferlen = sizeof (psf->u.ucbuf) / SIZEOF_TRIBYTE ;	while (len > 0)	{	if (len < bufferlen)			bufferlen = (int) len ;		convert (ptr + total, (tribyte*) (psf->u.ucbuf), bufferlen, psf->norm_float) ;		writecount = psf_fwrite (psf->u.ucbuf, SIZEOF_TRIBYTE, bufferlen, psf) ;		total += writecount ;		if (writecount < bufferlen)			break ;		len -= writecount ;		} ;	return total ;} /* pcm_write_f2bet *//*==============================================================================*/static voidf2bei_array (float *src, int *dest, int count, int normalize){	unsigned char	*ucptr ;	float			normfact ;	int				value ;	normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ;	ucptr = ((unsigned char*) dest) + 4 * count ;	while (--count >= 0)	{	ucptr -= 4 ;		value = lrintf (src [count] * normfact) ;		ucptr [0] = value >> 24 ;		ucptr [1] = value >> 16 ;		ucptr [2] = value >> 8 ;		ucptr [3] = value ;		} ;} /* f2bei_array */static voidf2bei_clip_array (float *src, int *dest, int count, int normalize){	unsigned char	*ucptr ;	float			normfact, scaled_value ;	int				value ;	normfact = normalize ? (8.0 * 0x10000000) : 1.0 ;	ucptr = ((unsigned char*) dest) + 4 * count ;	while (--count >= 0)	{	ucptr -= 4 ;		scaled_value = src [count] * normfact ;		if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= 1.0 * 0x7FFFFFFF)		{	ucptr [0] = 0x7F ;			ucptr [1] = 0xFF ;			ucptr [2] = 0xFF ;			ucptr [3] = 0xFF ;			continue ;			} ;		if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x10000000))		{	ucptr [0] = 0x80 ;			ucptr [1] = 0x00 ;			ucptr [2] = 0x00 ;			ucptr [3] = 0x00 ;			continue ;		} ;		value = lrintf (scaled_value) ;		ucptr [0] = value >> 24 ;		ucptr [1] = value >> 16 ;		ucptr [2] = value >> 8 ;		ucptr [3] = value ;		} ;} /* f2bei_clip_array */static sf_count_tpcm_write_f2bei	(SF_PRIVATE *psf, float *ptr, sf_count_t len){	void		(*convert) (float *, int *, int, int) ;	int			bufferlen, writecount ;	sf_count_t	total = 0 ;	convert = (psf->add_clipping) ? f2bei_clip_array : f2bei_array ;	bufferlen = ARRAY_LEN (psf->u.ibuf) ;	while (len > 0)	{	if (len < bufferlen)			bufferlen = (int) len ;		convert (ptr + total, psf->u.ibuf, bufferlen, psf->norm_float) ;		writecount = psf_fwrite (psf->u.ibuf, sizeof (int), bufferlen, psf) ;		total += writecount ;		if (writecount < bufferlen)			break ;		len -= writecount ;		} ;	return total ;} /* pcm_write_f2bei *//*==============================================================================*/static voidf2lei_array (float *src, int *dest, int count, int normalize){	unsigned char	*ucptr ;	float			normfact ;	int				value ;	normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ;	ucptr = ((unsigned char*) dest) + 4 * count ;	while (--count >= 0)	{	ucptr -= 4 ;		value = lrintf (src [count] * normfact) ;		ucptr [0] = value ;		ucptr [1] = value >> 8 ;		ucptr [2] = value >> 16 ;		ucptr [3] = value >> 24 ;		} ;} /* f2lei_array */static voidf2lei_clip_array (float *src, int *dest, int count, int normalize){	unsigned char	*ucptr ;	float			normfact, scaled_value ;	int				value ;	normfact = normalize ? (8.0 * 0x10000000) : 1.0 ;	ucptr = ((unsigned char*) dest) + 4 * count ;	while (--count >= 0)	{	ucptr -= 4 ;		scaled_value = src [count] * normfact ;		if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFFFFFF))		{	ucptr [0] = 0xFF ;			ucptr [1] = 0xFF ;			ucptr [2] = 0xFF ;			ucptr [3] = 0x7F ;			continue ;			} ;		if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x10000000))		{	ucptr [0] = 0x00 ;			ucptr [1] = 0x00 ;			ucptr [2] = 0x00 ;			ucptr [3] = 0x80 ;			continue ;			} ;		value = lrintf (scaled_value) ;		ucptr [0] = value ;		ucptr [1] = value >> 8 ;		ucptr [2] = value >> 16 ;		ucptr [3] = value >> 24 ;		} ;} /* f2lei_clip_array */static sf_count_tpcm_write_f2lei	(SF_PRIVATE *psf, float *ptr, sf_count_t len){	void		(*convert) (float *, int *, int, int) ;	int			bufferlen, writecount ;	sf_count_t	total = 0 ;	convert = (psf->add_clipping) ? f2lei_clip_array : f2lei_array ;	bufferlen = ARRAY_LEN (psf->u.ibuf) ;	while (len > 0)	{	if (len < bufferlen)			bufferlen = (int) len ;		convert (ptr + total, psf->u.ibuf, bufferlen, psf->norm_float) ;		writecount = psf_fwrite (psf->u.ibuf, sizeof (int), bufferlen, psf) ;		total += writecount ;		if (writecount < bufferlen)			break ;		len -= writecount ;		} ;	return total ;} /* pcm_write_f2lei *//*==============================================================================*/static voidd2sc_array	(double *src, signed char *dest, int count, int normalize){	double	normfact ;	normfact = normalize ? (1.0 * 0x7F) : 1.0 ;	while (--count >= 0)	{	dest [count] = lrint (src [count] * normfact) ;		} ;} /* d2sc_array */static voidd2sc_clip_array	(double *src, signed char *dest, int count, int normalize){	double	normfact, scaled_value ;	normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ;	while (--count >= 0)	{	scaled_value = src [count] * normfact ;		if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFFFFFF))		{	dest [count] = 127 ;			continue ;			} ;		if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x10000000))		{	dest [count] = -128 ;			continue ;			} ;		dest [count] = lrintf (scaled_value) >> 24 ;		} ;} /* d2sc_clip_array */static sf_count_tpcm_write_d2sc	(SF_PRIVATE *psf, double *ptr, sf_count_t len){	void		(*convert) (double *, signed char *, int, int) ;	int			bufferlen, writecount ;	sf_count_t	total = 0 ;	convert = (psf->add_clipping) ? d2sc_clip_array : d2sc_array ;	bufferlen = ARRAY_LEN (psf->u.scbuf) ;	while (len > 0)	{	if (len < bufferlen)			bufferlen = (int) len ;		convert (ptr + total, psf->u.scbuf, bufferlen, psf->norm_double) ;		writecount = psf_fwrite (psf->u.scbuf, sizeof (signed char), bufferlen, psf) ;		total += writecount ;		if (writecount < bufferlen)			break ;		len -= writecount ;		} ;	return total ;} /* pcm_write_d2sc *//*==============================================================================*/static	voidd2uc_array	(double *src, unsigned char *dest, int count, int normalize){	double normfact ;	normfact = normalize ? (1.0 * 0x7F) : 1.0 ;	while (--count >= 0)	{	dest [count] = lrint (src [count] * normfact) + 128 ;		} ;} /* d2uc_array */static	voidd2uc_clip_array	(double *src, unsigned char *dest, int count, int normalize){	double	normfact, scaled_value ;	normfact = normalize ? (8.0 * 0x10000000) : (1.0 * 0x1000000) ;	while (--count >= 0)	{	scaled_value = src [count] * normfact ;		if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFFFFFF))		{	dest [count] = 255 ;			continue ;			} ;		if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x10000000))		{	

⌨️ 快捷键说明

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