alEffect.h 5.0 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 = 0,
  10. REVERB,
  11. AUTOWAH,
  12. CHORUS,
  13. COMPRESSOR,
  14. DISTORTION,
  15. ECHO,
  16. EQUALIZER,
  17. FLANGER,
  18. MODULATOR,
  19. DEDICATED,
  20. MAX_EFFECTS
  21. };
  22. extern ALboolean DisabledEffects[MAX_EFFECTS];
  23. extern ALfloat ReverbBoost;
  24. extern ALboolean EmulateEAXReverb;
  25. struct ALeffectVtable {
  26. void (*const setParami)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
  27. void (*const setParamiv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
  28. void (*const setParamf)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
  29. void (*const setParamfv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
  30. void (*const getParami)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
  31. void (*const getParamiv)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
  32. void (*const getParamf)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
  33. void (*const getParamfv)(const struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
  34. };
  35. #define DEFINE_ALEFFECT_VTABLE(T) \
  36. const struct ALeffectVtable T##_vtable = { \
  37. T##_setParami, T##_setParamiv, \
  38. T##_setParamf, T##_setParamfv, \
  39. T##_getParami, T##_getParamiv, \
  40. T##_getParamf, T##_getParamfv, \
  41. }
  42. extern const struct ALeffectVtable ALeaxreverb_vtable;
  43. extern const struct ALeffectVtable ALreverb_vtable;
  44. extern const struct ALeffectVtable ALautowah_vtable;
  45. extern const struct ALeffectVtable ALchorus_vtable;
  46. extern const struct ALeffectVtable ALcompressor_vtable;
  47. extern const struct ALeffectVtable ALdistortion_vtable;
  48. extern const struct ALeffectVtable ALecho_vtable;
  49. extern const struct ALeffectVtable ALequalizer_vtable;
  50. extern const struct ALeffectVtable ALflanger_vtable;
  51. extern const struct ALeffectVtable ALmodulator_vtable;
  52. extern const struct ALeffectVtable ALnull_vtable;
  53. extern const struct ALeffectVtable ALdedicated_vtable;
  54. typedef union ALeffectProps {
  55. struct {
  56. // Shared Reverb Properties
  57. ALfloat Density;
  58. ALfloat Diffusion;
  59. ALfloat Gain;
  60. ALfloat GainHF;
  61. ALfloat DecayTime;
  62. ALfloat DecayHFRatio;
  63. ALfloat ReflectionsGain;
  64. ALfloat ReflectionsDelay;
  65. ALfloat LateReverbGain;
  66. ALfloat LateReverbDelay;
  67. ALfloat AirAbsorptionGainHF;
  68. ALfloat RoomRolloffFactor;
  69. ALboolean DecayHFLimit;
  70. // Additional EAX Reverb Properties
  71. ALfloat GainLF;
  72. ALfloat DecayLFRatio;
  73. ALfloat ReflectionsPan[3];
  74. ALfloat LateReverbPan[3];
  75. ALfloat EchoTime;
  76. ALfloat EchoDepth;
  77. ALfloat ModulationTime;
  78. ALfloat ModulationDepth;
  79. ALfloat HFReference;
  80. ALfloat LFReference;
  81. } Reverb;
  82. struct {
  83. ALfloat AttackTime;
  84. ALfloat ReleaseTime;
  85. ALfloat PeakGain;
  86. ALfloat Resonance;
  87. } Autowah;
  88. struct {
  89. ALint Waveform;
  90. ALint Phase;
  91. ALfloat Rate;
  92. ALfloat Depth;
  93. ALfloat Feedback;
  94. ALfloat Delay;
  95. } Chorus;
  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. ALint Waveform;
  127. ALint Phase;
  128. ALfloat Rate;
  129. ALfloat Depth;
  130. ALfloat Feedback;
  131. ALfloat Delay;
  132. } Flanger;
  133. struct {
  134. ALfloat Frequency;
  135. ALfloat HighPassCutoff;
  136. ALint Waveform;
  137. } Modulator;
  138. struct {
  139. ALfloat Gain;
  140. } Dedicated;
  141. } ALeffectProps;
  142. typedef struct ALeffect {
  143. // Effect type (AL_EFFECT_NULL, ...)
  144. ALenum type;
  145. ALeffectProps Props;
  146. const struct ALeffectVtable *vtbl;
  147. /* Self ID */
  148. ALuint id;
  149. } ALeffect;
  150. inline struct ALeffect *LookupEffect(ALCdevice *device, ALuint id)
  151. { return (struct ALeffect*)LookupUIntMapKey(&device->EffectMap, id); }
  152. inline struct ALeffect *RemoveEffect(ALCdevice *device, ALuint id)
  153. { return (struct ALeffect*)RemoveUIntMapKey(&device->EffectMap, id); }
  154. inline ALboolean IsReverbEffect(ALenum type)
  155. { return type == AL_EFFECT_REVERB || type == AL_EFFECT_EAXREVERB; }
  156. ALenum InitEffect(ALeffect *effect);
  157. ALvoid ReleaseALEffects(ALCdevice *device);
  158. ALvoid LoadReverbPreset(const char *name, ALeffect *effect);
  159. #ifdef __cplusplus
  160. }
  161. #endif
  162. #endif