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

📄 au_g72x.c

📁 Audacity是一款用於錄音和編輯聲音的、免費的開放源碼軟體。它可以執行於Mac OS X、Microsoft Windows、GNU/Linux和其它作業系統
💻 C
📖 第 1 页 / 共 2 页
字号:
	{	readcount = (len >= bufferlen) ? bufferlen : len ;		count = au_g72x_read_block (psf, pg72x, sptr, readcount) ;		for (k = 0 ; k < readcount ; k++)			ptr [total + k] = normfact * sptr [k] ;		total += count ;		len -= readcount ;		if (count != readcount)			break ;		} ;	return total ;} /* au_g72x_read_f */static sf_count_tau_g72x_read_d	(SF_PRIVATE *psf, double *ptr, sf_count_t len){	G72x_DATA *pg72x ;	short		*sptr ;	int			k, bufferlen, readcount = 0, count ;	sf_count_t	total = 0 ;	double		normfact ;	if (! psf->fdata)		return 0 ;	pg72x = (G72x_DATA*) psf->fdata ;	normfact = (psf->norm_double == SF_TRUE) ? 1.0 / ((double) 0x8000) : 1.0 ;	sptr = psf->u.sbuf ;	bufferlen = SF_BUFFER_LEN / sizeof (short) ;	while (len > 0)	{	readcount = (len >= bufferlen) ? bufferlen : len ;		count = au_g72x_read_block (psf, pg72x, sptr, readcount) ;		for (k = 0 ; k < readcount ; k++)			ptr [total + k] = normfact * (double) (sptr [k]) ;		total += count ;		len -= readcount ;		if (count != readcount)			break ;		} ;	return total ;} /* au_g72x_read_d */static sf_count_tau_g72x_seek	(SF_PRIVATE *psf, int mode, sf_count_t offset){	/* Prevent compiler warnings. */	mode ++ ;	offset ++ ;	psf_log_printf (psf, "seek unsupported\n") ;	/*	No simple solution. To do properly, would need to seek	**	to start of file and decode everything up to seek position.	**	Maybe implement SEEK_SET to 0 only?	*/	return 0 ;/***		G72x_DATA	*pg72x ;**		int			newblock, newsample, samplecount ;****		if (! psf->fdata)**			return 0 ;**		pg72x = (G72x_DATA*) psf->fdata ;****		if (! (psf->datalength && psf->dataoffset))**		{	psf->error = SFE_BAD_SEEK ;**			return	((sf_count_t) -1) ;**			} ;****		samplecount = (8 * psf->datalength) / G721_32_BITS_PER_SAMPLE ;****		switch (whence)**		{	case SEEK_SET :**					if (offset < 0 || offset > samplecount)**					{	psf->error = SFE_BAD_SEEK ;**						return	((sf_count_t) -1) ;**						} ;**					newblock  = offset / pg72x->samplesperblock ;**					newsample = offset % pg72x->samplesperblock ;**					break ;****			case SEEK_CUR :**					if (psf->current + offset < 0 || psf->current + offset > samplecount)**					{	psf->error = SFE_BAD_SEEK ;**						return	((sf_count_t) -1) ;**						} ;**					newblock  = (8 * (psf->current + offset)) / pg72x->samplesperblock ;**					newsample = (8 * (psf->current + offset)) % pg72x->samplesperblock ;**					break ;****			case SEEK_END :**					if (offset > 0 || samplecount + offset < 0)**					{	psf->error = SFE_BAD_SEEK ;**						return	((sf_count_t) -1) ;**						} ;**					newblock  = (samplecount + offset) / pg72x->samplesperblock ;**					newsample = (samplecount + offset) % pg72x->samplesperblock ;**					break ;****			default :**					psf->error = SFE_BAD_SEEK ;**					return	((sf_count_t) -1) ;**			} ;****		if (psf->mode == SFM_READ)**		{	psf_fseek (psf, psf->dataoffset + newblock * pg72x->blocksize, SEEK_SET) ;**			pg72x->blockcount  = newblock ;**			au_g72x_decode_block (psf, pg72x) ;**			pg72x->samplecount = newsample ;**			}**		else**		{	/+* What to do about write??? *+/**			psf->error = SFE_BAD_SEEK ;**			return	((sf_count_t) -1) ;**			} ;****		psf->current = newblock * pg72x->samplesperblock + newsample ;**		return psf->current ;***/} /* au_g72x_seek *//*==========================================================================================** G72x Write Functions.*/static intau_g72x_encode_block	(SF_PRIVATE *psf, G72x_DATA *pg72x){	int k ;	/* Encode the samples. */	g72x_encode_block (pg72x) ;	/* Write the block to disk. */	if ((k = psf_fwrite (pg72x->block, 1, pg72x->blocksize, psf)) != pg72x->blocksize)		psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, pg72x->blocksize) ;	pg72x->samplecount = 0 ;	pg72x->blockcount ++ ;	/* Set samples to zero for next block. */	memset (pg72x->samples, 0, G72x_BLOCK_SIZE * sizeof (short)) ;	return 1 ;} /* au_g72x_encode_block */static intau_g72x_write_block	(SF_PRIVATE *psf, G72x_DATA *pg72x, short *ptr, int len){	int	count, total = 0, indx = 0 ;	while (indx < len)	{	count = pg72x->samplesperblock - pg72x->samplecount ;		if (count > len - indx)			count = len - indx ;		memcpy (&(pg72x->samples [pg72x->samplecount]), &(ptr [indx]), count * sizeof (short)) ;		indx += count ;		pg72x->samplecount += count ;		total = indx ;		if (pg72x->samplecount >= pg72x->samplesperblock)			au_g72x_encode_block (psf, pg72x) ;		} ;	return total ;} /* au_g72x_write_block */static sf_count_tau_g72x_write_s	(SF_PRIVATE *psf, short *ptr, sf_count_t len){	G72x_DATA 	*pg72x ;	int			writecount, count ;	sf_count_t	total = 0 ;	if (! psf->fdata)		return 0 ;	pg72x = (G72x_DATA*) psf->fdata ;	while (len > 0)	{	writecount = (len > 0x10000000) ? 0x10000000 : (int) len ;		count = au_g72x_write_block (psf, pg72x, ptr, writecount) ;		total += count ;		len -= count ;		if (count != writecount)			break ;		} ;	return total ;} /* au_g72x_write_s */static sf_count_tau_g72x_write_i	(SF_PRIVATE *psf, int *ptr, sf_count_t len){	G72x_DATA *pg72x ;	short		*sptr ;	int			k, bufferlen, writecount = 0, count ;	sf_count_t	total = 0 ;	if (! psf->fdata)		return 0 ;	pg72x = (G72x_DATA*) psf->fdata ;	sptr = psf->u.sbuf ;	bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;	while (len > 0)	{	writecount = (len >= bufferlen) ? bufferlen : len ;		for (k = 0 ; k < writecount ; k++)			sptr [k] = ptr [total + k] >> 16 ;		count = au_g72x_write_block (psf, pg72x, sptr, writecount) ;		total += count ;		len -= writecount ;		if (count != writecount)			break ;		} ;	return total ;} /* au_g72x_write_i */static sf_count_tau_g72x_write_f	(SF_PRIVATE *psf, float *ptr, sf_count_t len){	G72x_DATA *pg72x ;	short		*sptr ;	int			k, bufferlen, writecount = 0, count ;	sf_count_t	total = 0 ;	float		normfact ;	if (! psf->fdata)		return 0 ;	pg72x = (G72x_DATA*) psf->fdata ;	normfact = (psf->norm_float == SF_TRUE) ? (1.0 * 0x8000) : 1.0 ;	sptr = psf->u.sbuf ;	bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;	while (len > 0)	{	writecount = (len >= bufferlen) ? bufferlen : len ;		for (k = 0 ; k < writecount ; k++)			sptr [k] = lrintf (normfact * ptr [total + k]) ;		count = au_g72x_write_block (psf, pg72x, sptr, writecount) ;		total += count ;		len -= writecount ;		if (count != writecount)			break ;		} ;	return total ;} /* au_g72x_write_f */static sf_count_tau_g72x_write_d	(SF_PRIVATE *psf, double *ptr, sf_count_t len){	G72x_DATA *pg72x ;	short		*sptr ;	int			k, bufferlen, writecount = 0, count ;	sf_count_t	total = 0 ;	double		normfact ;	if (! psf->fdata)		return 0 ;	pg72x = (G72x_DATA*) psf->fdata ;	normfact = (psf->norm_double == SF_TRUE) ? (1.0 * 0x8000) : 1.0 ;	sptr = psf->u.sbuf ;	bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;	while (len > 0)	{	writecount = (len >= bufferlen) ? bufferlen : len ;		for (k = 0 ; k < writecount ; k++)			sptr [k] = lrint (normfact * ptr [total + k]) ;		count = au_g72x_write_block (psf, pg72x, sptr, writecount) ;		total += count ;		len -= writecount ;		if (count != writecount)			break ;		} ;	return total ;} /* au_g72x_write_d */static intau_g72x_close	(SF_PRIVATE *psf){	G72x_DATA *pg72x ;	if (! psf->fdata)		return 0 ;	pg72x = (G72x_DATA*) psf->fdata ;	if (psf->mode == SFM_WRITE)	{	/*	If a block has been partially assembled, write it out		**	as the final block.		*/		if (pg72x->samplecount && pg72x->samplecount < G72x_BLOCK_SIZE)			au_g72x_encode_block (psf, pg72x) ;		if (psf->write_header)			psf->write_header (psf, SF_FALSE) ;		} ;	return 0 ;} /* au_g72x_close *//*** Do not edit or modify anything in this comment block.** The arch-tag line is a file identity tag for the GNU Arch ** revision control system.**** arch-tag: 3cc5439e-7247-486b-b2e6-11a4affa5744*/

⌨️ 快捷键说明

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