29enum class FirstOrderTPTFilterType
52template <
typename SampleType>
57 using Type = FirstOrderTPTFilterType;
88 void reset (SampleType newValue);
92 template <
typename ProcessContext>
95 const auto& inputBlock = context.getInputBlock();
96 auto& outputBlock = context.getOutputBlock();
97 const auto numChannels = outputBlock.getNumChannels();
98 const auto numSamples = outputBlock.getNumSamples();
100 jassert (inputBlock.getNumChannels() <= s1.
size());
101 jassert (inputBlock.getNumChannels() == numChannels);
102 jassert (inputBlock.getNumSamples() == numSamples);
104 if (context.isBypassed)
106 outputBlock.copyFrom (inputBlock);
110 for (
size_t channel = 0; channel < numChannels; ++channel)
112 auto*
inputSamples = inputBlock .getChannelPointer (channel);
113 auto*
outputSamples = outputBlock.getChannelPointer (channel);
115 for (
size_t i = 0; i < numSamples; ++i)
119 #if JUCE_DSP_ENABLE_SNAP_TO_ZERO
140 std::vector<SampleType> s1 { 2 };
141 double sampleRate = 44100.0;
144 Type filterType = Type::lowpass;
145 SampleType cutoffFrequency = 1000.0;
A first order filter class using the TPT (Topology-Preserving Transform) structure.
Type getType() const noexcept
Returns the type of the filter.
SampleType getCutoffFrequency() const noexcept
Returns the cutoff frequency of the filter.
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 process(const ProcessContext &context) noexcept
Processes the input and output samples supplied in the processing context.
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.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
This structure is passed into a DSP algorithm's prepare() method, and contains information about vari...