2007-12-18 01:20:11 +00:00
|
|
|
#ifndef _AL_EFFECT_H_
|
|
|
|
#define _AL_EFFECT_H_
|
|
|
|
|
2012-09-14 09:42:36 +00:00
|
|
|
#include "alMain.h"
|
2007-12-18 01:20:11 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-05-26 05:31:24 +00:00
|
|
|
struct ALeffect;
|
2013-05-25 06:26:59 +00:00
|
|
|
|
2008-11-14 15:13:59 +00:00
|
|
|
enum {
|
2016-10-30 15:45:09 +00:00
|
|
|
AL__EAXREVERB = 0,
|
|
|
|
AL__REVERB,
|
|
|
|
AL__CHORUS,
|
|
|
|
AL__COMPRESSOR,
|
|
|
|
AL__DISTORTION,
|
|
|
|
AL__ECHO,
|
|
|
|
AL__EQUALIZER,
|
|
|
|
AL__FLANGER,
|
|
|
|
AL__MODULATOR,
|
|
|
|
AL__DEDICATED,
|
2009-04-12 23:01:10 +00:00
|
|
|
|
2008-11-14 15:13:59 +00:00
|
|
|
MAX_EFFECTS
|
|
|
|
};
|
|
|
|
extern ALboolean DisabledEffects[MAX_EFFECTS];
|
|
|
|
|
2011-07-21 05:26:16 +00:00
|
|
|
extern ALfloat ReverbBoost;
|
2011-07-21 05:53:46 +00:00
|
|
|
extern ALboolean EmulateEAXReverb;
|
2011-07-21 05:26:16 +00:00
|
|
|
|
2013-05-25 06:26:59 +00:00
|
|
|
struct ALeffectVtable {
|
2013-05-29 18:17:45 +00:00
|
|
|
void (*const setParami)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
|
|
|
|
void (*const setParamiv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
|
|
|
|
void (*const setParamf)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
|
|
|
|
void (*const setParamfv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
|
2013-05-26 05:31:24 +00:00
|
|
|
|
2013-10-07 19:56:41 +00:00
|
|
|
void (*const getParami)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
|
|
|
|
void (*const getParamiv)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
|
|
|
|
void (*const getParamf)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
|
|
|
|
void (*const getParamfv)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
|
2013-05-25 06:26:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define DEFINE_ALEFFECT_VTABLE(T) \
|
|
|
|
const struct ALeffectVtable T##_vtable = { \
|
2013-05-29 18:17:45 +00:00
|
|
|
T##_setParami, T##_setParamiv, \
|
|
|
|
T##_setParamf, T##_setParamfv, \
|
|
|
|
T##_getParami, T##_getParamiv, \
|
|
|
|
T##_getParamf, T##_getParamfv, \
|
2013-05-25 06:26:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern const struct ALeffectVtable ALeaxreverb_vtable;
|
|
|
|
extern const struct ALeffectVtable ALreverb_vtable;
|
|
|
|
extern const struct ALeffectVtable ALchorus_vtable;
|
2013-10-03 14:55:12 +00:00
|
|
|
extern const struct ALeffectVtable ALcompressor_vtable;
|
2013-05-25 06:26:59 +00:00
|
|
|
extern const struct ALeffectVtable ALdistortion_vtable;
|
|
|
|
extern const struct ALeffectVtable ALecho_vtable;
|
|
|
|
extern const struct ALeffectVtable ALequalizer_vtable;
|
|
|
|
extern const struct ALeffectVtable ALflanger_vtable;
|
|
|
|
extern const struct ALeffectVtable ALmodulator_vtable;
|
|
|
|
extern const struct ALeffectVtable ALnull_vtable;
|
|
|
|
extern const struct ALeffectVtable ALdedicated_vtable;
|
|
|
|
|
|
|
|
|
2013-05-26 05:07:31 +00:00
|
|
|
typedef union ALeffectProps {
|
2011-09-11 14:42:23 +00:00
|
|
|
struct {
|
|
|
|
// Shared Reverb Properties
|
|
|
|
ALfloat Density;
|
|
|
|
ALfloat Diffusion;
|
|
|
|
ALfloat Gain;
|
|
|
|
ALfloat GainHF;
|
|
|
|
ALfloat DecayTime;
|
|
|
|
ALfloat DecayHFRatio;
|
|
|
|
ALfloat ReflectionsGain;
|
|
|
|
ALfloat ReflectionsDelay;
|
|
|
|
ALfloat LateReverbGain;
|
|
|
|
ALfloat LateReverbDelay;
|
|
|
|
ALfloat AirAbsorptionGainHF;
|
|
|
|
ALfloat RoomRolloffFactor;
|
|
|
|
ALboolean DecayHFLimit;
|
|
|
|
|
|
|
|
// Additional EAX Reverb Properties
|
|
|
|
ALfloat GainLF;
|
|
|
|
ALfloat DecayLFRatio;
|
|
|
|
ALfloat ReflectionsPan[3];
|
|
|
|
ALfloat LateReverbPan[3];
|
|
|
|
ALfloat EchoTime;
|
|
|
|
ALfloat EchoDepth;
|
|
|
|
ALfloat ModulationTime;
|
|
|
|
ALfloat ModulationDepth;
|
|
|
|
ALfloat HFReference;
|
|
|
|
ALfloat LFReference;
|
|
|
|
} Reverb;
|
|
|
|
|
|
|
|
struct {
|
2013-10-03 14:55:12 +00:00
|
|
|
ALint Waveform;
|
|
|
|
ALint Phase;
|
|
|
|
ALfloat Rate;
|
|
|
|
ALfloat Depth;
|
2011-09-11 14:42:23 +00:00
|
|
|
ALfloat Feedback;
|
2013-10-03 14:55:12 +00:00
|
|
|
ALfloat Delay;
|
|
|
|
} Chorus;
|
2011-09-11 14:42:23 +00:00
|
|
|
|
|
|
|
struct {
|
2013-10-03 14:55:12 +00:00
|
|
|
ALboolean OnOff;
|
|
|
|
} Compressor;
|
2011-09-11 14:42:23 +00:00
|
|
|
|
|
|
|
struct {
|
2013-10-03 14:55:12 +00:00
|
|
|
ALfloat Edge;
|
2011-09-11 14:42:23 +00:00
|
|
|
ALfloat Gain;
|
2013-10-03 14:55:12 +00:00
|
|
|
ALfloat LowpassCutoff;
|
|
|
|
ALfloat EQCenter;
|
|
|
|
ALfloat EQBandwidth;
|
|
|
|
} Distortion;
|
2011-03-13 04:11:25 +00:00
|
|
|
|
2013-03-14 06:31:12 +00:00
|
|
|
struct {
|
|
|
|
ALfloat Delay;
|
2013-10-03 14:55:12 +00:00
|
|
|
ALfloat LRDelay;
|
2013-03-14 06:31:12 +00:00
|
|
|
|
2013-10-03 14:55:12 +00:00
|
|
|
ALfloat Damping;
|
2013-03-14 06:31:12 +00:00
|
|
|
ALfloat Feedback;
|
2013-10-03 14:55:12 +00:00
|
|
|
|
|
|
|
ALfloat Spread;
|
|
|
|
} Echo;
|
2013-03-14 06:31:12 +00:00
|
|
|
|
2013-05-18 08:33:01 +00:00
|
|
|
struct {
|
|
|
|
ALfloat LowCutoff;
|
|
|
|
ALfloat LowGain;
|
|
|
|
ALfloat Mid1Center;
|
|
|
|
ALfloat Mid1Gain;
|
|
|
|
ALfloat Mid1Width;
|
|
|
|
ALfloat Mid2Center;
|
|
|
|
ALfloat Mid2Gain;
|
|
|
|
ALfloat Mid2Width;
|
|
|
|
ALfloat HighCutoff;
|
|
|
|
ALfloat HighGain;
|
|
|
|
} Equalizer;
|
|
|
|
|
|
|
|
struct {
|
2013-10-03 14:55:12 +00:00
|
|
|
ALint Waveform;
|
|
|
|
ALint Phase;
|
|
|
|
ALfloat Rate;
|
|
|
|
ALfloat Depth;
|
|
|
|
ALfloat Feedback;
|
|
|
|
ALfloat Delay;
|
|
|
|
} Flanger;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
ALfloat Frequency;
|
|
|
|
ALfloat HighPassCutoff;
|
|
|
|
ALint Waveform;
|
|
|
|
} Modulator;
|
|
|
|
|
|
|
|
struct {
|
2013-05-18 08:33:01 +00:00
|
|
|
ALfloat Gain;
|
2013-10-03 14:55:12 +00:00
|
|
|
} Dedicated;
|
2013-05-26 05:07:31 +00:00
|
|
|
} ALeffectProps;
|
|
|
|
|
2013-05-26 05:31:24 +00:00
|
|
|
typedef struct ALeffect {
|
2013-05-26 05:07:31 +00:00
|
|
|
// Effect type (AL_EFFECT_NULL, ...)
|
|
|
|
ALenum type;
|
|
|
|
|
|
|
|
ALeffectProps Props;
|
2013-05-18 08:33:01 +00:00
|
|
|
|
2013-05-25 06:26:59 +00:00
|
|
|
const struct ALeffectVtable *vtbl;
|
2011-09-11 15:59:47 +00:00
|
|
|
|
2012-04-20 05:28:01 +00:00
|
|
|
/* Self ID */
|
|
|
|
ALuint id;
|
2013-05-26 05:31:24 +00:00
|
|
|
} ALeffect;
|
2007-12-18 01:20:11 +00:00
|
|
|
|
2016-05-13 06:12:11 +00:00
|
|
|
inline void LockEffectsRead(ALCdevice *device)
|
|
|
|
{ LockUIntMapRead(&device->EffectMap); }
|
|
|
|
inline void UnlockEffectsRead(ALCdevice *device)
|
|
|
|
{ UnlockUIntMapRead(&device->EffectMap); }
|
|
|
|
inline void LockEffectsWrite(ALCdevice *device)
|
|
|
|
{ LockUIntMapWrite(&device->EffectMap); }
|
|
|
|
inline void UnlockEffectsWrite(ALCdevice *device)
|
|
|
|
{ UnlockUIntMapWrite(&device->EffectMap); }
|
|
|
|
|
2013-11-04 21:51:19 +00:00
|
|
|
inline struct ALeffect *LookupEffect(ALCdevice *device, ALuint id)
|
2016-05-13 06:12:11 +00:00
|
|
|
{ return (struct ALeffect*)LookupUIntMapKeyNoLock(&device->EffectMap, id); }
|
2013-11-04 21:51:19 +00:00
|
|
|
inline struct ALeffect *RemoveEffect(ALCdevice *device, ALuint id)
|
2016-05-13 06:12:11 +00:00
|
|
|
{ return (struct ALeffect*)RemoveUIntMapKeyNoLock(&device->EffectMap, id); }
|
2013-11-04 21:51:19 +00:00
|
|
|
|
2013-11-04 20:12:31 +00:00
|
|
|
inline ALboolean IsReverbEffect(ALenum type)
|
2011-07-05 11:36:41 +00:00
|
|
|
{ return type == AL_EFFECT_REVERB || type == AL_EFFECT_EAXREVERB; }
|
2007-12-18 01:20:11 +00:00
|
|
|
|
2012-01-21 00:23:15 +00:00
|
|
|
ALenum InitEffect(ALeffect *effect);
|
2009-08-15 16:39:18 +00:00
|
|
|
ALvoid ReleaseALEffects(ALCdevice *device);
|
2007-12-18 01:20:11 +00:00
|
|
|
|
2012-03-13 22:48:51 +00:00
|
|
|
ALvoid LoadReverbPreset(const char *name, ALeffect *effect);
|
2012-01-21 00:23:15 +00:00
|
|
|
|
2007-12-18 01:20:11 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|