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

Envelope of a spectrum, smoothing proportional to frequency. More...

#include <SpectralEnvelope.h>

Public Member Functions

void prepare (int numBins, double widthOctaves=1.0/3.0, double minBins=1.0)
 Sets the bins and the width.
 
void setWidth (double widthOctaves) noexcept
 Width of the smoothing in octaves (0.05 to 4; non-finite values are ignored).
 
void setPasses (int passes) noexcept
 Passes of the smoothing: 1 (the default) or 2. Two passes keep the equivalent width and lose the long tails of one: the envelope follows a wide rise of the spectrum closely while a narrow line still stands over it.
 
void setTaper (double cornerBin, double exponent) noexcept
 Narrows the smoothing above a corner: its width in octaves falls as (corner / frequency) to the exponent (0, the default, keeps it constant; 1 makes it constant in hertz above the corner; at most 2). Non-finite values are ignored.
 
int getPasses () const noexcept
 
double getWidth () const noexcept
 
int getNumBins () const noexcept
 
void compute (const T *in, T *out) const noexcept
 The envelope of a spectrum.
 
template<int Lanes>
void computeInterleaved (T *values) const noexcept
 The envelopes of several spectra at once, in place: each what compute() gives for its own. The recursion waits on itself at every bin, so a few run in the time of one.
 
void resonances (const T *in, T *out) const noexcept
 The resonances, never negative: given decibels, the spectrum over its envelope in decibels (soft); given magnitudes, the excess of amplitude over it (hard).
 
void excess (const T *in, T *out) const noexcept
 The spectrum less its envelope, with its sign (what stands over the envelope is positive, what lies under it negative).
 

Detailed Description

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

Envelope of a spectrum, smoothing proportional to frequency.

Template Parameters
TSample type of the spectra (float or double).

Definition at line 45 of file SpectralEnvelope.h.

Member Function Documentation

◆ compute()

template<FloatType T>
void dspark::SpectralEnvelope< T >::compute ( const T *  in,
T *  out 
) const
inlinenoexcept

The envelope of a spectrum.

Parameters
innumBins values (magnitudes, or decibels when logDomain).
outnumBins values (may be in).

Definition at line 122 of file SpectralEnvelope.h.

◆ computeInterleaved()

template<FloatType T>
template<int Lanes>
void dspark::SpectralEnvelope< T >::computeInterleaved ( T *  values) const
inlinenoexcept

The envelopes of several spectra at once, in place: each what compute() gives for its own. The recursion waits on itself at every bin, so a few run in the time of one.

Template Parameters
LanesHow many spectra (1 to 8).
Parameters
valuesnumBins groups of Lanes values, one of each spectrum.

Definition at line 136 of file SpectralEnvelope.h.

◆ excess()

template<FloatType T>
void dspark::SpectralEnvelope< T >::excess ( const T *  in,
T *  out 
) const
inlinenoexcept

The spectrum less its envelope, with its sign (what stands over the envelope is positive, what lies under it negative).

Parameters
innumBins values.
outnumBins values (must not be in).

Definition at line 187 of file SpectralEnvelope.h.

◆ getNumBins()

template<FloatType T>
int dspark::SpectralEnvelope< T >::getNumBins ( ) const
inlinenoexcept

Definition at line 115 of file SpectralEnvelope.h.

◆ getPasses()

template<FloatType T>
int dspark::SpectralEnvelope< T >::getPasses ( ) const
inlinenoexcept

Definition at line 112 of file SpectralEnvelope.h.

◆ getWidth()

template<FloatType T>
double dspark::SpectralEnvelope< T >::getWidth ( ) const
inlinenoexcept

Definition at line 114 of file SpectralEnvelope.h.

◆ prepare()

template<FloatType T>
void dspark::SpectralEnvelope< T >::prepare ( int  numBins,
double  widthOctaves = 1.0 / 3.0,
double  minBins = 1.0 
)
inline

Sets the bins and the width.

Parameters
numBinsBins of the spectra (fftSize / 2 + 1), at least 2.
widthOctavesWidth of the smoothing, 0.05 to 4 octaves.
minBinsNarrowest smoothing, in bins (1 by default; a spectrum padded q times more keeps the same width in hertz with q).

Definition at line 56 of file SpectralEnvelope.h.

◆ resonances()

template<FloatType T>
void dspark::SpectralEnvelope< T >::resonances ( const T *  in,
T *  out 
) const
inlinenoexcept

The resonances, never negative: given decibels, the spectrum over its envelope in decibels (soft); given magnitudes, the excess of amplitude over it (hard).

Parameters
innumBins values.
outnumBins values of the excess (must not be in).

Definition at line 175 of file SpectralEnvelope.h.

◆ setPasses()

template<FloatType T>
void dspark::SpectralEnvelope< T >::setPasses ( int  passes)
inlinenoexcept

Passes of the smoothing: 1 (the default) or 2. Two passes keep the equivalent width and lose the long tails of one: the envelope follows a wide rise of the spectrum closely while a narrow line still stands over it.

Definition at line 90 of file SpectralEnvelope.h.

◆ setTaper()

template<FloatType T>
void dspark::SpectralEnvelope< T >::setTaper ( double  cornerBin,
double  exponent 
)
inlinenoexcept

Narrows the smoothing above a corner: its width in octaves falls as (corner / frequency) to the exponent (0, the default, keeps it constant; 1 makes it constant in hertz above the corner; at most 2). Non-finite values are ignored.

Parameters
cornerBinThe corner, in bins.
exponent0 to 2.

Definition at line 104 of file SpectralEnvelope.h.

◆ setWidth()

template<FloatType T>
void dspark::SpectralEnvelope< T >::setWidth ( double  widthOctaves)
inlinenoexcept

Width of the smoothing in octaves (0.05 to 4; non-finite values are ignored).

Definition at line 65 of file SpectralEnvelope.h.


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