You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.7 KiB
C++
71 lines
1.7 KiB
C++
#ifndef GUARD_IMMUNOSURGICALLY_SABER_TOOTHED_ZABEEHA_LIGHTS_1276
|
|
#define GUARD_IMMUNOSURGICALLY_SABER_TOOTHED_ZABEEHA_LIGHTS_1276
|
|
#pragma once
|
|
|
|
#include "channel.hpp"
|
|
#include "options.hpp"
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include <span>
|
|
|
|
struct biquad
|
|
{
|
|
float b0, b1, b2;
|
|
float a1, a2;
|
|
float x1, x2;
|
|
};
|
|
|
|
struct lr4
|
|
{
|
|
biquad bq;
|
|
float x1, x2;
|
|
float y1, y2;
|
|
bool active;
|
|
};
|
|
|
|
class PWDecoder
|
|
{
|
|
public:
|
|
PWDecoder();
|
|
|
|
void Init(float rate);
|
|
[[nodiscard]] std::span<const float> Decode(std::span<const float> in);
|
|
|
|
[[nodiscard]] static constexpr unsigned GetBlockSize() noexcept { return 0; }
|
|
[[nodiscard]] std::vector<Option> GetOptions();
|
|
|
|
[[nodiscard]] std::vector<Channel::E> GetChannels() const;
|
|
[[nodiscard]] static constexpr uint32_t GetDelay() noexcept { return 0; }
|
|
|
|
private:
|
|
std::vector<float> buf;
|
|
|
|
float rate = -1;
|
|
enum class ChannelSetup { QUAD, _3P1, _5P1, _7P1 } channel_setup = ChannelSetup::_5P1;
|
|
bool psd = true; // Passive Surround Decoding
|
|
float widen = 0;
|
|
std::uint32_t n_taps = 0;
|
|
float rear_delay_ms = 12;
|
|
float lfe_cutoff = 150, fc_cutoff = 12'000;
|
|
|
|
std::uint32_t delay;
|
|
std::array<std::vector<float>, 2> buffer;
|
|
std::array<std::uint32_t, 2> pos;
|
|
std::vector<float> taps;
|
|
lr4 lr4[2];
|
|
|
|
void DelayConvolveRun(
|
|
std::span<float> buffer, uint32_t *pos,
|
|
float *dst, std::size_t dst_stride,
|
|
const float *src, std::size_t src_stride, float vol, std::size_t n_samples);
|
|
|
|
void Mix4(std::span<const float> src);
|
|
void Mix3p1Base(std::span<const float> src, std::size_t stride);
|
|
void Mix3p1(std::span<const float> src);
|
|
void Mix5p1(std::span<const float> src);
|
|
void Mix7p1(std::span<const float> src);
|
|
};
|
|
|
|
#endif
|