30template <
typename SampleType>
37template <
typename SampleType>
43template <
typename SampleType>
53template <
typename SampleType>
59 sampleRate =
spec.sampleRate;
62 s1.resize (
spec.numChannels);
63 s2.resize (
spec.numChannels);
64 s3.resize (
spec.numChannels);
65 s4.resize (
spec.numChannels);
70template <
typename SampleType>
73 for (
auto s : { &s1, &s2, &s3, &s4 })
74 std::fill (s->begin(), s->end(),
static_cast<SampleType
> (0));
77template <
typename SampleType>
80 for (
auto s : { &s1, &s2, &s3, &s4 })
81 for (
auto& element : *s)
82 util::snapToZero (element);
86template <
typename SampleType>
97 if (filterType == Type::allpass)
100 auto yH2 = ((filterType == Type::lowpass ?
yL :
yH) - (R2 + g) * s3[(
size_t) channel] - s4[(
size_t) channel]) * h;
108 return filterType == Type::lowpass ?
yL2 :
yH2;
111template <
typename SampleType>
122 auto yH2 = (
yL - (R2 + g) * s3[(
size_t) channel] - s4[(
size_t) channel]) * h;
134template <
typename SampleType>
139 h = (SampleType) (1.0 / (1.0 + R2 * g + g * g));
A filter class designed to perform multi-band separation using the TPT (Topology-Preserving Transform...
void prepare(const ProcessSpec &spec)
Initialises the filter.
void setType(Type newType)
Sets the filter type.
void reset()
Resets the internal state variables of the filter.
LinkwitzRileyFilter()
Constructor.
SampleType processSample(int channel, SampleType inputValue)
Performs the filter operation on a single sample at a time.
void setCutoffFrequency(SampleType newCutoffFrequencyHz)
Sets the cutoff frequency of the filter in Hz.
void snapToZero() noexcept
Ensure that the state variables are rounded to zero if the state variables are denormals.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Returns true if a value is at least zero, and also below a specified upper limit.
Commonly used mathematical constants.
This structure is passed into a DSP algorithm's prepare() method, and contains information about vari...