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

A simple non-interpolating delay line implementation. More...

#include <delay.h>

Public Member Functions

 Delay (uint32_t delay=0, uint32_t max_delay=4095)
 Constructs a delay line with a specified delay and maximum delay.
 
void Clear ()
 Clears the delay line, resetting the internal buffer.
 
void SetMaximumDelay (uint32_t delay)
 Sets the maximum delay for the delay line.
 
uint32_t GetMaximumDelay () const
 Gets the maximum delay-line length.
 
void SetDelay (uint32_t delay)
 Sets the delay for the delay line.
 
uint32_t GetDelay (void) const
 Returns the current delay in samples.
 
float LastOut () const
 Returns the last output sample from the delay line.
 
float NextOut () const
 Returns the next output sample.
 
float Tick (float input)
 Processes the next input sample.
 
float TapOut (uint32_t tap) const
 Taps the output of the delay line at a specific point.
 
void Process (const AudioBuffer input, AudioBuffer &output)
 Processes a block of input samples.
 
bool AddNextInputs (std::span< const float > input)
 Adds the next input samples to the delay line.
 
void GetNextOutputs (std::span< float > output)
 Gets the next output samples from the delay line.
 
void GetNextOutputsAt (std::span< uint32_t > taps, std::span< float > output, std::span< float > coeffs)
 Gets the next output samples from the delay line at specific tap points.
 
std::span< float > GetNextOutputBuffers (uint32_t size)
 Get a span pointing to the next writable region of the buffer.
 
std::span< float > GetNextInputBuffers (uint32_t size)
 Get a span pointing to the next writable region of the buffer.
 
void GetNextReadAndWriteBuffers (std::span< float > &read_buffer, std::span< float > &write_buffer, uint32_t size)
 Gets the next read and write buffers for the delay line.
 
void AdvanceWrite (uint32_t sample_count)
 Advances the write pointer of the delay line by a specified number of samples.
 
void AdvanceRead (uint32_t sample_count)
 Advances the read pointer of the delay line by a specified number of samples.
 

Detailed Description

A simple non-interpolating delay line implementation.

Constructor & Destructor Documentation

◆ Delay()

sfFDN::Delay::Delay ( uint32_t delay = 0,
uint32_t max_delay = 4095 )

Constructs a delay line with a specified delay and maximum delay.

Parameters
delayThe initial delay in samples.
max_delayThe maximum delay in samples, ie. the size of the internal buffer.

Member Function Documentation

◆ AddNextInputs()

bool sfFDN::Delay::AddNextInputs ( std::span< const float > input)

Adds the next input samples to the delay line.

Parameters
inputThe input samples to add.
Returns
True if the samples were added successfully, false otherwise.
Note
A return value of false indicates that there was not enough space in the internal buffer to write the input samples. In this case, the internal state remains unchanged. When processing audio in blocks, the delay line maximum delay should be set to a value that is larger than the block size.

◆ AdvanceRead()

void sfFDN::Delay::AdvanceRead ( uint32_t sample_count)

Advances the read pointer of the delay line by a specified number of samples.

Parameters
sample_countThe number of samples to advance the read pointer.

◆ AdvanceWrite()

void sfFDN::Delay::AdvanceWrite ( uint32_t sample_count)

Advances the write pointer of the delay line by a specified number of samples.

Parameters
sample_countThe number of samples to advance the write pointer.

◆ Clear()

void sfFDN::Delay::Clear ( )

Clears the delay line, resetting the internal buffer.

The delay value remains unchanged.

◆ GetMaximumDelay()

uint32_t sfFDN::Delay::GetMaximumDelay ( ) const

Gets the maximum delay-line length.

Returns
The maximum delay in samples.

◆ GetNextInputBuffers()

std::span< float > sfFDN::Delay::GetNextInputBuffers ( uint32_t size)

Get a span pointing to the next writable region of the buffer.

Parameters
sizeThe desired size of the buffer.
Returns
std::span<float>

Need to call AdvanceWrite after writing to the buffer to update the internal state of the delay line.

◆ GetNextOutputBuffers()

std::span< float > sfFDN::Delay::GetNextOutputBuffers ( uint32_t size)

Get a span pointing to the next writable region of the buffer.

Parameters
sizeThe desired size of the buffer.
Returns
std::span<float>

Need to call AdvanceRead after reading from the buffer to update the internal state of the delay line.

◆ GetNextOutputs()

void sfFDN::Delay::GetNextOutputs ( std::span< float > output)

Gets the next output samples from the delay line.

Parameters
outputThe output samples to fill.

◆ GetNextOutputsAt()

void sfFDN::Delay::GetNextOutputsAt ( std::span< uint32_t > taps,
std::span< float > output,
std::span< float > coeffs )

Gets the next output samples from the delay line at specific tap points.

Parameters
tapsThe tap points in samples.
outputThe output samples to fill.
coeffsThe coefficients to apply to each tap point when filling the output buffer. Must have the same size as taps.

◆ GetNextReadAndWriteBuffers()

void sfFDN::Delay::GetNextReadAndWriteBuffers ( std::span< float > & read_buffer,
std::span< float > & write_buffer,
uint32_t size )

Gets the next read and write buffers for the delay line.

Parameters
read_bufferThe span to fill with the next readable region of the buffer.
write_bufferThe span to fill with the next writable region of the buffer.
sizeThe desired size of the buffers.

◆ LastOut()

float sfFDN::Delay::LastOut ( ) const

Returns the last output sample from the delay line.

Returns
The last output sample.

◆ NextOut()

float sfFDN::Delay::NextOut ( ) const

Returns the next output sample.

Returns
The next output sample.

◆ Process()

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

Processes a block of input samples.

Parameters
inputThe input audio buffer.
outputThe output audio buffer.
Note
The input and output buffers must have the same sample count and a channel count of 1 (mono).
The input samples are added to the delay line, and the output samples are read from the delay line.

◆ SetDelay()

void sfFDN::Delay::SetDelay ( uint32_t delay)

Sets the delay for the delay line.

Parameters
delayThe delay in samples.

◆ SetMaximumDelay()

void sfFDN::Delay::SetMaximumDelay ( uint32_t delay)

Sets the maximum delay for the delay line.

Parameters
delayThe maximum delay in samples.
Note
This can increase the size of the internal buffer if the new maximum delay is larger than the current buffer size.

◆ TapOut()

float sfFDN::Delay::TapOut ( uint32_t tap) const

Taps the output of the delay line at a specific point.

Parameters
tapThe tap point in samples.
Returns
The output sample at the tap point.

◆ Tick()

float sfFDN::Delay::Tick ( float input)

Processes the next input sample.

Parameters
inputThe input sample to process.
Returns
The processed output sample.

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