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

📄 alsapcm.java

📁 java处理声音文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	public static final int	SND_PCM_DIG1_CON_MUSICAL_ID =	0x05;	public static final int	SND_PCM_DIG1_CON_MAGNETIC_MASK =	0x07;	public static final int	SND_PCM_DIG1_CON_MAGNETIC_ID =	0x03;	public static final int	SND_PCM_DIG1_CON_IEC908_CD =	(SND_PCM_DIG1_CON_LASEROPT_ID|0x00);	public static final int	SND_PCM_DIG1_CON_NON_IEC908_CD =	(SND_PCM_DIG1_CON_LASEROPT_ID|0x08);	public static final int	SND_PCM_DIG1_CON_PCM_CODER =	(SND_PCM_DIG1_CON_DIGDIGCONV_ID|0x00);	public static final int	SND_PCM_DIG1_CON_SAMPLER =	(SND_PCM_DIG1_CON_DIGDIGCONV_ID|0x20);	public static final int	SND_PCM_DIG1_CON_MIXER =		(SND_PCM_DIG1_CON_DIGDIGCONV_ID|0x10);	public static final int	SND_PCM_DIG1_CON_RATE_CONVERTER =	(SND_PCM_DIG1_CON_DIGDIGCONV_ID|0x18);	public static final int	SND_PCM_DIG1_CON_SYNTHESIZER =	(SND_PCM_DIG1_CON_MUSICAL_ID|0x00);	public static final int	SND_PCM_DIG1_CON_MICROPHONE =	(SND_PCM_DIG1_CON_MUSICAL_ID|0x08);	public static final int	SND_PCM_DIG1_CON_DAT =		(SND_PCM_DIG1_CON_MAGNETIC_ID|0x00);	public static final int	SND_PCM_DIG1_CON_VCR =		(SND_PCM_DIG1_CON_MAGNETIC_ID|0x08);	public static final int	SND_PCM_DIG1_CON_ORIGINAL =	(1<<7);	/* this bits depends on the category code */	public static final int	SND_PCM_DIG2_PRO_SBITS =		(7<<0);	/* mask - sample bits */	public static final int	SND_PCM_DIG2_PRO_SBITS_20 =	(2<<0);	/* 20-bit - coordination */	public static final int	SND_PCM_DIG2_PRO_SBITS_24 =	(4<<0);	/* 24-bit - main audio */	public static final int	SND_PCM_DIG2_PRO_SBITS_UDEF =	(6<<0);	/* user defined application */	public static final int	SND_PCM_DIG2_PRO_WORDLEN =	(7<<3);	/* mask - source word length */	public static final int	SND_PCM_DIG2_PRO_WORDLEN_NOTID =	(0<<3);	/* not indicated */	public static final int	SND_PCM_DIG2_PRO_WORDLEN_22_18 =	(2<<3);	/* 22-bit or 18-bit */	public static final int	SND_PCM_DIG2_PRO_WORDLEN_23_19 =	(4<<3);	/* 23-bit or 19-bit */	public static final int	SND_PCM_DIG2_PRO_WORDLEN_24_20 =	(5<<3);	/* 24-bit or 20-bit */	public static final int	SND_PCM_DIG2_PRO_WORDLEN_20_16 =	(6<<3);	/* 20-bit or 16-bit */	public static final int	SND_PCM_DIG2_CON_SOURCE =		(15<<0);	/* mask - source number */	public static final int	SND_PCM_DIG2_CON_SOURCE_UNSPEC =	(0<<0);	/* unspecified */	public static final int	SND_PCM_DIG2_CON_CHANNEL =	(15<<4);	/* mask - channel number */	public static final int	SND_PCM_DIG2_CON_CHANNEL_UNSPEC =	(0<<4);	/* unspecified */	public static final int	SND_PCM_DIG3_CON_FS =		(15<<0);	/* mask - sample frequency */	public static final int	SND_PCM_DIG3_CON_FS_44100 =	(0<<0);	/* 44.1kHz */	public static final int	SND_PCM_DIG3_CON_FS_48000 =	(2<<0);	/* 48kHz */	public static final int	SND_PCM_DIG3_CON_FS_32000 =	(3<<0);	/* 32kHz */	public static final int	SND_PCM_DIG3_CON_CLOCK =		(3<<4);	/* mask - clock accuracy */	public static final int	SND_PCM_DIG3_CON_CLOCK_1000PPM =	(0<<4);	/* 1000 ppm */	public static final int	SND_PCM_DIG3_CON_CLOCK_50PPM =	(1<<4);	/* 50 ppm */	public static final int	SND_PCM_DIG3_CON_CLOCK_VARIABLE =	(2<<4);	/* variable pitch */	static	{		System.loadLibrary("tritonusalsa");	}	/**	 *	Holds the pointer to snd_pcm_t for the native code.	 *	This must be long to be 64bit-clean.	 */	private long	m_lNativeHandle;	public AlsaPcm(int nCard,		       int nDevice,		       int nDirection)		throws	Exception	{		if (open(nCard,			 nDevice,			 nDirection) < 0)		{			throw new Exception();		}	}	public AlsaPcm(int nCard,		       int nDevice,		       int nSubevice,		       int nDirection)		throws	Exception	{		if (open(nCard,			 nDevice,			 nSubevice,			 nDirection) < 0)		{			throw new Exception();		}	}	/**	 *	Calls snd_pcm_open().	 */	private native int open(		int nCard,		int nDevice,		int nDirection);	/**	 *	Calls snd_pcm_open_subdevice().	 */	private native int open(		int nCard,		int nDevice,		int nSubdevice,		int nDirection);	/**	 *	Calls snd_pcm_close().	 */	public native int close();	/* does not seem useful:	   file_descriptor	 */	public native int setNonblockMode(int nNonblock);	/* TODO:	   pcm_info	   pcm_channel_info	 */	/**	 *	anValues[0]	type	 *	anValues[1]	flags	 *	anValues[2]	playback subdevices	 *	anValues[3]	capture subdevices	 *	 *	astrValues[0]	id	 *	astrValues[1]	name	 */	public native int getInfo(int[] anValues,				  String[] astrValues);	/**	 *	anValues[00]	subdevice	 *	anValues[01]	channel	 *	anValues[02]	mode	 *	anValues[03]	flags	 *	anValues[04]	formats	 *	anValues[05]	rates	 *	anValues[06]	min rate	 *	anValues[07]	max rate	 *	anValues[08]	min voices	 *	anValues[09]	max voices	 *	anValues[10]	buffer_size	 *	anValues[11]	min fragment size	 *	anValues[12]	max fragment size	 *	anValues[13]	fragment align	 *	anValues[14]	fifo size	 *	anValues[15]	transfer block size	 *	anValues[16]	mmap size	 *	anValues[17]	mixer device	 *	 *	astrValues[0]	subdevice name	 *	 *	missing: sync info, digital info, mixer_eid	 */	public native int getChannelInfo(int[] anValues,					 String[] astrValues);	/**	 *	Calls snd_pcm_channel_params().	 */	public native int setChannelParams(		int nChannel,		int nMode,		// format		boolean bInterleave,		int nFormat,		int nRate,		int nVoices,		int nSpecial,		/* TODO: digital */		int nStartMode,		int nStopMode,		boolean bTime,		boolean bUstTime,		int nQueueOrFragSize,		int nMin,		int nMax);	/**	 *	anValues[00]	channel	 *	anValues[01]	mode	 *	 *	anValues[02]	format	 *	anValues[03]	rate	 *	anValues[04]	voices	 *	anValues[05]	special	 *	 *	missing: digital	 *	 *	anValues[06]	queue size (only valid if stream mode)	 *	anValues[07]	frag size (only valid if block mode)	 *	anValues[08]	frags (only valid if block mode)	 *	anValues[09]	min frags (only valid if block mode)	 *	anValues[10]	max frags (only valid if block mode)	 *	anValues[11]	most significant bits per sample	 *	 *	abValues[0]	interleave	 */	public native int getChannelSetup(int[] anValues,					  boolean[] abValues);	/**	 *	anValues[0]	mode	 *	anValues[1]	status	 *	 *	anValues[2]	byte count since start	 *	anValues[3]	current fragment	 *	anValues[4]	bytes in queue/buffer	 *	anValues[5]	free bytes in queue	 *	anValues[6]	underrun count (playback)	 *	anValues[7]	overrun count (capture)	 *	anValues[8]	ADC overrange count (capture)	 *	 *	alValues[0]	start time	 *	alValues[1]	ust start time	 */	public native int getChannelStatus(int nChannel,					   int[] anValues,					   long[] alValues);	public native int prepareChannel(int nChannel);	public native int preparePlayback();	public native int prepareCapture();	public native int goChannel(int nChannel);	public native int goPlayback();	public native int goCapture();	public native int goSync(/* TODO: */);	public native int drainPlayback();	public native int flushChannel(int nChannel);	public native int flushPlayback();	public native int flushCapture();	public native int setPlaybackPause(boolean bEnable);	public native int getTransferSize(int nChannel);	public native int write(byte[] abData, int nOffset, int nLength);	public native int read(byte[] abData, int nOffset, int nLength);	/* not implemented:	   writev	   readv	   mmap	   munmap	   *_format_*	 */}/*** AlsaPcm.java ***/

⌨️ 快捷键说明

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