effectslot.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef CORE_EFFECTSLOT_H
  2. #define CORE_EFFECTSLOT_H
  3. #include <atomic>
  4. #include <memory>
  5. #include "device.h"
  6. #include "effects/base.h"
  7. #include "flexarray.h"
  8. #include "intrusive_ptr.h"
  9. struct EffectSlot;
  10. struct WetBuffer;
  11. using EffectSlotArray = al::FlexArray<EffectSlot*>;
  12. enum class EffectSlotType : unsigned char {
  13. None,
  14. Reverb,
  15. Chorus,
  16. Autowah,
  17. Compressor,
  18. Convolution,
  19. Dedicated,
  20. Distortion,
  21. Echo,
  22. Equalizer,
  23. Flanger,
  24. FrequencyShifter,
  25. PitchShifter,
  26. RingModulator,
  27. VocalMorpher,
  28. };
  29. struct EffectSlotProps {
  30. float Gain;
  31. bool AuxSendAuto;
  32. EffectSlot *Target;
  33. EffectSlotType Type;
  34. EffectProps Props;
  35. al::intrusive_ptr<EffectState> State;
  36. std::atomic<EffectSlotProps*> next;
  37. };
  38. struct EffectSlot {
  39. bool InUse{false};
  40. std::atomic<EffectSlotProps*> Update{nullptr};
  41. /* Wet buffer configuration is ACN channel order with N3D scaling.
  42. * Consequently, effects that only want to work with mono input can use
  43. * channel 0 by itself. Effects that want multichannel can process the
  44. * ambisonics signal and make a B-Format source pan.
  45. */
  46. MixParams Wet;
  47. float Gain{1.0f};
  48. bool AuxSendAuto{true};
  49. EffectSlot *Target{nullptr};
  50. EffectSlotType EffectType{EffectSlotType::None};
  51. EffectProps mEffectProps{};
  52. al::intrusive_ptr<EffectState> mEffectState;
  53. float RoomRolloff{0.0f}; /* Added to the source's room rolloff, not multiplied. */
  54. float DecayTime{0.0f};
  55. float DecayLFRatio{0.0f};
  56. float DecayHFRatio{0.0f};
  57. bool DecayHFLimit{false};
  58. float AirAbsorptionGainHF{1.0f};
  59. /* Mixing buffer used by the Wet mix. */
  60. al::vector<FloatBufferLine,16> mWetBuffer;
  61. static std::unique_ptr<EffectSlotArray> CreatePtrArray(size_t count);
  62. };
  63. #endif /* CORE_EFFECTSLOT_H */