🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
2.4 KiB

  1. #ifndef _AL_AUXEFFECTSLOT_H_
  2. #define _AL_AUXEFFECTSLOT_H_
  3. #include <array>
  4. #include "alMain.h"
  5. #include "alEffect.h"
  6. #include "ambidefs.h"
  7. #include "effects/base.h"
  8. #include "almalloc.h"
  9. #include "atomic.h"
  10. struct ALeffectslot;
  11. using ALeffectslotArray = al::FlexArray<ALeffectslot*>;
  12. struct ALeffectslotProps {
  13. ALfloat Gain;
  14. ALboolean AuxSendAuto;
  15. ALeffectslot *Target;
  16. ALenum Type;
  17. EffectProps Props;
  18. EffectState *State;
  19. std::atomic<ALeffectslotProps*> next;
  20. };
  21. struct ALeffectslot {
  22. ALfloat Gain{1.0f};
  23. ALboolean AuxSendAuto{AL_TRUE};
  24. ALeffectslot *Target{nullptr};
  25. struct {
  26. ALenum Type{AL_EFFECT_NULL};
  27. EffectProps Props{};
  28. EffectState *State{nullptr};
  29. } Effect;
  30. std::atomic_flag PropsClean;
  31. RefCount ref{0u};
  32. std::atomic<ALeffectslotProps*> Update{nullptr};
  33. struct {
  34. ALfloat Gain{1.0f};
  35. ALboolean AuxSendAuto{AL_TRUE};
  36. ALeffectslot *Target{nullptr};
  37. ALenum EffectType{AL_EFFECT_NULL};
  38. EffectProps mEffectProps{};
  39. EffectState *mEffectState{nullptr};
  40. ALfloat RoomRolloff{0.0f}; /* Added to the source's room rolloff, not multiplied. */
  41. ALfloat DecayTime{0.0f};
  42. ALfloat DecayLFRatio{0.0f};
  43. ALfloat DecayHFRatio{0.0f};
  44. ALboolean DecayHFLimit{AL_FALSE};
  45. ALfloat AirAbsorptionGainHF{1.0f};
  46. } Params;
  47. /* Self ID */
  48. ALuint id{};
  49. /* Mixing buffer used by the Wet mix. */
  50. al::vector<std::array<ALfloat,BUFFERSIZE>,16> MixBuffer;
  51. /* Wet buffer configuration is ACN channel order with N3D scaling.
  52. * Consequently, effects that only want to work with mono input can use
  53. * channel 0 by itself. Effects that want multichannel can process the
  54. * ambisonics signal and make a B-Format source pan.
  55. */
  56. MixParams Wet;
  57. ALeffectslot() { PropsClean.test_and_set(std::memory_order_relaxed); }
  58. ALeffectslot(const ALeffectslot&) = delete;
  59. ALeffectslot& operator=(const ALeffectslot&) = delete;
  60. ~ALeffectslot();
  61. static ALeffectslotArray *CreatePtrArray(size_t count) noexcept;
  62. DEF_PLACE_NEWDEL()
  63. };
  64. ALenum InitEffectSlot(ALeffectslot *slot);
  65. void UpdateEffectSlotProps(ALeffectslot *slot, ALCcontext *context);
  66. void UpdateAllEffectSlotProps(ALCcontext *context);
  67. ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect *effect);
  68. #endif