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

Minimum-phase filtering by a curve on a log-frequency grid, fine in the low end. More...

#include <DetailFilter.h>

Public Member Functions

void prepare (const AudioSpec &spec)
 Allocates for a layout (an invalid spec is ignored; channels over kMaxChannels pass through).
 
void reset () noexcept
 Clears the signal and the curves.
 
void setLinked (bool on) noexcept
 One curve and one filter for every channel.
 
bool isLinked () const noexcept
 
void setShortKernel (bool on) noexcept
 Cuts the kernels of the high part (all but the fine detail of the low end) to its window and tapers them over their whole length, from the next one designed (off by default: a kernel keeps the room the padding leaves, with only its tail tapered). A cut there then rings for a shorter time after the event, at the same depth; the fine detail of the low end keeps the length it takes.
 
bool isShortKernel () const noexcept
 
void setHold (DetailHold hold) noexcept
 By the frame, how each point holds its moves before the kernels are designed (DetailHold::Largest by default). By the block there is no hold.
 
DetailHold getHold () const noexcept
 
void setRemovalListen (bool on) noexcept
 Outputs what is taken out: the programme, delayed, less the filtered one.
 
bool isRemovalListen () const noexcept
 
int getLatency () const noexcept
 
int getHopSize () const noexcept
 
int getCurveCount () const noexcept
 
bool isDisplayDue (int shownAt) const noexcept
 
void publishPlayed (int channels=2) noexcept
 Hands the last kernels of both parts to a display (audio thread): a copy of them, for playedValue() and playedExtreme().
 
T playedValue (int channel, int point) const noexcept
 
T playedExtreme () const noexcept
 
