alEffect.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 Delay;
  115. ALfloat LowCutoff;
  116. ALfloat LowGain;
  117. ALfloat Mid1Center;
  118. ALfloat Mid1Gain;
  119. ALfloat Mid1Width;
  120. ALfloat Mid2Center;
  121. ALfloat Mid2Gain;
  122. ALfloat Mid2Width;
  123. ALfloat HighCutoff;
  124. ALfloat HighGain;
  125. } Equalizer;
  126. struct {
  127. ALint Waveform;
  128. ALint Phase;
  129. ALfloat Rate;
  130. ALfloat Depth;
  131. ALfloat Feedback;
  132. ALfloat Delay;
  133. } Flanger;
  134. struct {
  135. ALfloat Frequency;
  136. ALfloat HighPassCutoff;
  137. ALint Waveform;
  138. } Modulator;
  139. struct {
  140. ALfloat Gain;
  141. } Dedicated;
  142. } ALeffectProps;
  143. typedef struct ALeffect {
  144. // Effect type (AL_EFFECT_NULL, ...)
  145. ALenum type;
  146. ALeffectProps Props;
  147. const struct ALeffectVtable *vtbl;
  148. /* Self ID */
  149. ALuint id;
  150. } ALeffect;
  151. inline struct ALeffect *LookupEffect(ALCdevice *device, ALuint id)
  152. { return (struct ALeffect*)LookupUIntMapKey(&device->EffectMap, id); }
  153. inline struct ALeffect *RemoveEffect(ALCdevice *device, ALuint id)
  154. { return (struct ALeffect*)RemoveUIntMapKey(&device->EffectMap, id); }
  155. inline ALboolean IsReverbEffect(ALenum type)
  156. { return type == AL_EFFECT_REVERB || type == AL_EFFECT_EAXREVERB; }
  157. ALenum InitEffect(ALeffect *effect);
  158. ALvoid ReleaseALEffects(ALCdevice *device);
  159. ALvoid LoadReverbPreset(const char *name, ALeffect *effect);
  160. #ifdef __cplusplus
  161. }
  162. #endif
  163. #endif