DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
dspark::BucketBrigade< T > Class Template Reference

One bucket-brigade delay line (one channel). More...

#include <BucketBrigade.h>

Public Types

enum class  Precision { Standard , High }
 How the line reads its input and its output (setPrecision()). More...
 
enum class  Shape { Butterworth , Chorus }
 The pair of filters around the chain (setShape()). More...
 

Public Member Functions

void prepare (double sampleRate, int stages, double cornerHz, int factor=1)
 Allocates the chain and designs the filters.
 
void setShape (Shape shape) noexcept
 The pair of filters around the chain; takes effect from the next corner set.
 
Shape getShape () const noexcept
 
void reset () noexcept
 Empties the chain and the filters.
 
void setCorner (double hz) noexcept
 Corner of the input and output low-passes, 200 Hz to 0.45 of the host's rate.
 
void setCorners (double inputHz, double outputHz) noexcept
 Corners of the input and the output low-passes, each 200 Hz to 0.45 of the host's rate (non-finite values are ignored). Set before the line runs (or after prepare()) they take effect at once; while it runs they glide over 32 steps of the line.
 
void setCornersNow (double inputHz, double outputHz) noexcept
 The corners taken at once, without the glide: for an owner that moves them every sample itself. Non-finite values are ignored.
 
int getStages () const noexcept
 
double getCorner () const noexcept
 
double getOutputCorner () const noexcept
 
int getFactor () const noexcept
 
void setPrecision (Precision precision) noexcept
 How the line reads its input and its output (out-of-range values read as Standard); call reset() after a change.
 
Precision getPrecision () const noexcept
 
double clockFor (double delaySeconds) const noexcept
 The clock rate a delay needs, in hertz.
 
double delayFor (double wantedSeconds) const noexcept
 The delay to ask of processSample() for the whole device to be late by wantedSeconds.
 
T processSample (T input, double delaySeconds) noexcept
 One host sample through the device.
 
void processPair (BucketBrigade &twin, T input, double delayThis, double delayTwin, double &outThis, double &outTwin) noexcept
 One host sample through this line and a twin, sharing this line's input low-pass (the twin's own is not used).
 

Static Public Attributes

static constexpr int kMinStages = 64
 Smallest chain.
 
static constexpr int kMaxStages = 8192
 Largest chain.
 

Detailed Description

template<FloatType T>
class dspark::BucketBrigade< T >

One bucket-brigade delay line (one channel).

Template Parameters
TSample type (float or double); the chain and the filters run in double.

Definition at line 88 of file BucketBrigade.h.

Member Enumeration Documentation

◆ Precision

template<FloatType T>
enum class dspark::BucketBrigade::Precision
strong

How the line reads its input and its output (setPrecision()).

Enumerator
Standard 

Input by a straight line between steps, output by its average over the step (default).

High 

Input by a quintic through six steps, output by a quadratic B-spline over three (see the file notes).

Definition at line 95 of file BucketBrigade.h.

◆ Shape

template<FloatType T>
enum class dspark::BucketBrigade::Shape
strong

The pair of filters around the chain (setShape()).

Enumerator
Butterworth 

Fourth-order Butterworth low-passes at the input and the output (default).

Chorus 

Two sections of Q 0.8 at the input; a mean of two steps and a section of Q 0.6 at the output.

Definition at line 124 of file BucketBrigade.h.

Member Function Documentation

◆ clockFor()

template<FloatType T>
double dspark::BucketBrigade< T >::clockFor ( double  delaySeconds) const
inlinenoexcept

The clock rate a delay needs, in hertz.

Definition at line 207 of file BucketBrigade.h.

◆ delayFor()

template<FloatType T>
double dspark::BucketBrigade< T >::delayFor ( double  wantedSeconds) const
inlinenoexcept

The delay to ask of processSample() for the whole device to be late by wantedSeconds.

The chain is not all of the device's delay: its two low-passes add their group delay (that of two fourth-order Butterworth filters at the corner, taken at low frequencies), the held output half a clock period (the chain's delay over its number of stages) and the average over the step half a step (three and a half in high precision, which reads its input two steps back and weighs its output over three). This takes them off, so an echo lands on its time.

Parameters
wantedSecondsThe delay from the input to the output.
Returns
The delay of the chain alone (never under 10 microseconds).

Definition at line 227 of file BucketBrigade.h.

◆ getCorner()

template<FloatType T>
double dspark::BucketBrigade< T >::getCorner ( ) const
inlinenoexcept
Returns
The input low-pass's corner (the corner of both with setCorner()).

Definition at line 192 of file BucketBrigade.h.

◆ getFactor()

template<FloatType T>
int dspark::BucketBrigade< T >::getFactor ( ) const
inlinenoexcept
Returns
1, or 2 when the line runs at twice the host's rate.

Definition at line 196 of file BucketBrigade.h.