void getPlayedCurve (int channel, T *played) noexcept
 The response being applied now: publishPlayed() and the points of a channel (for the owner's thread, not while a display reads).
 
template<typename Design >
void processBlock (AudioBufferView< T > buffer, Design &&design) noexcept
 Filters a block in place by curves that do not read the signal.
 
template<typename Feed , typename Design >
void processBlock (AudioBufferView< T > buffer, Feed &&feed, Design &&design) noexcept
 Filters a block in place.
 

Static Public Member Functions

static double frequency (int point) noexcept
 

Static Public Attributes

static constexpr int kPoints = SpectralReadout<T>::kPoints
 Points of a curve.
 
static constexpr int kMaxChannels = 16
 Channels filtered at most.
 

Detailed Description

template<FloatType T, DetailLatency L = DetailLatency::Frame>
class dspark::DetailFilter< T, L >

Minimum-phase filtering by a curve on a log-frequency grid, fine in the low end.

Template Parameters
TSample type (float or double).
LWhen it hands the samples back (DetailLatency; Frame unless given).

Definition at line 510 of file DetailFilter.h.

Member Function Documentation

◆ frequency()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
static double dspark::DetailFilter< T, L >::frequency ( int  point)
inlinestaticnoexcept
Returns
The frequency of a point of the curve, in hertz.

Definition at line 520 of file DetailFilter.h.

◆ getCurveCount()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
int dspark::DetailFilter< T, L >::getCurveCount ( ) const
inlinenoexcept
Returns
Curves designed since reset(), modulo 2^30: a display follows this.

Definition at line 679 of file DetailFilter.h.

◆ getHold()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
DetailHold dspark::DetailFilter< T, L >::getHold ( ) const
inlinenoexcept
Returns
How the points hold their moves.

Definition at line 666 of file DetailFilter.h.

◆ getHopSize()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
int dspark::DetailFilter< T, L >::getHopSize ( ) const
inlinenoexcept
Returns
Samples from one curve to the next.

Definition at line 676 of file DetailFilter.h.

◆ getLatency()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
int dspark::DetailFilter< T, L >::getLatency ( ) const
inlinenoexcept
Returns
The latency in samples.

Definition at line 674 of file DetailFilter.h.

◆ getPlayedCurve()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
void dspark::DetailFilter< T, L >::getPlayedCurve ( int  channel,
T *  played 
)
inlinenoexcept

The response being applied now: publishPlayed() and the points of a channel (for the owner's thread, not while a display reads).

Parameters
channel0 or 1 (0 when linked); others give zeros.
playedkPoints values, in decibels.

Definition at line 730 of file DetailFilter.h.

◆ isDisplayDue()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
bool dspark::DetailFilter< T, L >::isDisplayDue ( int  shownAt) const
inlinenoexcept
Parameters
shownAtThe curve count a display was last drawn at.
Returns
Whether the next drawing is due: 21 ms later (four curves by the block, two by the frame), some 47 a second, as often as a screen shows it, whatever the blocks.

Definition at line 686 of file DetailFilter.h.

◆ isLinked()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
bool dspark::DetailFilter< T, L >::isLinked ( ) const
inlinenoexcept
Returns
Whether one curve serves every channel.

Definition at line 641 of file DetailFilter.h.

◆ isRemovalListen()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
bool dspark::DetailFilter< T, L >::isRemovalListen ( ) const
inlinenoexcept
Returns
Whether the output is what is taken out.

Definition at line 671 of file DetailFilter.h.

◆ isShortKernel()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
bool dspark::DetailFilter< T, L >::isShortKernel ( ) const
inlinenoexcept
Returns
Whether the kernels are short.

Definition at line 657 of file DetailFilter.h.

◆ playedExtreme()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
T dspark::DetailFilter< T, L >::playedExtreme ( ) const
inlinenoexcept
Returns
The value of the largest magnitude of that response, over both channels (any thread).

Definition at line 718 of file DetailFilter.h.

◆ playedValue()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
T dspark::DetailFilter< T, L >::playedValue ( int  channel,
int  point 
) const
inlinenoexcept
Returns
A point of the response of the kernels last handed over, in decibels (any thread; made by the first read after they change). Channel 0 or 1 (the same when linked); others read 0.

Definition at line 711 of file DetailFilter.h.

◆ prepare()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
void dspark::DetailFilter< T, L >::prepare ( const AudioSpec &  spec)
inline

Allocates for a layout (an invalid spec is ignored; channels over kMaxChannels pass through).

Parameters
specRate and channels.

Definition at line 527 of file DetailFilter.h.

◆ processBlock() [1/2]

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

Filters a block in place by curves that do not read the signal.

Template Parameters
Designvoid(int channel, T* curveDb), as below.
Parameters
bufferThe audio.
designThe callback, run once a hop.

Definition at line 746 of file DetailFilter.h.

◆ processBlock() [2/2]

template<FloatType T, DetailLatency L = DetailLatency::Frame>
template<typename Feed , typename Design >
void dspark::DetailFilter< T, L >::processBlock ( AudioBufferView< T >  buffer,
Feed &&  feed,
Design &&  design 
)
inlinenoexcept

Filters a block in place.

Template Parameters
Feedvoid(int offset, int count): the samples [offset, offset + count) of the block, still untouched, are about to be taken; all of a hop's have been given when its curve is asked for. Must not throw.
Designvoid(int channel, T* curveDb): writes the kPoints gains wanted now, in decibels (held from one hop to the next). The channel is 0 when linked. Must not throw.
Parameters
bufferThe audio.
feedThe callback that reads the block (or a key beside it).
designThe callback, run once at the end of each hop.

Definition at line 766 of file DetailFilter.h.

◆ publishPlayed()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
void dspark::DetailFilter< T, L >::publishPlayed ( int  channels = 2)
inlinenoexcept

Hands the last kernels of both parts to a display (audio thread): a copy of them, for playedValue() and playedExtreme().

Parameters
channelsThe channels processed (one shows on both).

Definition at line 693 of file DetailFilter.h.

◆ reset()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
void dspark::DetailFilter< T, L >::reset ( )
inlinenoexcept

Clears the signal and the curves.

Definition at line 606 of file DetailFilter.h.

◆ setHold()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
void dspark::DetailFilter< T, L >::setHold ( DetailHold  hold)
inlinenoexcept

By the frame, how each point holds its moves before the kernels are designed (DetailHold::Largest by default). By the block there is no hold.

Definition at line 664 of file DetailFilter.h.

◆ setLinked()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
void dspark::DetailFilter< T, L >::setLinked ( bool  on)
inlinenoexcept

One curve and one filter for every channel.

Definition at line 634 of file DetailFilter.h.

◆ setRemovalListen()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
void dspark::DetailFilter< T, L >::setRemovalListen ( bool  on)
inlinenoexcept

Outputs what is taken out: the programme, delayed, less the filtered one.

Definition at line 669 of file DetailFilter.h.

◆ setShortKernel()

template<FloatType T, DetailLatency L = DetailLatency::Frame>
void dspark::DetailFilter< T, L >::setShortKernel ( bool  on)
inlinenoexcept

Cuts the kernels of the high part (all but the fine detail of the low end) to its window and tapers them over their whole length, from the next one designed (off by default: a kernel keeps the room the padding leaves, with only its tail tapered). A cut there then rings for a shorter time after the event, at the same depth; the fine detail of the low end keeps the length it takes.

Definition at line 651 of file DetailFilter.h.

Member Data Documentation

◆ kMaxChannels

template<FloatType T, DetailLatency L = DetailLatency::Frame>
constexpr int dspark::DetailFilter< T, L >::kMaxChannels = 16
staticconstexpr

Channels filtered at most.

Definition at line 517 of file DetailFilter.h.

◆ kPoints

template<FloatType T, DetailLatency L = DetailLatency::Frame>
constexpr int dspark::DetailFilter< T, L >::kPoints = SpectralReadout<T>::kPoints
staticconstexpr

Points of a curve.

Definition at line 516 of file DetailFilter.h.


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