DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
dspark::SpectralDenoiser< T > Class Template Reference

Learn-a-profile spectral gate (hiss/hum/room-tone reduction). More...

#include <SpectralDenoiser.h>

Public Member Functions

void prepare (const AudioSpec &spec, int fftSize=2048)
 Prepares the STFT pipeline and the per-channel bin state.
 
void reset () noexcept
 Clears signal state and per-bin gain memories (keeps profile).
 
void clearProfile () noexcept
 Forgets the learned noise profile (stream-owner thread).
 
void setLearning (bool learning) noexcept
 While true, incoming audio trains the noise profile.
 
void setReduction (T db) noexcept
 Maximum attenuation of gated bins in dB [0, 40] (default 18). Non-finite values are ignored.
 
void setThreshold (T factor) noexcept
 Gate threshold over the learned profile [1, 8] (default 2). Non-finite values are ignored.
 
bool getLearning () const noexcept
 
getReduction () const noexcept
 
getThreshold () const noexcept
 
int getLatency () const noexcept
 Latency in samples (the STFT pipeline's).
 
std::vector< uint8_t > getState () const
 Serializes the parameter state (the learned profile is material- dependent content, not a preset, and is intentionally not included).
 
bool setState (const uint8_t *data, size_t size)
 Restores parameters from a blob (tolerant; rejects foreign ids).
 
void processBlock (AudioBufferView< T > buffer) noexcept
 Processes a block in-place. Pass-through until prepare() succeeds.
 

Detailed Description

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

Learn-a-profile spectral gate (hiss/hum/room-tone reduction).

Template Parameters
TSample type (float or double).

Definition at line 59 of file SpectralDenoiser.h.

Member Function Documentation

◆ clearProfile()

template<FloatType T>
void dspark::SpectralDenoiser< T >::clearProfile ( )
inlinenoexcept

Forgets the learned noise profile (stream-owner thread).

Definition at line 103 of file SpectralDenoiser.h.

◆ getLatency()

template<FloatType T>
int dspark::SpectralDenoiser< T >::getLatency ( ) const
inlinenoexcept

Latency in samples (the STFT pipeline's).

Definition at line 137 of file SpectralDenoiser.h.

◆ getLearning()

template<FloatType T>
bool dspark::SpectralDenoiser< T >::getLearning ( ) const
inlinenoexcept

Definition at line 132 of file SpectralDenoiser.h.

◆ getReduction()

template<FloatType T>
T dspark::SpectralDenoiser< T >::getReduction ( ) const
inlinenoexcept

Definition at line 133 of file SpectralDenoiser.h.

◆ getState()

template<FloatType T>
std::vector< uint8_t > dspark::SpectralDenoiser< T >::getState ( ) const
inline

Serializes the parameter state (the learned profile is material- dependent content, not a preset, and is intentionally not included).

Definition at line 141 of file SpectralDenoiser.h.

◆ getThreshold()

template<FloatType T>
T dspark::SpectralDenoiser< T >::getThreshold ( ) const
inlinenoexcept

Definition at line 134 of file SpectralDenoiser.h.

◆ prepare()

template<FloatType T>
void dspark::SpectralDenoiser< T >::prepare ( const AudioSpec spec,
int  fftSize = 2048 
)
inline

Prepares the STFT pipeline and the per-channel bin state.

Invalid specs (non-positive/non-finite rate, block size or channel count) are ignored: the previous state is kept and an unprepared instance stays pass-through. fftSize is sanitized by the STFT engine (power of two in [4, 1 << 20]).

Parameters
specAudio environment specification.
fftSizeSTFT size (default 2048; larger = finer hum notching).

Definition at line 75 of file SpectralDenoiser.h.

◆ processBlock()

template<FloatType T>
void dspark::SpectralDenoiser< T >::processBlock ( AudioBufferView< T >  buffer)
inlinenoexcept

Processes a block in-place. Pass-through until prepare() succeeds.

Definition at line 164 of file SpectralDenoiser.h.

◆ reset()

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

Clears signal state and per-bin gain memories (keeps profile).

Definition at line 93 of file SpectralDenoiser.h.

◆ setLearning()

template<FloatType T>
void dspark::SpectralDenoiser< T >::setLearning ( bool  learning)
inlinenoexcept

While true, incoming audio trains the noise profile.

Definition at line 111 of file SpectralDenoiser.h.

◆ setReduction()

template<FloatType T>
void dspark::SpectralDenoiser< T >::setReduction ( db)
inlinenoexcept

Maximum attenuation of gated bins in dB [0, 40] (default 18). Non-finite values are ignored.

Definition at line 118 of file SpectralDenoiser.h.

◆ setState()

template<FloatType T>
bool dspark::SpectralDenoiser< T >::setState ( const uint8_t *  data,
size_t  size 
)
inline

Restores parameters from a blob (tolerant; rejects foreign ids).

Definition at line 152 of file SpectralDenoiser.h.

◆ setThreshold()

template<FloatType T>
void dspark::SpectralDenoiser< T >::setThreshold ( factor)
inlinenoexcept

Gate threshold over the learned profile [1, 8] (default 2). Non-finite values are ignored.

Definition at line 126 of file SpectralDenoiser.h.


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