📄 soundcard.h
字号:
#ifndef SOUNDCARD_H#define SOUNDCARD_H/* * Copyright by Hannu Savolainen 1993-2000 * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. 2. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. *//* * IMPORTANT NOTICE! * * This header file contains many obsolete definitions (for compatibility * purposes). Please check the OSS Programmer's guide for descriptions * of the supported API details (http://www.opensound.com/pguide). */#if defined(__cplusplus)#define EXTERNC extern "C"#else#define EXTERNC extern#endif /* EXTERN_C_WRAPPERS *//* * OSS interface version. With versions earlier than 3.6 this value is * an integer with value less than 361. In versions 3.6 and later * it's a six digit hexadecimal value. For example value * of 0x030600 represents OSS version 3.6.0. * Use ioctl(fd, OSS_GETVERSION, &int) to get the version number of * the currently active driver. */#define SOUND_VERSION 0x030960#define OPEN_SOUND_SYSTEM#if defined(__hpux) && !defined(_HPUX_SOURCE)# error "-D_HPUX_SOURCE must be used when compiling OSS applications"#endif#ifdef __hpux#include <sys/ioctl.h>#endif#ifdef linux/* In Linux we need to be prepared for cross compiling */#include <linux/ioctl.h>#else# ifdef __FreeBSD__# include <sys/ioccom.h># else# include <sys/ioctl.h># endif#endif/* * Supported card ID numbers (OBSOLETE. NOT USED ANY MORE) */#define SNDCARD_ADLIB 1#define SNDCARD_SB 2#define SNDCARD_PAS 3#define SNDCARD_GUS 4#define SNDCARD_MPU401 5#define SNDCARD_SB16 6#define SNDCARD_SB16MIDI 7#define SNDCARD_UART6850 8#define SNDCARD_GUS16 9#define SNDCARD_MSS 10#define SNDCARD_PSS 11#define SNDCARD_SSCAPE 12#define SNDCARD_PSS_MPU 13#define SNDCARD_PSS_MSS 14#define SNDCARD_SSCAPE_MSS 15#define SNDCARD_TRXPRO 16#define SNDCARD_TRXPRO_SB 17#define SNDCARD_TRXPRO_MPU 18#define SNDCARD_MAD16 19#define SNDCARD_MAD16_MPU 20#define SNDCARD_CS4232 21#define SNDCARD_CS4232_MPU 22#define SNDCARD_MAUI 23#define SNDCARD_PSEUDO_MSS 24#define SNDCARD_GUSPNP 25#define SNDCARD_UART401 26/* Sound card numbers 27 to N are reserved. Don't add more numbers here *//*********************************** * IOCTL Commands for /dev/sequencer */#ifndef __SIOWR#if defined(__hpux) || (defined(_IOWR) && (defined(_AIX) || (!defined(sun) && !defined(sparc) && !defined(__INCioctlh) && !defined(__Lynx__))))/* Use already defined ioctl defines if they exist (except with Sun and some others) */#define SIOCPARM_MASK IOCPARM_MASK#define SIOC_VOID IOC_VOID#define SIOC_OUT IOC_OUT#define SIOC_IN IOC_IN#define SIOC_INOUT IOC_INOUT#define __SIOC_SIZE _IOC_SIZE#define __SIOC_DIR _IOC_DIR#define __SIOC_NONE _IOC_NONE#define __SIOC_READ _IOC_READ#define __SIOC_WRITE _IOC_WRITE#define __SIO _IO#define __SIOR _IOR#define __SIOW _IOW#define __SIOWR _IOWR#else/* Ioctl's have the command encoded in the lower word, * and the size of any in or out parameters in the upper * word. The high 2 bits of the upper word are used * to encode the in/out status of the parameter; for now * we restrict parameters to at most 8191 bytes. *//* #define SIOCTYPE (0xff<<8) */#define SIOCPARM_MASK 0x1fff /* parameters must be < 8192 bytes */#define SIOC_VOID 0x00000000 /* no parameters */#define SIOC_OUT 0x20000000 /* copy out parameters */#define SIOC_IN 0x40000000 /* copy in parameters */#define SIOC_INOUT (SIOC_IN|SIOC_OUT)/* the 0x20000000 is so we can distinguish new ioctl's from old */#define __SIO(x,y) ((int)(SIOC_VOID|(x<<8)|y))#define __SIOR(x,y,t) ((int)(SIOC_OUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))#define __SIOW(x,y,t) ((int)(SIOC_IN|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))#define __SIOWR(x,y,t) ((int)(SIOC_INOUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))#define __SIOC_SIZE(x) ((x>>16)&SIOCPARM_MASK)#define __SIOC_DIR(x) (x & 0xf0000000)#define __SIOC_NONE SIOC_VOID#define __SIOC_READ SIOC_OUT#define __SIOC_WRITE SIOC_IN# endif /* _IOWR */#endif /* !__SIOWR */#define SNDCTL_SEQ_RESET __SIO ('Q', 0)#define SNDCTL_SEQ_SYNC __SIO ('Q', 1)#define SNDCTL_SYNTH_INFO __SIOWR('Q', 2, struct synth_info)#define SNDCTL_SEQ_CTRLRATE __SIOWR('Q', 3, int) /* Set/get timer resolution (HZ) */#define SNDCTL_SEQ_GETOUTCOUNT __SIOR ('Q', 4, int)#define SNDCTL_SEQ_GETINCOUNT __SIOR ('Q', 5, int)#define SNDCTL_SEQ_PERCMODE __SIOW ('Q', 6, int)#define SNDCTL_FM_LOAD_INSTR __SIOW ('Q', 7, struct sbi_instrument) /* Obsolete. Don't use!!!!!! */#define SNDCTL_SEQ_TESTMIDI __SIOW ('Q', 8, int)#define SNDCTL_SEQ_RESETSAMPLES __SIOW ('Q', 9, int)#define SNDCTL_SEQ_NRSYNTHS __SIOR ('Q',10, int)#define SNDCTL_SEQ_NRMIDIS __SIOR ('Q',11, int)#define SNDCTL_MIDI_INFO __SIOWR('Q',12, struct midi_info)#define SNDCTL_SEQ_THRESHOLD __SIOW ('Q',13, int)#define SNDCTL_SYNTH_MEMAVL __SIOWR('Q',14, int) /* in=dev#, out=memsize */#define SNDCTL_FM_4OP_ENABLE __SIOW ('Q',15, int) /* in=dev# */#define SNDCTL_SEQ_PANIC __SIO ('Q',17)#define SNDCTL_SEQ_OUTOFBAND __SIOW ('Q',18, struct seq_event_rec)#define SNDCTL_SEQ_GETTIME __SIOR ('Q',19, int)#define SNDCTL_SYNTH_ID __SIOWR('Q',20, struct synth_info)#define SNDCTL_SYNTH_CONTROL __SIOWR('Q',21, struct synth_control)#define SNDCTL_SYNTH_REMOVESAMPLE __SIOWR('Q',22, struct remove_sample) /* Reserved for future use */#define SNDCTL_SEQ_TIMING_ENABLE __SIO ('Q', 23) /* Enable incoming MIDI timing messages */#define SNDCTL_SEQ_ACTSENSE_ENABLE __SIO ('Q', 24) /* Enable incoming active sensing messages */#define SNDCTL_SEQ_RT_ENABLE __SIO ('Q', 25) /* Enable other incoming realtime messages */typedef struct synth_control{ int devno; /* Synthesizer # */ char data[4000]; /* Device spesific command/data record */}synth_control;typedef struct remove_sample{ int devno; /* Synthesizer # */ int bankno; /* MIDI bank # (0=General MIDI) */ int instrno; /* MIDI instrument number */}remove_sample;typedef struct seq_event_rec{ unsigned char arr[8];}seq_event_rec;#define SNDCTL_TMR_TIMEBASE __SIOWR('T', 1, int)#define SNDCTL_TMR_START __SIO ('T', 2)#define SNDCTL_TMR_STOP __SIO ('T', 3)#define SNDCTL_TMR_CONTINUE __SIO ('T', 4)#define SNDCTL_TMR_TEMPO __SIOWR('T', 5, int)#define SNDCTL_TMR_SOURCE __SIOWR('T', 6, int)# define TMR_INTERNAL 0x00000001# define TMR_EXTERNAL 0x00000002# define TMR_MODE_MIDI 0x00000010# define TMR_MODE_FSK 0x00000020# define TMR_MODE_CLS 0x00000040# define TMR_MODE_SMPTE 0x00000080#define SNDCTL_TMR_METRONOME __SIOW ('T', 7, int)#define SNDCTL_TMR_SELECT __SIOW ('T', 8, int)/* * Some big endian/little endian handling macros (native endian and opposite * endian formats) */#if defined(_AIX) || defined(AIX) || defined(sparc) || defined(__hppa) || defined(PPC) || defined(__powerpc__) && !defined(i386) && !defined(__i386) && !defined(__i386__)/* Big endian machines */# define _PATCHKEY(id) (0xfd00|id)# define AFMT_S16_NE AFMT_S16_BE# define AFMT_U16_NE AFMT_U16_BE# define AFMT_S32_NE AFMT_S32_BE# define AFMT_S24_NE AFMT_S24_BE# define AFMT_S16_OE AFMT_S16_LE# define AFMT_S32_OE AFMT_S32_LE# define AFMT_S24_OE AFMT_S24_LE#else# define _PATCHKEY(id) ((id<<8)|0xfd)# define AFMT_S16_NE AFMT_S16_LE# define AFMT_U16_NE AFMT_U16_LE# define AFMT_S32_NE AFMT_S32_LE# define AFMT_S24_NE AFMT_S24_LE# define AFMT_S16_OE AFMT_S16_BE# define AFMT_S32_OE AFMT_S32_BE# define AFMT_S24_OE AFMT_S24_BE#endif/* * Sample loading mechanism for internal synthesizers (/dev/sequencer) * The following patch_info structure has been designed to support * Gravis UltraSound. It tries to be universal format for uploading * sample based patches but is probably too limited. */struct patch_info{ unsigned short key; /* Use WAVE_PATCH here */#define WAVE_PATCH _PATCHKEY(0x04)#define GUS_PATCH WAVE_PATCH#define WAVEFRONT_PATCH _PATCHKEY(0x06) short device_no; /* Synthesizer number */ short instr_no; /* Midi pgm# */ unsigned int mode;/* * The least significant byte has the same format than the GUS .PAT * files */#define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */#define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */#define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */#define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */#define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */#define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3) */#define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */#define WAVE_FAST_RELEASE 0x80 /* bit 7 = Shut off immediately after note off */ /* (use the env_rate/env_offs fields). *//* Linux specific bits */#define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */#define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */#define WAVE_SCALE 0x00040000 /* The scaling info is valid */#define WAVE_FRACTIONS 0x00080000 /* Fraction information is valid *//* Reserved bits */#define WAVE_ROM 0x40000000 /* For future use */#define WAVE_MULAW 0x20000000 /* For future use *//* Other bits must be zeroed */ int len; /* Size of the wave data in bytes */ int loop_start, loop_end; /* Byte offsets from the beginning *//* * The base_freq and base_note fields are used when computing the * playback speed for a note. The base_note defines the tone frequency * which is heard if the sample is played using the base_freq as the * playback speed. * * The low_note and high_note fields define the minimum and maximum note * frequencies for which this sample is valid. It is possible to define * more than one samples for an instrument number at the same time. The * low_note and high_note fields are used to select the most suitable one. * * The fields base_note, high_note and low_note should contain * the note frequency multiplied by 1000. For example value for the * middle A is 440*1000. */ unsigned int base_freq; unsigned int base_note; unsigned int high_note; unsigned int low_note; int panning; /* -128=left, 127=right */ int detuning;/* New fields introduced in version 1.99.5 */ /* Envelope. Enabled by mode bit WAVE_ENVELOPES */ unsigned char env_rate[6]; /* GUS HW ramping rate */ unsigned char env_offset[6]; /* 255 == 100% */ /* * The tremolo, vibrato and scale info are not supported yet. * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or * WAVE_SCALE */ unsigned char tremolo_sweep; unsigned char tremolo_rate; unsigned char tremolo_depth; unsigned char vibrato_sweep; unsigned char vibrato_rate; unsigned char vibrato_depth; int scale_frequency; unsigned int scale_factor; /* from 0 to 2048 or 0 to 2 */ int volume; int fractions; int reserved1; int spare[2]; char data[1]; /* The waveform data starts here */};struct sysex_info{ short key; /* Use SYSEX_PATCH or MAUI_PATCH here */#define SYSEX_PATCH _PATCHKEY(0x05)#define MAUI_PATCH _PATCHKEY(0x06) short device_no; /* Synthesizer number */ int len; /* Size of the sysex data in bytes */ unsigned char data[1]; /* Sysex data starts here */};/* * /dev/sequencer input events. *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -