delay_line.h 976 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include "common/common_types.h"
  3. namespace AudioCore {
  4. class DelayLineBase {
  5. public:
  6. DelayLineBase();
  7. ~DelayLineBase();
  8. void Initialize(s32 max_delay_, float* src_buffer);
  9. void SetDelay(s32 new_delay);
  10. s32 GetDelay() const;
  11. s32 GetMaxDelay() const;
  12. f32 TapOut(s32 last_sample);
  13. f32 Tick(f32 sample);
  14. float* GetInput();
  15. const float* GetInput() const;
  16. f32 GetOutputSample() const;
  17. void Clear();
  18. void Reset();
  19. protected:
  20. float* buffer{nullptr};
  21. float* buffer_end{nullptr};
  22. s32 max_delay{};
  23. float* input{nullptr};
  24. float* output{nullptr};
  25. s32 delay{};
  26. };
  27. class DelayLineAllPass final : public DelayLineBase {
  28. public:
  29. DelayLineAllPass();
  30. ~DelayLineAllPass();
  31. void Initialize(u32 delay, float coeffcient_, f32* src_buffer);
  32. void SetCoefficient(float coeffcient_);
  33. f32 Tick(f32 sample);
  34. void Reset();
  35. private:
  36. float coefficient{};
  37. };
  38. } // namespace AudioCore