delay_line.h 1.1 KB

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