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

A signal-dependent fractional delay filter. More...

#include <nonlinear.h>

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

Public Member Functions

 SignalDependentFractionalDelay (const SignalDependentFractionalDelayOptions &options={})
 Constructs a signal-dependent fractional delay.
 
void SetD (float d)
 Sets the interpolation weight.
 
float GetD () const noexcept SFFDN_NONBLOCKING
 Returns the interpolation weight.
 
float Tick (float input) noexcept SFFDN_NONBLOCKING
 Processes a single sample.
 
void Process (const AudioBuffer &input, AudioBuffer &output) noexcept SFFDN_NONBLOCKING override
 Processes the audio buffer.
 
uint32_t InputChannelCount () const noexcept SFFDN_NONBLOCKING override
 Returns the number of input channels this processor expects.
 
uint32_t OutputChannelCount () const noexcept SFFDN_NONBLOCKING override
 Returns the number of output channels this processor produces.
 
void Clear () override
 Clears the delay state.
 
std::unique_ptr< AudioProcessorClone () const override
 Creates a copy of the processor.
 
- 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

A signal-dependent fractional delay filter.

Implements the filter of Fig. 5 of the paper, after J. R. Pierce and S. A. Van Duyne, "A passive nonlinear digital filter design which facilitates physics-based sound synthesis of highly nonlinear musical instruments", J. Acoust. Soc. Amer., 1997, and V. Välimäki, T. Tolonen and M. Karjalainen, "Signal-dependent nonlinearities for physical models using time-varying fractional delay filters", Proc. ICMC, 1998.

The input is split into its positive and negative half-wave rectified components, each is delayed by a different fractional amount, and the two are summed:

\[ p(n) = \max(x(n), 0), \qquad q(n) = \min(x(n), 0), \\ y(n) = d\,q(n) + (1 - d)\,q(n-1) + d\,p(n-2) + (1 - d)\,p(n-1). \]

The two interpolators are linear and carry complementary weights, so the positive component is delayed by \(1 + d\) samples and the negative one by \(1 - d\). The result keeps the fundamental and the overall amplitude of a sinusoidal input but distorts it around its zero crossings, generating even harmonics. It is a milder effect than ControllableFullWaveRectifier, and a good alternative to it on sustained input.

Note
The delayed positive and negative components overlap by up to one sample, so a zero-mean periodic signal can lose up to one sample of energy per period. The operation is therefore slightly lossy rather than strictly energy preserving, and the loss grows with frequency. It does not endanger the stability of the enclosing network. It needs no dc blocker.

Constructor & Destructor Documentation

◆ SignalDependentFractionalDelay()

sfFDN::SignalDependentFractionalDelay::SignalDependentFractionalDelay ( const SignalDependentFractionalDelayOptions & options = {})
explicit

Constructs a signal-dependent fractional delay.

Parameters
optionsThe configuration options.
Exceptions
std::invalid_argumentif d is not in [0, 1].

Member Function Documentation

◆ Clear()

void sfFDN::SignalDependentFractionalDelay::Clear ( )
overridevirtual

Clears the delay state.

The interpolation weight is left untouched.

Implements sfFDN::AudioProcessor.

◆ Clone()

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

Creates a copy of the processor.

The delay state is carried over.

Implements sfFDN::AudioProcessor.

◆ InputChannelCount()

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

Returns the number of input channels this processor expects.

This is always 1.

Implements sfFDN::AudioProcessor.

◆ OutputChannelCount()

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

Returns the number of output channels this processor produces.

This is always 1.

Implements sfFDN::AudioProcessor.

◆ Process()

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

Processes the audio buffer.

Note
The input and output buffers must have one channel and the same number of samples.

Implements sfFDN::AudioProcessor.

◆ SetD()

void sfFDN::SignalDependentFractionalDelay::SetD ( float d)

Sets the interpolation weight.

Parameters
dThe interpolation weight, in [0, 1].
Exceptions
std::invalid_argumentif d is not in [0, 1].

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