alEffect.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. #ifndef _AL_EFFECT_H_
  2. #define _AL_EFFECT_H_
  3. #include "alMain.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. struct ALeffect;
  8. enum {
  9. EAXREVERB_EFFECT = 0,
  10. REVERB_EFFECT,
  11. CHORUS_EFFECT,
  12. COMPRESSOR_EFFECT,
  13. DISTORTION_EFFECT,
  14. ECHO_EFFECT,
  15. EQUALIZER_EFFECT,
  16. FLANGER_EFFECT,
  17. MODULATOR_EFFECT,
  18. PSHIFTER_EFFECT,
  19. DEDICATED_EFFECT,
  20. MAX_EFFECTS
  21. };
  22. extern ALboolean DisabledEffects[MAX_EFFECTS];
  23. extern ALfloat ReverbBoost;
  24. struct EffectList {
  25. const char name[16];
  26. int type;
  27. ALenum val;
  28. };
  29. #define EFFECTLIST_SIZE 12
  30. extern const struct EffectList EffectList[EFFECTLIST_SIZE];
  31. struct ALeffectVtable {
  32. void (*const setParami)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
  33. void (*const setParamiv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
  34. void (*const setParamf)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
  35. void (*const setParamfv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
  36. void (*const getParami)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
  37. void (*const getParamiv)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
  38. void (*const getParamf)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
  39. void (*const getParamfv)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
  40. };
  41. #define DEFINE_ALEFFECT_VTABLE(T) \
  42. const struct ALeffectVtable T##_vtable = { \
  43. T##_setParami, T##_setParamiv, \
  44. T##_setParamf, T##_setParamfv, \
  45. T##_getParami, T##_getParamiv, \
  46. T##_getParamf, T##_getParamfv, \
  47. }
  48. extern const struct ALeffectVtable ALeaxreverb_vtable;
  49. extern const struct ALeffectVtable ALreverb_vtable;
  50. extern const struct ALeffectVtable ALchorus_vtable;
  51. extern const struct ALeffectVtable ALcompressor_vtable;
  52. extern const struct ALeffectVtable ALdistortion_vtable;
  53. extern const struct ALeffectVtable ALecho_vtable;
  54. extern const struct ALeffectVtable ALequalizer_vtable;
  55. extern const struct ALeffectVtable ALflanger_vtable;
  56. extern const struct ALeffectVtable ALmodulator_vtable;
  57. extern const struct ALeffectVtable ALnull_vtable;
  58. extern const struct ALeffectVtable ALpshifter_vtable;
  59. extern const struct ALeffectVtable ALdedicated_vtable;
  60. typedef union ALeffectProps {
  61. struct {
  62. // Shared Reverb Properties
  63. ALfloat Density;
  64. ALfloat Diffusion;
  65. ALfloat Gain;
  66. ALfloat GainHF;
  67. ALfloat DecayTime;
  68. ALfloat DecayHFRatio;
  69. ALfloat ReflectionsGain;
  70. ALfloat ReflectionsDelay;
  71. ALfloat LateReverbGain;
  72. ALfloat LateReverbDelay;
  73. ALfloat AirAbsorptionGainHF;
  74. ALfloat RoomRolloffFactor;
  75. ALboolean DecayHFLimit;
  76. // Additional EAX Reverb Properties
  77. ALfloat GainLF;
  78. ALfloat DecayLFRatio;
  79. ALfloat ReflectionsPan[3];
  80. ALfloat LateReverbPan[3];
  81. ALfloat EchoTime;
  82. ALfloat EchoDepth;
  83. ALfloat ModulationTime;
  84. ALfloat ModulationDepth;
  85. ALfloat HFReference;
  86. ALfloat LFReference;
  87. } Reverb;
  88. struct {
  89. ALint Waveform;
  90. ALint Phase;
  91. ALfloat Rate;
  92. ALfloat Depth;
  93. ALfloat Feedback;
  94. ALfloat Delay;
  95. } Chorus; /* Also Flanger */
  96. struct {
  97. ALboolean OnOff;
  98. } Compressor;
  99. struct {
  100. ALfloat Edge;
  101. ALfloat Gain;
  102. ALfloat LowpassCutoff;
  103. ALfloat EQCenter;
  104. ALfloat EQBandwidth;
  105. } Distortion;
  106. struct {
  107. ALfloat Delay;
  108. ALfloat LRDelay;
  109. ALfloat Damping;
  110. ALfloat Feedback;
  111. ALfloat Spread;
  112. } Echo;
  113. struct {
  114. ALfloat LowCutoff;
  115. ALfloat LowGain;
  116. ALfloat Mid1Center;
  117. ALfloat Mid1Gain;
  118. ALfloat Mid1Width;
  119. ALfloat Mid2Center;
  120. ALfloat Mid2Gain;
  121. ALfloat Mid2Width;
  122. ALfloat HighCutoff;
  123. ALfloat HighGain;
  124. } Equalizer;
  125. struct {
  126. ALfloat Frequency;
  127. ALfloat HighPassCutoff;
  128. ALint Waveform;
  129. } Modulator;
  130. struct {
  131. ALint CoarseTune;
  132. ALint FineTune;
  133. } Pshifter;
  134. struct {
  135. ALfloat Gain;
  136. } Dedicated;
  137. } ALeffectProps;
  138. typedef struct ALeffect {
  139. // Effect type (AL_EFFECT_NULL, ...)
  140. ALenum type;
  141. ALeffectProps Props;
  142. const struct ALeffectVtable *vtab;
  143. /* Self ID */
  144. ALuint id;
  145. } ALeffect;
  146. #define ALeffect_setParami(o, c, p, v) ((o)->vtab->setParami(o, c, p, v))
  147. #define ALeffect_setParamf(o, c, p, v) ((o)->vtab->setParamf(o, c, p, v))
  148. #define ALeffect_setParamiv(o, c, p, v) ((o)->vtab->setParamiv(o, c, p, v))
  149. #define ALeffect_setParamfv(o, c, p, v) ((o)->vtab->setParamfv(o, c, p, v))
  150. #define ALeffect_getParami(o, c, p, v) ((o)->vtab->getParami(o, c, p, v))
  151. #define ALeffect_getParamf(o, c, p, v) ((o)->vtab->getParamf(o, c, p, v))
  152. #define ALeffect_getParamiv(o, c, p, v) ((o)->vtab->getParamiv(o, c, p, v))
  153. #define ALeffect_getParamfv(o, c, p, v) ((o)->vtab->getParamfv(o, c, p, v))
  154. inline ALboolean IsReverbEffect(ALenum type)
  155. { return type == AL_EFFECT_REVERB || type == AL_EFFECT_EAXREVERB; }
  156. void InitEffect(ALeffect *effect);
  157. void ReleaseALEffects(ALCdevice *device);
  158. void LoadReverbPreset(const char *name, ALeffect *effect);
  159. #ifdef __cplusplus
  160. }
  161. #endif
  162. #endif