30template <
typename SampleType>
36template <
typename SampleType>
39 filterType = newValue;
42template <
typename SampleType>
51template <
typename SampleType>
61template <
typename SampleType>
67 sampleRate =
spec.sampleRate;
69 s1.resize (
spec.numChannels);
70 s2.resize (
spec.numChannels);
76template <
typename SampleType>
79 reset (
static_cast<SampleType
> (0));
82template <
typename SampleType>
85 for (
auto v : { &s1, &s2 })
86 std::fill (v->begin(), v->end(), newValue);
89template <
typename SampleType>
92 for (
auto v : { &s1, &s2 })
93 for (
auto& element : *v)
94 util::snapToZero (element);
98template <
typename SampleType>
114 case Type::lowpass:
return yLP;
115 case Type::bandpass:
return yBP;
116 case Type::highpass:
return yHP;
122template <
typename SampleType>
126 R2 =
static_cast<SampleType
> (1.0 / resonance);
127 h =
static_cast<SampleType
> (1.0 / (1.0 + R2 * g + g * g));
An IIR filter that can perform low, band and high-pass filtering on an audio signal,...
StateVariableTPTFilter()
Constructor.
void snapToZero() noexcept
Ensure that the state variables are rounded to zero if the state variables are denormals.
void setType(Type newType)
Sets the filter type.
void prepare(const ProcessSpec &spec)
Initialises the filter.
void setResonance(SampleType newResonance)
Sets the resonance of the filter.
void reset()
Resets the internal state variables of the filter.
SampleType processSample(int channel, SampleType inputValue)
Processes one sample at a time on a given channel.
void setCutoffFrequency(SampleType newFrequencyHz)
Sets the cutoff frequency of the filter.
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...