30template <
typename SampleType>
37template <
typename SampleType>
40 filterType = newValue;
43template <
typename SampleType>
48 cutoffFrequency = newValue;
53template <
typename SampleType>
66template <
typename SampleType>
69 reset (
static_cast<SampleType
> (0));
72template <
typename SampleType>
75 std::fill (s1.begin(), s1.end(), newValue);
79template <
typename SampleType>
82 auto& s = s1[(
size_t) channel];
84 auto v = G * (inputValue - s);
90 case Type::lowpass:
return y;
91 case Type::highpass:
return inputValue - y;
92 case Type::allpass:
return 2 * y - inputValue;
100template <
typename SampleType>
104 util::snapToZero (s);
108template <
typename SampleType>
116template class FirstOrderTPTFilter<float>;
117template class FirstOrderTPTFilter<double>;
A first order filter class using the TPT (Topology-Preserving Transform) structure.
void prepare(const ProcessSpec &spec)
Initialises the filter.
void snapToZero() noexcept
Ensure that the state variables are rounded to zero if the state variables are denormals.
SampleType processSample(int channel, SampleType inputValue)
Processes one sample at a time on a given channel.
FirstOrderTPTFilter()
Constructor.
void setType(Type newType)
Sets the filter type.
void setCutoffFrequency(SampleType newFrequencyHz)
Sets the cutoff frequency of the filter.
void reset()
Resets the internal state variables of the filter.
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...
uint32 numChannels
The number of channels that the process() method will be expected to handle.
double sampleRate
The sample rate that will be used for the data that is sent to the processor.