soundcard.h

来自「基于组件方式开发操作系统的OSKIT源代码」· C头文件 代码 · 共 1,046 行 · 第 1/3 页

H
1,046
字号
 *	Midi controller numbers ******************************************* * Controllers 0 to 31 (0x00 to 0x1f) and * 32 to 63 (0x20 to 0x3f) are continuous * controllers. * In the MIDI 1.0 these controllers are sent using * two messages. Controller numbers 0 to 31 are used * to send the MSB and the controller numbers 32 to 63 * are for the LSB. Note that just 7 bits are used in MIDI bytes. */#define	   CTL_BANK_SELECT		0x00#define	   CTL_MODWHEEL			0x01#define    CTL_BREATH			0x02/*		undefined		0x03 */#define    CTL_FOOT			0x04#define    CTL_PORTAMENTO_TIME		0x05#define    CTL_DATA_ENTRY		0x06#define    CTL_MAIN_VOLUME		0x07#define    CTL_BALANCE			0x08/*		undefined		0x09 */#define    CTL_PAN			0x0a#define    CTL_EXPRESSION		0x0b/*		undefined		0x0c *//*		undefined		0x0d *//*		undefined		0x0e *//*		undefined		0x0f */#define    CTL_GENERAL_PURPOSE1	0x10#define    CTL_GENERAL_PURPOSE2	0x11#define    CTL_GENERAL_PURPOSE3	0x12#define    CTL_GENERAL_PURPOSE4	0x13/*		undefined		0x14 - 0x1f *//*		undefined		0x20 *//* The controller numbers 0x21 to 0x3f are reserved for the *//* least significant bytes of the controllers 0x00 to 0x1f. *//* These controllers are not recognised by the driver. *//* Controllers 64 to 69 (0x40 to 0x45) are on/off switches. *//* 0=OFF and 127=ON (intermediate values are possible) */#define    CTL_DAMPER_PEDAL		0x40#define    CTL_SUSTAIN			0x40	/* Alias */#define    CTL_HOLD			0x40	/* Alias */#define    CTL_PORTAMENTO		0x41#define    CTL_SOSTENUTO		0x42#define    CTL_SOFT_PEDAL		0x43/*		undefined		0x44 */#define    CTL_HOLD2			0x45/*		undefined		0x46 - 0x4f */#define    CTL_GENERAL_PURPOSE5	0x50#define    CTL_GENERAL_PURPOSE6	0x51#define    CTL_GENERAL_PURPOSE7	0x52#define    CTL_GENERAL_PURPOSE8	0x53/*		undefined		0x54 - 0x5a */#define    CTL_EXT_EFF_DEPTH		0x5b#define    CTL_TREMOLO_DEPTH		0x5c#define    CTL_CHORUS_DEPTH		0x5d#define    CTL_DETUNE_DEPTH		0x5e#define    CTL_CELESTE_DEPTH		0x5e	/* Alias for the above one */#define    CTL_PHASER_DEPTH		0x5f#define    CTL_DATA_INCREMENT		0x60#define    CTL_DATA_DECREMENT		0x61#define    CTL_NONREG_PARM_NUM_LSB	0x62#define    CTL_NONREG_PARM_NUM_MSB	0x63#define    CTL_REGIST_PARM_NUM_LSB	0x64#define    CTL_REGIST_PARM_NUM_MSB	0x65/*		undefined		0x66 - 0x78 *//*		reserved		0x79 - 0x7f *//* Pseudo controllers (not midi compatible) */#define    CTRL_PITCH_BENDER		255#define    CTRL_PITCH_BENDER_RANGE	254#define    CTRL_EXPRESSION		253	/* Obsolete */#define    CTRL_MAIN_VOLUME		252	/* Obsolete */#define SEQ_BALANCE		11#define SEQ_VOLMODE             12/* * Volume mode decides how volumes are used */#define VOL_METHOD_ADAGIO	1#define VOL_METHOD_LINEAR	2/* * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as *	 input events. *//* * Event codes 0xf0 to 0xfc are reserved for future extensions. */#define SEQ_FULLSIZE		0xfd	/* Long events *//* *	SEQ_FULLSIZE events are used for loading patches/samples to the *	synthesizer devices. These events are passed directly to the driver *	of the associated synthesizer device. There is no limit to the size *	of the extended events. These events are not queued but executed *	immediately when the write() is called (execution can take several *	seconds of time).  * *	When a SEQ_FULLSIZE message is written to the device, it must *	be written using exactly one write() call. Other events cannot *	be mixed to the same write. *	 *	For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the  *	/dev/sequencer. Don't write other data together with the instrument structure *	Set the key field of the structure to FM_PATCH. The device field is used to *	route the patch to the corresponding device. * *	For Gravis UltraSound use struct patch_info. Initialize the key field *      to GUS_PATCH. */#define SEQ_PRIVATE		0xfe	/* Low level HW dependent events (8 bytes) */#define SEQ_EXTENDED		0xff	/* Extended events (8 bytes) OBSOLETE *//* * Record for FM patches */typedef unsigned char sbi_instr_data[32];struct sbi_instrument {		unsigned short	key;		/* 	Initialize to FM_PATCH or OPL3_PATCH */#define FM_PATCH	0x01fd#define OPL3_PATCH	0x03fd		short		device;		/*	Synth# (0-4)	*/		int 		channel;	/*	Program# to be initialized 	*/		sbi_instr_data	operators;	/*	Register settings for operator cells (.SBI format)	*/	};struct synth_info {	/* Read only */		char	name[30];		int	device;		/* 0-N. INITIALIZE BEFORE CALLING */		int	synth_type;#define SYNTH_TYPE_FM			0#define SYNTH_TYPE_SAMPLE		1#define SYNTH_TYPE_MIDI			2	/* Midi interface */		int	synth_subtype;#define FM_TYPE_ADLIB			0x00#define FM_TYPE_OPL3			0x01#define SAMPLE_TYPE_GUS			0x10		int	perc_mode;	/* No longer supported */		int	nr_voices;		int	nr_drums;	/* Obsolete field */		int	instr_bank_size;		unsigned long	capabilities;	#define SYNTH_CAP_PERCMODE		0x00000001 /* No longer used */#define SYNTH_CAP_OPL3			0x00000002 /* Set if OPL3 supported */#define SYNTH_CAP_INPUT			0x00000004 /* Input (MIDI) device */		int	dummies[19];	/* Reserve space */	};struct sound_timer_info {		char name[30];		int caps;	};#define MIDI_CAP_MPU401		1		/* MPU-401 intelligent mode */struct midi_info {		char		name[30];		int		device;		/* 0-N. INITIALIZE BEFORE CALLING */		unsigned long	capabilities;	/* To be defined later */		int		dev_type;		int		dummies[18];	/* Reserve space */	};/******************************************** * ioctl commands for the /dev/midi## */typedef struct {		unsigned char cmd;		char nr_args, nr_returns;		unsigned char data[30];	} mpu_command_rec;#define SNDCTL_MIDI_PRETIME		_IOWR('m', 0, int)#define SNDCTL_MIDI_MPUMODE		_IOWR('m', 1, int)#define SNDCTL_MIDI_MPUCMD		_IOWR('m', 2, mpu_command_rec)/******************************************** * IOCTL commands for /dev/dsp and /dev/audio */#define SNDCTL_DSP_RESET		_IO  ('P', 0)#define SNDCTL_DSP_SYNC			_IO  ('P', 1)#define SNDCTL_DSP_SPEED		_IOWR('P', 2, int)#define SNDCTL_DSP_STEREO		_IOWR('P', 3, int)#define SNDCTL_DSP_GETBLKSIZE		_IOR('P', 4, int)#define SNDCTL_DSP_SETBLKSIZE		_IOW('P', 4, int)#define SNDCTL_DSP_SAMPLESIZE		SNDCTL_DSP_SETFMT#define SOUND_PCM_WRITE_CHANNELS	_IOWR('P', 6, int)#define SOUND_PCM_WRITE_FILTER		_IOWR('P', 7, int)#define SNDCTL_DSP_POST			_IO  ('P', 8)#define SNDCTL_DSP_SUBDIVIDE		_IOWR('P', 9, int)#define SNDCTL_DSP_SETFRAGMENT		_IOWR('P',10, int)/*	Audio data formats (Note! U8=8 and S16_LE=16 for compatibility) */#define SNDCTL_DSP_GETFMTS		_IOR ('P',11, int) /* Returns a mask */#define SNDCTL_DSP_SETFMT		_IOWR('P',5, int) /* Selects ONE fmt*/#	define AFMT_QUERY		0x00000000	/* Return current fmt */#	define AFMT_MU_LAW		0x00000001#	define AFMT_A_LAW		0x00000002#	define AFMT_IMA_ADPCM		0x00000004#	define AFMT_U8			0x00000008#	define AFMT_S16_LE		0x00000010	/* Little endian signed 16*/#	define AFMT_S16_BE		0x00000020	/* Big endian signed 16 */#	define AFMT_S8			0x00000040#	define AFMT_U16_LE		0x00000080	/* Little endian U16 */#	define AFMT_U16_BE		0x00000100	/* Big endian U16 */#	define AFMT_MPEG		0x00000200	/* MPEG (2) audio *//* * Buffer status queries. */typedef struct audio_buf_info {			int fragments;	/* # of available fragments (partially usend ones not counted) */			int fragsize;	/* Size of a fragment in bytes */			int bytes;	/* Available space in bytes (includes partially used fragments) */			/* Note! 'bytes' could be more than fragments*fragsize */		} audio_buf_info;#define SNDCTL_DSP_GETOSPACE		_IOR ('P',12, audio_buf_info)#define SNDCTL_DSP_GETISPACE		_IOR ('P',13, audio_buf_info)#define SNDCTL_DSP_NONBLOCK		_IO  ('P',14)#define SOUND_PCM_READ_RATE		_IOR ('P', 2, int)#define SOUND_PCM_READ_CHANNELS		_IOR ('P', 6, int)#define SOUND_PCM_READ_BITS		_IOR ('P', 5, int)#define SOUND_PCM_READ_FILTER		_IOR ('P', 7, int)/* Some alias names */#define SOUND_PCM_WRITE_BITS		SNDCTL_DSP_SETFMT#define SOUND_PCM_WRITE_RATE		SNDCTL_DSP_SPEED#define SOUND_PCM_POST			SNDCTL_DSP_POST#define SOUND_PCM_RESET			SNDCTL_DSP_RESET#define SOUND_PCM_SYNC			SNDCTL_DSP_SYNC#define SOUND_PCM_SUBDIVIDE		SNDCTL_DSP_SUBDIVIDE#define SOUND_PCM_SETFRAGMENT		SNDCTL_DSP_SETFRAGMENT#define SOUND_PCM_GETFMTS		SNDCTL_DSP_GETFMTS#define SOUND_PCM_SETFMT		SNDCTL_DSP_SETFMT#define SOUND_PCM_GETOSPACE		SNDCTL_DSP_GETOSPACE#define SOUND_PCM_GETISPACE		SNDCTL_DSP_GETISPACE#define SOUND_PCM_NONBLOCK		SNDCTL_DSP_NONBLOCK/* * ioctl calls to be used in communication with coprocessors and * DSP chips. */typedef struct copr_buffer {		int command;	/* Set to 0 if not used */		int flags;#define CPF_NONE		0x0000#define CPF_FIRST		0x0001	/* First block */#define CPF_LAST		0x0002	/* Last block */		int len;		int offs;	/* If required by the device (0 if not used) */		unsigned char data[4000]; /* NOTE! 4000 is not 4k */	} copr_buffer;typedef struct copr_debug_buf {		int command;	/* Used internally. Set to 0 */		int parm1;		int parm2;		int flags;			int len;	/* Length of data in bytes */	} copr_debug_buf;typedef struct copr_msg {		int len;		unsigned char data[4000];	} copr_msg;#define SNDCTL_COPR_RESET             _IO  ('C',  0)#define SNDCTL_COPR_LOAD	      _IOWR('C',  1, copr_buffer)#define SNDCTL_COPR_RDATA	      _IOWR('C',  2, copr_debug_buf)#define SNDCTL_COPR_RCODE	      _IOWR('C',  3, copr_debug_buf)#define SNDCTL_COPR_WDATA	      _IOW ('C',  4, copr_debug_buf)#define SNDCTL_COPR_WCODE	      _IOW ('C',  5, copr_debug_buf)#define SNDCTL_COPR_RUN		      _IOWR('C',  6, copr_debug_buf)#define SNDCTL_COPR_HALT	      _IOWR('C',  7, copr_debug_buf)#define SNDCTL_COPR_SENDMSG	      _IOW ('C',  8, copr_msg)#define SNDCTL_COPR_RCVMSG	      _IOR ('C',  9, copr_msg)/********************************************* * IOCTL commands for /dev/mixer */	/*  * Mixer devices * * There can be up to 20 different analog mixer channels. The * SOUND_MIXER_NRDEVICES gives the currently supported maximum.  * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells * the devices supported by the particular mixer. */#define SOUND_MIXER_NRDEVICES	17#define SOUND_MIXER_VOLUME	0#define SOUND_MIXER_BASS	1#define SOUND_MIXER_TREBLE	2#define SOUND_MIXER_SYNTH	3#define SOUND_MIXER_PCM		4#define SOUND_MIXER_SPEAKER	5#define SOUND_MIXER_LINE	6#define SOUND_MIXER_MIC		7#define SOUND_MIXER_CD		8#define SOUND_MIXER_IMIX	9	/*  Recording monitor  */#define SOUND_MIXER_ALTPCM	10#define SOUND_MIXER_RECLEV	11	/* Recording level */#define SOUND_MIXER_IGAIN	12	/* Input gain */#define SOUND_MIXER_OGAIN	13	/* Output gain *//*  * The AD1848 codec and compatibles have three line level inputs * (line, aux1 and aux2). Since each card manufacturer have assigned * different meanings to these inputs, it's inpractical to assign * specific meanings (line, cd, synth etc.) to them. */#define SOUND_MIXER_LINE1	14	/* Input source 1  (aux1) */#define SOUND_MIXER_LINE2	15	/* Input source 2  (aux2) */#define SOUND_MIXER_LINE3	16	/* Input source 3  (line) *//* Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) *//* Not counted to SOUND_MIXER_NRDEVICES, but use the same number space */#define SOUND_ONOFF_MIN		28#define SOUND_ONOFF_MAX		30#define SOUND_MIXER_MUTE	28	/* 0 or 1 */#define SOUND_MIXER_ENHANCE	29	/* Enhanced stereo (0, 40, 60 or 80) */#define SOUND_MIXER_LOUD	30	/* 0 or 1 *//* Note!	Number 31 cannot be used since the sign bit is reserved */#define SOUND_DEVICE_LABELS	{"Vol  ", "Bass ", "Trebl", "Synth", "Pcm  ", "Spkr ", "Line ", \				 "Mic  ", "CD   ", "Mix  ", "Pcm2 ", "Rec  ", "IGain", "OGain", \				 "Line1", "Line2", "Line3"}#define SOUND_DEVICE_NAMES	{"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \				 "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \				 "line1", "line2", "line3"}

⌨️ 快捷键说明

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