|
DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
|
A frame's spectrum read through a window that shortens as frequency rises, from the one transform of the whole window. More...
#include <SpectralEnvelope.h>
Public Member Functions | |
| void | prepare (const double *window, int windowSize, int transform, double widthOctaves=1.0/3.0, double minBins=1.0) |
| Sets the window, the transform and the width. | |
| int | getNumBins () const noexcept |
| double | getGain (int bin) const noexcept |
| void | smooth (const double *spectrum, double *re, double *im) const noexcept |
| The smoothed complex spectrum of a frame. | |
| void | power (const double *spectrum, T *out) noexcept |
| The power of each bin through its own window, scaled to read as through the whole one. | |
A frame's spectrum read through a window that shortens as frequency rises, from the one transform of the whole window.
Smoothing a complex spectrum across frequency is the same as multiplying the frame by a weight in time: the wider the smoothing, the narrower the weight. With the time origin moved to the window's peak, a smoothing whose width grows with frequency (as SpectralEnvelope's, a one-pole run both ways) weighs the low bins by nearly the whole window and the high ones by a short stretch around its peak: the low end keeps its resolution in frequency and the top gains it in time, where the ear has it. The weight of a smoothing of coefficient c is (1 - c)^2 / (1 - 2 c cos(theta) + c^2) at the angle theta = 2 pi (t - peak) / transform.
power() gives the power of each bin scaled so that a noise, or a tone summed over its lobe, reads what it reads through the whole window (each bin by the energy of the window over the energy of its own shorter one).
Threading: prepare() on the setup thread (allocates); smooth() and power() on the owner's thread, with no allocation.
| T | Sample type of the powers (float or double). |
Definition at line 224 of file SpectralEnvelope.h.
|
inlinenoexcept |
Definition at line 304 of file SpectralEnvelope.h.
|
inlinenoexcept |
Definition at line 302 of file SpectralEnvelope.h.
|
inlinenoexcept |
The power of each bin through its own window, scaled to read as through the whole one.
| spectrum | The frame's transform, interleaved, getNumBins() pairs. |
| out | getNumBins() powers. |
Definition at line 341 of file SpectralEnvelope.h.
|
inline |
Sets the window, the transform and the width.
| window | The analysis window the frames are made with. |
| windowSize | Its length, at least 2. |
| transform | The transform's size (windowSize or more, for a zero-padded frame that starts at the window's start). |
| widthOctaves | Width of the smoothing, 0.05 to 4 octaves. |
| minBins | Narrowest smoothing, in bins (1 by default). |
Definition at line 236 of file SpectralEnvelope.h.
|
inlinenoexcept |
The smoothed complex spectrum of a frame.
| spectrum | The frame's transform, interleaved (real, imaginary), getNumBins() pairs. |
| re | getNumBins() values: the real parts. |
| im | getNumBins() values: the imaginary parts. |
Definition at line 312 of file SpectralEnvelope.h.