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

📄 common.h

📁 Audacity是一款用於錄音和編輯聲音的、免費的開放源碼軟體。它可以執行於Mac OS X、Microsoft Windows、GNU/Linux和其它作業系統
💻 H
📖 第 1 页 / 共 2 页
字号:
/*** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd@mega-nerd.com>**** This program is free software; you can redistribute it and/or modify** it under the terms of the GNU Lesser General Public License as published by** the Free Software Foundation; either version 2.1 of the License, or** (at your option) any later version.**** This program is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the** GNU Lesser General Public License for more details.**** You should have received a copy of the GNU Lesser General Public License** along with this program; if not, write to the Free Software** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/#ifndef COMMON_H_INCLUDED#define COMMON_H_INCLUDED#include "config.h"#ifndef SNDFILE_H#include <sndfile.h>#endif#if HAVE_STDINT_H#include <stdint.h>#endif#ifdef UNUSED#elif defined (__GNUC__)#	define UNUSED(x) UNUSED_ ## x __attribute__ ((unused))#elif defined (__LCLINT__)#	define UNUSED(x) /*@unused@*/ x#else#	define UNUSED(x) x#endif#ifdef __GNUC__#	define WARN_UNUSED	__attribute__((warn_unused_result))#else#	define WARN_UNUSED#endif#define	SF_BUFFER_LEN			(8192*2)#define	SF_FILENAME_LEN			(512)#define	SF_HEADER_LEN			(4096)#define	SF_TEXT_LEN				(1024)#define SF_SYSERR_LEN			(256)#define SF_MAX_STRINGS			(16)#define	SF_SEEK_ERROR			((sf_count_t) -1)#define	BITWIDTH2BYTES(x)	(((x) + 7) / 8)/*	For some reason sizeof returns an unsigned  value which causes**	a warning when that value is added or subtracted from a signed**	value. Use SIGNED_SIZEOF instead.*/#define		SIGNED_SIZEOF(x)	((int) sizeof (x))#define		ARRAY_LEN(x)	((int) (sizeof (x) / sizeof ((x) [0])))#define		SF_MAX(a,b)		((a) > (b) ? (a) : (b))#define		SF_MIN(a,b)		((a) < (b) ? (a) : (b))enum{	/* PEAK chunk location. */	SF_PEAK_START		= 42,	SF_PEAK_END			= 43,	/* PEAK chunk location. */	SF_SCALE_MAX		= 52,	SF_SCALE_MIN		= 53,	/* str_flags values. */	SF_STR_ALLOW_START	= 0x0100,	SF_STR_ALLOW_END	= 0x0200,	/* Location of strings. */	SF_STR_LOCATE_START	= 0x0400,	SF_STR_LOCATE_END	= 0x0800,	SFD_TYPEMASK		= 0x0FFFFFFF} ;#define		SFM_MASK 	(SFM_READ | SFM_WRITE | SFM_RDWR)#define		SFM_UNMASK 	(~SFM_MASK)/*---------------------------------------------------------------------------------------** Formats that may be supported at some time in the future.** When support is finalised, these values move to src/sndfile.h.*/enum{	/* Work in progress. */	/* Formats supported read only. */	SF_FORMAT_WVE			= 0x4020000,		/* Psion ALaw Sound File */	SF_FORMAT_TXW			= 0x4030000,		/* Yamaha TX16 sampler file */	SF_FORMAT_DWD			= 0x4040000,		/* DiamondWare Digirized */	/* Following are detected but not supported. */	SF_FORMAT_OGG			= 0x4090000,	SF_FORMAT_REX			= 0x40A0000,		/* Propellorheads Rex/Rcy */	SF_FORMAT_REX2			= 0x40D0000,		/* Propellorheads Rex2 */	SF_FORMAT_KRZ			= 0x40E0000,		/* Kurzweil sampler file */	SF_FORMAT_WMA			= 0x4100000,		/* Windows Media Audio. */	SF_FORMAT_SHN			= 0x4110000,		/* Shorten. */	SF_FORMAT_FLAC			= 0x4120000,	/* Unsupported encodings. */	SF_FORMAT_VORBIS		= 0x1001,	SF_FORMAT_SVX_FIB		= 0x1020, 		/* SVX Fibonacci Delta encoding. */	SF_FORMAT_SVX_EXP		= 0x1021, 		/* SVX Exponential Delta encoding. */	SF_FORMAT_PCM_N			= 0x1030} ;/*---------------------------------------------------------------------------------------**	PEAK_CHUNK - This chunk type is common to both AIFF and WAVE files although their**	endian encodings are different.*/typedef struct{	float			value ;		/* signed value of peak */	unsigned int	position ;	/* the sample frame for the peak */} PEAK_POS ;typedef struct{	unsigned int	version ;	/* version of the PEAK chunk */	unsigned int	timestamp ;	/* secs since 1/1/1970  */#if HAVE_FLEXIBLE_ARRAY	/* the per channel peak info */	PEAK_POS		peaks [] ;#else	/*	** This is not ISO compliant C. It works on some compilers which	** don't support the ISO standard flexible struct array which is	** used above. If your compiler doesn't ike this I suggest you find	** youself a 1999 ISO C standards compilant compiler. GCC-3.X is	** highly recommended.	*/	PEAK_POS		peaks [0] ;#endif} PEAK_CHUNK ;typedef struct{	int		type ;	int		flags ;	char 	*str ;} STR_DATA ;/*=======================================================================================**	SF_PRIVATE stuct - a pointer to this struct is passed back to the caller of the**	sf_open_XXXX functions. The caller however has no knowledge of the struct's**	contents.*/typedef struct sf_private_tag{	/* Force the compiler to double align the start of buffer. */	union	{	double			dbuf	[SF_BUFFER_LEN / sizeof (double)] ;#if (defined (SIZEOF_INT64_T) && (SIZEOF_INT64_T == 8))		int64_t			lbuf	[SF_BUFFER_LEN / sizeof (int64_t)] ;#else		long			lbuf	[SF_BUFFER_LEN / sizeof (double)] ;#endif		float			fbuf	[SF_BUFFER_LEN / sizeof (float)] ;		int				ibuf	[SF_BUFFER_LEN / sizeof (int)] ;		short			sbuf	[SF_BUFFER_LEN / sizeof (short)] ;		char			cbuf	[SF_BUFFER_LEN / sizeof (char)] ;		signed char		scbuf	[SF_BUFFER_LEN / sizeof (signed char)] ;		unsigned char	ucbuf	[SF_BUFFER_LEN / sizeof (signed char)] ;		} u ;	char			filepath	[SF_FILENAME_LEN] ;	char			rsrcpath	[SF_FILENAME_LEN] ;	char			filename	[SF_FILENAME_LEN / 4] ;	char			syserr		[SF_SYSERR_LEN] ;	/* logbuffer and logindex should only be changed within the logging functions	** of common.c	*/	char			logbuffer	[SF_BUFFER_LEN] ;	unsigned char	header		[SF_HEADER_LEN] ; /* Must be unsigned */	int				rwf_endian ;	/* Header endian-ness flag. */	/* Storage and housekeeping data for adding/reading strings from	** sound files.	*/	STR_DATA		strings [SF_MAX_STRINGS] ;	char			str_storage [SF_BUFFER_LEN] ;	char			*str_end ;	int				str_flags ;	/* Guard value. If this changes the buffers above have overflowed. */	int				Magick ;	/* Index variables for maintaining logbuffer and header above. */	int				logindex ;	int				headindex, headend ;	int				has_text ;	int				do_not_close_descriptor ;	/* File descriptors for the file and (possibly) the resource fork. */	int 			filedes, rsrcdes ;	int				end_of_file ;	int				error ;	int				mode ;			/* Open mode : SFM_READ, SFM_WRITE or SFM_RDWR. */	int				endian ;		/* File endianness : SF_ENDIAN_LITTLE or SF_ENDIAN_BIG. */	int				float_endswap ;	/* Need to endswap float32s? */	/*	** Maximum float value for calculating the multiplier for	** float/double to short/int conversions.	*/	int				float_int_mult ;	float			float_max ;	/* Vairables for handling pipes. */	int				is_pipe ;		/* True if file is a pipe. */	sf_count_t		pipeoffset ;	/* Number of bytes read from a pipe. */	/* True if clipping must be performed on float->int conversions. */	int				add_clipping ;	SF_INFO			sf ;	int				have_written ;	/* Has a single write been done to the file? */	int				has_peak ;		/* Has a PEAK chunk (AIFF and WAVE) been read? */	int				peak_loc ;		/* Write a PEAK chunk at the start or end of the file? */	PEAK_CHUNK		*pchunk ;	/* Loop Info */	SF_LOOP_INFO	*loop_info ;	sf_count_t		filelength ;	/* Overall length of (embedded) file. */	sf_count_t		fileoffset ;	/* Offset in number of bytes from beginning of file. */	sf_count_t		rsrclength ;	/* Length of the resource fork (if it exists). */	sf_count_t		dataoffset ;	/* Offset in number of bytes from beginning of file. */	sf_count_t		datalength ;	/* Length in bytes of the audio data. */	sf_count_t		dataend ;		/* Offset to file tailer. */	int				blockwidth ;	/* Size in bytes of one set of interleaved samples. */	int				bytewidth ;		/* Size in bytes of one sample (one channel). */	void			*dither ;	void			*interleave ;	int				last_op ;		/* Last operation; either SFM_READ or SFM_WRITE */	sf_count_t		read_current ;	sf_count_t		write_current ;	void			*fdata ;		/*	This is a pointer to dynamically allocated file format									**	specific data.									*/	SF_DITHER_INFO	write_dither ;	SF_DITHER_INFO	read_dither ;	int				norm_double ;	int				norm_float ;	int				auto_header ;	int				ieee_replace ;	/* A set of file specific function pointers */	sf_count_t		(*read_short)	(struct sf_private_tag*, short *ptr, sf_count_t len) ;	sf_count_t		(*read_int)		(struct sf_private_tag*, int *ptr, sf_count_t len) ;	sf_count_t		(*read_float)	(struct sf_private_tag*, float *ptr, sf_count_t len) ;	sf_count_t		(*read_double)	(struct sf_private_tag*, double *ptr, sf_count_t len) ;	sf_count_t		(*write_short)	(struct sf_private_tag*, short *ptr, sf_count_t len) ;	sf_count_t		(*write_int)	(struct sf_private_tag*, int *ptr, sf_count_t len) ;	sf_count_t		(*write_float)	(struct sf_private_tag*, float *ptr, sf_count_t len) ;	sf_count_t		(*write_double)	(struct sf_private_tag*, double *ptr, sf_count_t len) ;	sf_count_t		(*seek) 		(struct sf_private_tag*, int mode, sf_count_t samples_from_start) ;	int				(*write_header)	(struct sf_private_tag*, int calc_length) ;	int				(*command)		(struct sf_private_tag*, int command, void *data, int datasize) ;	int				(*close)		(struct sf_private_tag*) ;	char			*format_desc ;} SF_PRIVATE ;enum{	SFE_NO_ERROR		= SF_ERR_NO_ERROR,	SFE_BAD_OPEN_FORMAT	= SF_ERR_UNRECOGNISED_FORMAT,	SFE_SYSTEM			= SF_ERR_SYSTEM,	SFE_BAD_FILE,	SFE_BAD_FILE_READ,	SFE_OPEN_FAILED,	SFE_BAD_SNDFILE_PTR,	SFE_BAD_SF_INFO_PTR,	SFE_BAD_SF_INCOMPLETE,	SFE_BAD_FILE_PTR,	SFE_BAD_INT_PTR,	SFE_BAD_STAT_SIZE,	SFE_MALLOC_FAILED,	SFE_UNIMPLEMENTED,	SFE_BAD_READ_ALIGN,	SFE_BAD_WRITE_ALIGN,	SFE_UNKNOWN_FORMAT,	SFE_NOT_READMODE,	SFE_NOT_WRITEMODE,	SFE_BAD_MODE_RW,	SFE_BAD_SF_INFO,	SFE_BAD_OFFSET,	SFE_NO_EMBED_SUPPORT,	SFE_NO_EMBEDDED_RDWR,	SFE_NO_PIPE_WRITE,	SFE_INTERNAL,	SFE_LOG_OVERRUN,	SFE_BAD_CONTROL_CMD,	SFE_BAD_ENDIAN,	SFE_CHANNEL_COUNT,	SFE_BAD_RDWR_FORMAT,	SFE_INTERLEAVE_MODE,	SFE_INTERLEAVE_SEEK,	SFE_INTERLEAVE_READ,	SFE_BAD_SEEK,	SFE_NOT_SEEKABLE,	SFE_AMBIGUOUS_SEEK,	SFE_WRONG_SEEK,	SFE_SEEK_FAILED,	SFE_BAD_OPEN_MODE,	SFE_OPEN_PIPE_RDWR,

⌨️ 快捷键说明

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