pw_decoder.hpp (1702B)
1 #ifndef GUARD_IMMUNOSURGICALLY_SABER_TOOTHED_ZABEEHA_LIGHTS_1276 2 #define GUARD_IMMUNOSURGICALLY_SABER_TOOTHED_ZABEEHA_LIGHTS_1276 3 #pragma once 4 5 #include "channel.hpp" 6 #include "options.hpp" 7 8 #include <array> 9 #include <cstdint> 10 #include <span> 11 12 struct biquad 13 { 14 float b0, b1, b2; 15 float a1, a2; 16 float x1, x2; 17 }; 18 19 struct lr4 20 { 21 biquad bq; 22 float x1, x2; 23 float y1, y2; 24 bool active; 25 }; 26 27 class PWDecoder 28 { 29 public: 30 PWDecoder(); 31 32 void Init(float rate); 33 [[nodiscard]] std::span<const float> Decode(std::span<const float> in); 34 35 [[nodiscard]] static constexpr unsigned GetBlockSize() noexcept { return 0; } 36 [[nodiscard]] std::vector<Option> GetOptions(); 37 38 [[nodiscard]] std::vector<Channel::E> GetChannels() const; 39 [[nodiscard]] static constexpr uint32_t GetDelay() noexcept { return 0; } 40 41 private: 42 std::vector<float> buf; 43 44 float rate = -1; 45 enum class ChannelSetup { QUAD, _3P1, _5P1, _7P1 } channel_setup = ChannelSetup::_5P1; 46 bool psd = true; // Passive Surround Decoding 47 float widen = 0; 48 std::uint32_t n_taps = 0; 49 float rear_delay_ms = 12; 50 float lfe_cutoff = 150, fc_cutoff = 12'000; 51 52 std::uint32_t delay; 53 std::array<std::vector<float>, 2> buffer; 54 std::array<std::uint32_t, 2> pos; 55 std::vector<float> taps; 56 lr4 lr4[2]; 57 58 void DelayConvolveRun( 59 std::span<float> buffer, uint32_t *pos, 60 float *dst, std::size_t dst_stride, 61 const float *src, std::size_t src_stride, float vol, std::size_t n_samples); 62 63 void Mix4(std::span<const float> src); 64 void Mix3p1Base(std::span<const float> src, std::size_t stride); 65 void Mix3p1(std::span<const float> src); 66 void Mix5p1(std::span<const float> src); 67 void Mix7p1(std::span<const float> src); 68 }; 69 70 #endif