sfFDN
Loading...
Searching...
No Matches
sfFDN::AllpassFilter Class Reference

Implements a simple allpass filter with differential equation \(y(n) = g*x(n) + x(n-1) -g*y(n-1)\). More...

#include <filter.h>

Inheritance diagram for sfFDN::AllpassFilter:
[legend]
Collaboration diagram for sfFDN::AllpassFilter:
[legend]

Public Member Functions

 AllpassFilter (const AllpassFilterOptions &config={})
 Constructs an allpass filter.
 
void SetCoefficients (float coeff) noexcept SFFDN_NONBLOCKING
 Sets the allpass coefficient.
 
void WarpState (float last_in, float coeff) noexcept SFFDN_NONBLOCKING
 Re-seeds the filter state and sets a new coefficient in one step.
 
float Tick (float in) noexcept SFFDN_NONBLOCKING
 Input a sample in the filter and return the next output.
 
void Process (const AudioBuffer &input, AudioBuffer &output) noexcept SFFDN_NONBLOCKING override
 Processes a block of input samples through the filter.
 
uint32_t InputChannelCount () const noexcept SFFDN_NONBLOCKING override
 Returns the number of input channels supported by this processor.
 
uint32_t OutputChannelCount () const noexcept SFFDN_NONBLOCKING override
 Returns the number of output channels produced by this processor.
 
void Clear () override
 Clears the internal state of the processor.
 
std::unique_ptr< AudioProcessorClone () const override
 Creates a copy of the filter.
 
- Public Member Functions inherited from sfFDN::AudioProcessor

Additional Inherited Members

- Protected Member Functions inherited from sfFDN::AudioProcessor
 AudioProcessor (const AudioProcessor &)=default
 
AudioProcessoroperator= (const AudioProcessor &)=default
 
 AudioProcessor (AudioProcessor &&) noexcept=default
 
AudioProcessoroperator= (AudioProcessor &&) noexcept=default
 

Detailed Description

Implements a simple allpass filter with differential equation \(y(n) = g*x(n) + x(n-1) -g*y(n-1)\).

Member Function Documentation

◆ Clear()

void sfFDN::AllpassFilter::Clear ( )
overridevirtual

Clears the internal state of the processor.

This function resets the internal state of the filter to zero.

Implements sfFDN::AudioProcessor.

◆ Clone()

std::unique_ptr< AudioProcessor > sfFDN::AllpassFilter::Clone ( ) const
overridevirtual

Creates a copy of the filter.

Returns
A unique pointer to the cloned filter.

Implements sfFDN::AudioProcessor.

◆ InputChannelCount()

uint32_t sfFDN::AllpassFilter::InputChannelCount ( ) const
overridevirtualnoexcept

Returns the number of input channels supported by this processor.

Returns
The number of input channels.

Implements sfFDN::AudioProcessor.

◆ OutputChannelCount()

uint32_t sfFDN::AllpassFilter::OutputChannelCount ( ) const
overridevirtualnoexcept

Returns the number of output channels produced by this processor.

Returns
The number of output channels.

Implements sfFDN::AudioProcessor.

◆ Process()

void sfFDN::AllpassFilter::Process ( const AudioBuffer & input,
AudioBuffer & output )
overridevirtualnoexcept

Processes a block of input samples through the filter.

Parameters
inputThe input audio buffer.
outputThe output audio buffer. The input and output buffers must have the same number of channels and sample count.

Implements sfFDN::AudioProcessor.

◆ SetCoefficients()

void sfFDN::AllpassFilter::SetCoefficients ( float coeff)
inlinenoexcept

Sets the allpass coefficient.

Parameters
coeffThe allpass coefficient.

◆ Tick()

float sfFDN::AllpassFilter::Tick ( float in)
noexcept

Input a sample in the filter and return the next output.

Parameters
inThe input sample
Returns
The next output sample

◆ WarpState()

void sfFDN::AllpassFilter::WarpState ( float last_in,
float coeff )
inlinenoexcept

Re-seeds the filter state and sets a new coefficient in one step.

The filter is a Direct Form I first order allpass, so its state is the previous input sample and the previous output sample. When the filter is used as a fractional delay and the signal feeding it is switched to a different tap of a delay line, the stored previous input belongs to the old tap and is no longer the sample that precedes the next input. Feeding that stale sample back into Tick() injects a step into the output; this is the source of the clicks heard when an allpass interpolated delay line crosses an integer sample boundary.

Parameters
last_inThe sample that precedes the next input, i.e. the previous output of the new tap.
coeffThe new allpass coefficient.
Note
The previous output is deliberately left untouched: it is a genuine continuation of the output signal, and the remaining discontinuity decays at a rate set by the coefficient.

The documentation for this class was generated from the following file: