二函数
1. buffer函数
void alGenBuffers(ALsizei n /* buffer数*/, ALuint * buffers /* buffer ID数组*/);
void alDeleteBuffers(ALsizei n /* buffer数*/, ALuint * buffers /* buffer ID 数组*/);
ALboolean alIsBuffer(ALuint buffer);
// 为buffer填充数据
void alBufferData(ALuint buffer, ALenum format/*声音格式*/,const ALvoid *data/*数据地址*/
, ALsizei size/*数据字节数*/,ALsizei freq/*声音频率*/);
声音格式:AL_FORMAT_[MONO8, MONO16, STEREO8, STEREO16]
// 设置buffer的浮点数属性
void alBufferf (ALuintbuffer, ALenum param/*属性名*/,ALfloat value/*属性值*/);
void alBuffer3f (ALuintbuffer, ALenum param, ALfloat v1, ALfloat v2, ALfloat v3);
void alBufferfv (ALuintbuffer, ALenum param, ALfloat *values);
// 设置buffer的整数属性
void alBufferi (ALuintbuffer, ALenum param, ALint value);
void alBuffer3i (ALuintbuffer, ALenum param, ALint v1, ALint v2, ALint v3);
void alBufferiv (ALuintbuffer, ALenum param, ALint *values);
// 获取buffer属性值
void alGetBufferf(ALuint buffer, ALenum param, ALfloat *value);
void alGetBuffer3f(ALuint buffer, ALenum param, ALfloat *v1, ALfloat *v2, ALfloat *v3);
void alGetBufferfv(ALuint buffer, ALenum param, ALfloat *values);
void alGetBufferi(ALuint buffer, ALenum param, ALint *value);
void alGetBuffer3i(ALuint buffer, ALenum param, ALint *v1, ALint *v2, ALint *v3);
void alGetBufferiv(ALuint buffer, ALenum param, ALint *values);
2. source函数
void alGenSources(ALsizei n, ALuint *sources);
void alDeleteSources(ALsizei n, ALuint *sources);
ALboolean alIsSource(ALuint source);
void alSourcef (ALuintsource, ALenum param, ALfloat value);
void alSource3f (ALuintsource, ALenum param, ALfloat v1, ALfloat v2, ALfloat v3);
void alSourcefv (ALuintsource, ALenum param, ALfloat *values);
void alSourcei (ALuintsource, ALenum param, ALint value);
void alSource3i (ALuintsource, ALenum param, ALint v1, ALint v2, ALint v3);
void alSourceiv (ALuintsource, ALenum param, ALint *values);
void alGetSourcef(ALuint source, ALenum param, ALfloat *value);
void alGetSource3f(ALuint source, ALenum param, ALfloat *v1, ALfloat *v2, ALfloat *v3);
void alGetSourcefv(ALuint source, ALenum param, ALfloat *values);
void alGetSourcei(ALuint source, ALenum param, ALint *value);
void alGetSource3i(ALuint source, ALenum param, ALint *v1, ALint *v2, ALint *v3);
void alGetSourceiv(ALuint source, ALenum param, ALint *values);
void alSourcePlay(ALuint source);
void alSourcePause(ALuint source);
void alSourceStop(ALuint source);
void alSourceRewind(ALuint source); //停止source并将其状态设置为AL_INITIAL
void alSourcePlayv(ALsizei n, ALuint *sources); //播放一系列source
void alSourcePausev(ALsizei n, ALuint *sources);
void alSourceStopv(ALsizei n, ALuint *sources);
void alSourceRewindv(ALsizei n, ALuint *sources);
voidalSourceQueueBuffers (ALuint source, ALsizei n, ALuint *buffers); //alGetSourcei(source,
AL_BUFFERS_PROCESSED,&x)获取已经处理了的buffer数
voidalSourceUnqueueBuffers (ALuint source, ALsizei n, ALuint *buffers);
3. listener函数
void alListenerf(ALenum param, ALfloat value);
void alListener3f(ALenum param, ALfloat v1, ALfloat v2, ALfloat v3);
void alListenerfv(ALenum param, ALfloat *values);
void alListeneri(ALenum param, ALint value);
void alListener3i(ALenum param, ALint v1, ALint v2, ALint v3);
void alListeneriv(ALenum param, ALint *values);
void alGetListenerf(ALenum param, ALfloat *value);
void alGetListener3f(ALenum param, ALfloat *v1, ALfloat *v2, ALfloat *v3);
void alGetListenerfv(ALenum param, ALfloat *values);
void alGetListeneri(ALenum param, ALint *value);
void alGetListener3i(ALenum param, ALint *v1, ALint *v2, ALint *v3);
void alGetListeneriv(ALenum param, ALint *values);
4. 状态函数
AL_DOPPLER_FACTOR f 全局多普勒系数
AL_SPEED_OF_SOUND f 声音的每秒传播速度
AL_DISTANCE_MODEL i 距离模型枚举值
void alEnable (ALenumcapability); //使能某项功能
void alDisable (ALenumcapability);
ALboolean alIsEnabled(ALenum capability);
// FIXME:这一堆不知道是干吗的。。。
ALboolean alGetBoolean(ALenum param);
ALdouble alGetDouble(ALenum param);
ALfloat alGetFloat(ALenum param);
ALint alGetInteger(ALenum param);
void alGetBooleanv(ALenum param, ALboolean *data);
void alGetDoublev(ALenum param, ALdouble *data);
void alGetFloatv(ALenum param, ALfloat *data);
void alGetIntegerv(ALenum param, ALint *data);
const Alchar *alGetString (ALenum param); // param为
AL_VENDOR,AL_VERSION, AL_RENDERER, AL_EXTENSIONS
void alDopplerFactor(ALfloat value); //设置多普勒因子,默认1.0
void alSpeedOfSound(ALfloat value); //默认343.3
void alDistanceModel(ALenum value); //设置OpenAL的距离模型
AL_INVERSE_DISTANCE//倒数距离
AL_INVERSE_DISTANCE_CLAMPED//默认值
AL_LINEAR_DISTANCE //线性距离
AL_LINEAR_DISTANCE_CLAMPED
AL_EXPONENT_DISTANCE//指数距离
AL_EXPONENT_DISTANCE_CLAMPED
AL_NONE
//这两个参数是计算距离中用的,公式参考原版文档,总之越近增益越大
AL_REFERENCE_DISTANCE//参考距离
AL_ROLLOFF_FACTOR //衰减因子
5. 错误函数
ALenum alGetError(ALvoid);
6. extension函数
ALbooleanalIsExtensionPresent (const ALchar *extname); //extension有效时返回AL_TRUE
void * alGetProcAddress(const ALchar *fname); //返回指定的函数指针或者NULL
ALenum alGetEnumValue(const ALchar *ename); //返回ename描述的ALenum或者NULL
7. context函数
ALC_FREQUENCY l 输出频率
ALC_MONO_SOURCES l 请求的单声道source数
ALC_STEREO_SOURCES l 请求的双声道source数
ALC_REFRESH l context运行的刷新率
ALC_SYNC i 同步context的标志位
ALContext *alcCreateContext (ALCdevice *device, ALCint *attrlist);
attrlist:上述属性集的指针,可以是NULL或以0结尾的列表,列表中每一项是属性名和属性值组成的数对
ALCbooleanalcMakeContextCurrent (ALCcontext *context);
void alcProcessContext(ALCcontext *context); //通知指定context开始运行
void alcSuspendContext(ALCcontext *context); //这两个组合使用可以使状态的改变迅速生效
void alcDestroyContext(ALCcontext *context); //关闭非当前的context
ALCcontext*alcGetCurrentContext (ALCvoid);
ALCdevice*alcGetContextDevice (ALCcontext *context);
8. context错误函数
ALCenum alcGetError(ALCdevice *device);
9. contextdevice函数
ALCdevice*alcOpenDevice (const ALCchar *devicename);
ALCbooleanalcCloseDevice (ALCdevice *device);
10. contextextension函数
ALCbooleanalcIsExtensionPresent (ALCdevice *device, const ALCchar *extName);
void* alcGetProcAddress(ALCdevice *device, const ALCchar *funcName);
ALCenum alcGetEnumValue(ALCdevice *device, const ALCchar *enumName);
11. context状态函数
const ALCchar *alcGetString (ALCdevice *device, ALenum param);
属性: ALC_DEFAULT_DEVICE_SPECIFIER
ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER
ALC_DEVICE_SPECIFIER
ALC_CAPTURE_DEVICE_SPECIFIER
ALC_EXTENSIONS
void alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *data);
param: ALC_MAJOR_VERSION,ALC_MINOR_VERSION,
ALC_ATTRIBUTES_SIZE,ALC_ALL_ATTRIBUTES
size: 传入的目标buffer的大小
12. context 捕捉函数
ALCdevice*alcCaptureOpenDevice (const ALCchar *devicename, ALCuint frequency, ALCenum format,ALCsizei buffersize);
frequency: 捕捉的频率
ALCbooleanalcCaptureCloseDevice (ALCdevice *device);
void alcCaptureStart(ALCdevice *device); //启动捕捉,数据存入一个内部环形buffer,buffer大小是opendevice时候传入。通过alcGetIntegerv和ALC_CAPTURE_SAMPLES可以获得当前有效采样数,然后可用alcCaptureSamples获得已经采样的样本。
void alcCaptureStop(ALCdevice *device);
void alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples);