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

A part of a DetailFilter: minimum-phase kernels designed as a SpectralFilter designs its own (detail::MinimumPhase), at the window and padding given, convolved in partitions of a block (a quarter of that window, up to the whole of it). More...

#include <DetailFilter.h>

Public Types

using S = std::conditional_t< L==DetailLatency::Block, double, T >
 What the signal runs in: double by the block, where it costs little; T by the frame.
 

Public Member Functions

void prepare (double sampleRate, int channels, int window, int padding, int block, int steps)
 Allocates.
 
void reset () noexcept
 Clears the signal and the kernels (every one is then flat).
 
void setLinked (bool on) noexcept
 One kernel for every channel.
 
void setShortKernel (bool on) noexcept
 Kernels a window long, tapered over their whole length, from the next one designed.
 
int getLatency () const noexcept
 
int getHopSize () const noexcept
 
int getNumBins () const noexcept
 
int getTransformSize () const noexcept
 
int getKernelLength () const noexcept
 
double getBinHz () const noexcept
 
const double * getKeptKernel (int channel) const noexcept
 
template<typename Design >
void processBlock (AudioBufferView< T > buffer, Design &&design) noexcept
 Filters a block in place.
 

Detailed Description

template<FloatType T, DetailLatency L>
class dspark::detail::KernelConvolver< T, L >

A part of a DetailFilter: minimum-phase kernels designed as a SpectralFilter designs its own (detail::MinimumPhase), at the window and padding given, convolved in partitions of a block (a quarter of that window, up to the whole of it).

A kernel is designed every steps blocks. With DetailLatency::Frame the output runs through the last four as Hann frames four spacings long and one apart would play them. Their weights pair up (the first and the third add up to a half, as do the other two), so three convolutions play four kernels: their mean and the two differences. With DetailLatency::Block it runs through the last three by a quadratic B-spline. A fade between two images a moving curve at the rate of the kernels: by its first power near that rate with a raised cosine, by its square with a straight line, which then falls slowly away from it. The spline images by the cube and has no corner. Kernels are designed in double; the signal runs in double by the block (where it leaves the products of float rounding 20 dB lower for a tenth more of the cost) and in T by the frame. A flat curve returns the input to the bit, late by a block.

Audio thread, except prepare() (setup thread; allocates).

Template Parameters
TSample type (float or double).
LHow the output runs through the kernels.

Definition at line 157 of file DetailFilter.h.

Member Typedef Documentation

◆ S

template<FloatType T, DetailLatency L>
using dspark::detail::KernelConvolver< T, L >::S = std::conditional_t<L == DetailLatency::Block, double, T>

What the signal runs in: double by the block, where it costs little; T by the frame.

Definition at line 161 of file DetailFilter.h.

Member Function Documentation

◆ getBinHz()

template<FloatType T, DetailLatency L>
double dspark::detail::KernelConvolver< T, L >::getBinHz ( ) const
inlinenoexcept
Returns
Hertz a bin of the curve.

Definition at line 263 of file DetailFilter.h.

◆ getHopSize()

template<FloatType T, DetailLatency L>
int dspark::detail::KernelConvolver< T, L >::getHopSize ( ) const
inlinenoexcept
Returns
Half a window: the owner's hop, read from the low part.

Definition at line 255 of file DetailFilter.h.

◆ getKeptKernel()

template<FloatType T, DetailLatency L>
const double * dspark::detail::KernelConvolver< T, L >::getKeptKernel ( int  channel) const
inlinenoexcept
Returns
The newest kernel of a channel (0 when linked), or nullptr where it is flat.

Definition at line 265 of file DetailFilter.h.

◆ getKernelLength()

template<FloatType T, DetailLatency L>
int dspark::detail::KernelConvolver< T, L >::getKernelLength ( ) const
inlinenoexcept
Returns
Samples in a kernel.

Definition at line 261 of file DetailFilter.h.

◆ getLatency()

template<FloatType T, DetailLatency L>
int dspark::detail::KernelConvolver< T, L >::getLatency ( ) const
inlinenoexcept
Returns
The latency: a block.

Definition at line 253 of file DetailFilter.h.

◆ getNumBins()

template<FloatType T, DetailLatency L>
int dspark::detail::KernelConvolver< T, L >::getNumBins ( ) const
inlinenoexcept
Returns
The bins of a curve.

Definition at line 257 of file DetailFilter.h.

◆ getTransformSize()

template<FloatType T, DetailLatency L>
int dspark::detail::KernelConvolver< T, L >::getTransformSize ( ) const
inlinenoexcept
Returns
The transform of the design.

Definition at line 259 of file DetailFilter.h.

◆ prepare()

template<FloatType T, DetailLatency L>
void dspark::detail::KernelConvolver< T, L >::prepare ( double  sampleRate,
int  channels,
int  window,
int  padding,
int  block,
int  steps 
)
inline

Allocates.

Parameters
sampleRateThe rate this part runs at.
channelsThe channels it filters.
windowThe window the curve is designed for (a power of two, 4 at least).
paddingThe transform of the design over that window (a power of two).
blockSamples of a partition: a quarter of the window to all of it.
stepsBlocks from one kernel to the next.

Definition at line 172 of file DetailFilter.h.

◆ processBlock()

template<FloatType T, DetailLatency L>
template<typename Design >
void dspark::detail::KernelConvolver< T, L >::processBlock ( AudioBufferView< T >  buffer,
Design &&  design 
)
inlinenoexcept

Filters a block in place.

Template Parameters
Designvoid(int channel, const T* power, T* logGain, int bins): writes natural logarithms of gains (preset to 0). The power is nullptr and the channel -1 when linked. Must not throw.
Parameters
bufferThe audio.
designThe callback, run as each kernel starts.

Definition at line 281 of file DetailFilter.h.

◆ reset()

template<FloatType T, DetailLatency L>
void dspark::detail::KernelConvolver< T, L >::reset ( )
inlinenoexcept

Clears the signal and the kernels (every one is then flat).

Definition at line 233 of file DetailFilter.h.

◆ setLinked()

template<FloatType T, DetailLatency L>
void dspark::detail::KernelConvolver< T, L >::setLinked ( bool  on)
inlinenoexcept

One kernel for every channel.

Definition at line 248 of file DetailFilter.h.

◆ setShortKernel()

template<FloatType T, DetailLatency L>
void dspark::detail::KernelConvolver< T, L >::setShortKernel ( bool  on)
inlinenoexcept

Kernels a window long, tapered over their whole length, from the next one designed.

Definition at line 250 of file DetailFilter.h.


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