◆ getOutputCorner()

template<FloatType T>
double dspark::BucketBrigade< T >::getOutputCorner ( ) const
inlinenoexcept
Returns
The output low-pass's corner.

Definition at line 194 of file BucketBrigade.h.

◆ getPrecision()

template<FloatType T>
Precision dspark::BucketBrigade< T >::getPrecision ( ) const
inlinenoexcept
Returns
How the line reads its input and its output.

Definition at line 204 of file BucketBrigade.h.

◆ getShape()

template<FloatType T>
Shape dspark::BucketBrigade< T >::getShape ( ) const
inlinenoexcept
Returns
The pair of filters around the chain.

Definition at line 145 of file BucketBrigade.h.

◆ getStages()

template<FloatType T>
int dspark::BucketBrigade< T >::getStages ( ) const
inlinenoexcept

Definition at line 190 of file BucketBrigade.h.

◆ prepare()

template<FloatType T>
void dspark::BucketBrigade< T >::prepare ( double  sampleRate,
int  stages,
double  cornerHz,
int  factor = 1 
)
inline

Allocates the chain and designs the filters.

Parameters
sampleRateHost rate (invalid values are ignored).
stagesStages of the device (rounded to an even count, 64 to 8192).
cornerHzCorner of the input and output low-passes.
factor1 runs the line at the host's rate; 2 at twice it (see the file notes); other values read as 1.

Definition at line 109 of file BucketBrigade.h.

◆ processPair()

template<FloatType T>
void dspark::BucketBrigade< T >::processPair ( BucketBrigade< T > &  twin,
T  input,
double  delayThis,
double  delayTwin,
double &  outThis,
double &  outTwin 
)
inlinenoexcept

One host sample through this line and a twin, sharing this line's input low-pass (the twin's own is not used).

The twin must have been prepared like this line (rate, stages, factor) and carry the same corner; each line then gives what processSample() would give it on the same input.

Parameters
twinThe other line.
inputThe sample, the same for both.
delayThisThe delay of this line at this sample.
delayTwinThe delay of the twin at this sample.
outThisReceives this line's output.
outTwinReceives the twin's output.

Definition at line 268 of file BucketBrigade.h.

◆ processSample()

template<FloatType T>
T dspark::BucketBrigade< T >::processSample ( T  input,
double  delaySeconds 
)
inlinenoexcept

One host sample through the device.

Parameters
inputThe sample.
delaySecondsThe delay the clock is set for at this sample (N / (2 f_clk); at most 64 clock ticks per sample).
Returns
The delayed, held and filtered sample.

Definition at line 245 of file BucketBrigade.h.

◆ reset()

template<FloatType T>
void dspark::BucketBrigade< T >::reset ( )
inlinenoexcept

Empties the chain and the filters.

Definition at line 148 of file BucketBrigade.h.

◆ setCorner()

template<FloatType T>
void dspark::BucketBrigade< T >::setCorner ( double  hz)
inlinenoexcept

Corner of the input and output low-passes, 200 Hz to 0.45 of the host's rate.

Definition at line 163 of file BucketBrigade.h.

◆ setCorners()

template<FloatType T>
void dspark::BucketBrigade< T >::setCorners ( double  inputHz,
double  outputHz 
)
inlinenoexcept

Corners of the input and the output low-passes, each 200 Hz to 0.45 of the host's rate (non-finite values are ignored). Set before the line runs (or after prepare()) they take effect at once; while it runs they glide over 32 steps of the line.

Definition at line 171 of file BucketBrigade.h.

◆ setCornersNow()

template<FloatType T>
void dspark::BucketBrigade< T >::setCornersNow ( double  inputHz,
double  outputHz 
)
inlinenoexcept

The corners taken at once, without the glide: for an owner that moves them every sample itself. Non-finite values are ignored.

Definition at line 184 of file BucketBrigade.h.

◆ setPrecision()

template<FloatType T>
void dspark::BucketBrigade< T >::setPrecision ( Precision  precision)
inlinenoexcept

How the line reads its input and its output (out-of-range values read as Standard); call reset() after a change.

Definition at line 199 of file BucketBrigade.h.

◆ setShape()

template<FloatType T>
void dspark::BucketBrigade< T >::setShape ( Shape  shape)
inlinenoexcept

The pair of filters around the chain; takes effect from the next corner set.

Definition at line 131 of file BucketBrigade.h.

Member Data Documentation

◆ kMaxStages

template<FloatType T>
constexpr int dspark::BucketBrigade< T >::kMaxStages = 8192
staticconstexpr

Largest chain.

Definition at line 92 of file BucketBrigade.h.

◆ kMinStages

template<FloatType T>
constexpr int dspark::BucketBrigade< T >::kMinStages = 64
staticconstexpr

Smallest chain.

Definition at line 91 of file BucketBrigade.h.


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