Bands uniform in Bark over a power spectrum, with the loudness law.
More...
#include <AuditoryBands.h>
|
| void | prepare (double sampleRate, int fftSize, int numBands=72, double loHz=20.0, double hiHz=20000.0) |
| | Lays the bands out.
|
| |
| void | prepareDetailed (double sampleRate, int fftSize, int barkBands, double loHz, double hiHz, double bandsPerOctave) |
| | Lays the bands out with more of them in the low end.
|
| |
| void | prepareLike (const AuditoryBands &other, double sampleRate, int fftSize) |
| | Takes the bands of another instance over a spectrum of its own.
|
| |
| void | setReferenceSpl (double dbSpl) noexcept |
| | The SPL of a full-scale sine for the loudness law (60 to 130 dB).
|
| |
| int | getNumBands () const noexcept |
| |
| int | getNumBins () const noexcept |
| |
| double | getCentre (int band) const noexcept |
| |
| double | getBark (int band) const noexcept |
| |
| double | getSpacing () const noexcept |
| |
| double | getWidthBark (int band) const noexcept |
| |
| bool | isUniform () const noexcept |
| |
| double | getExponent (int band) const noexcept |
| |
| double | getThreshold (int band) const noexcept |
| |
| double | getThresholdLoudness (int band) const noexcept |
| |
| void | bandPowers (const T *binPower, T *out) const noexcept |
| | Band powers from a power spectrum.
|
| |
| template<int Lanes> |
| void | bandPowersInterleaved (const T *binPower, T *out) const noexcept |
| | The band powers of several spectra at once: each what bandPowers() gives for its own.
|
| |
| void | specificLoudness (const T *bandPower, T *out) const noexcept |
| | Specific loudness of band powers: (P + P_th)^a - P_th^a, with the band's exponent and threshold.
|
| |
| T | totalLoudness (const T *specific) const noexcept |
| |
|
| static void | smoothAcross (T *v, int n, T coeff) noexcept |
| | Smooths values across bands in both directions with a one-pole (forward, then backward): a spread like the ear's masking.
|
| |
template<FloatType T>
class dspark::AuditoryBands< T >
Bands uniform in Bark over a power spectrum, with the loudness law.
- Template Parameters
-
| T | Sample type of the spectra (float or double). |
Definition at line 143 of file AuditoryBands.h.
◆ bandPowers()
Band powers from a power spectrum.
- Parameters
-
| binPower | numBins powers (|X[k]|^2 scaled so a full-scale sine reads 1 in its bin, or any consistent scale). |
| out | getNumBands() powers. |
Definition at line 338 of file AuditoryBands.h.
◆ bandPowersInterleaved()
template<FloatType T>
template<int Lanes>
The band powers of several spectra at once: each what bandPowers() gives for its own.
- Template Parameters
-
| Lanes | How many spectra (1 to 8). |
- Parameters
-
| binPower | numBins groups of Lanes powers, one of each spectrum. |
| out | getNumBands() groups of Lanes powers, the same way. |
Definition at line 351 of file AuditoryBands.h.
◆ getBark()
◆ getCentre()
◆ getExponent()
◆ getNumBands()
◆ getNumBins()
◆ getSpacing()
- Returns
- The spacing of the bands in Bark (of the Bark layout: the widest a band is).
Definition at line 314 of file AuditoryBands.h.
◆ getThreshold()
- Returns
- The threshold in quiet of a band, as a power relative to a full-scale sine.
Definition at line 328 of file AuditoryBands.h.
◆ getThresholdLoudness()
◆ getWidthBark()
- Returns
- The stretch of the Bark axis a band stands for: from half way to the band below to half way to the band above (the first and the last take the half toward their only neighbour), which is its weight in a sum over the bands that stands for an integral over Bark.
Definition at line 322 of file AuditoryBands.h.
◆ isUniform()
◆ prepare()
template<FloatType T>
| void dspark::AuditoryBands< T >::prepare |
( |
double |
sampleRate, |
|
|
int |
fftSize, |
|
|
int |
numBands = 72, |
|
|
double |
loHz = 20.0, |
|
|
double |
hiHz = 20000.0 |
|
) |
| |
|
inline |
Lays the bands out.
- Parameters
-
| sampleRate | Rate of the spectrum (invalid values are ignored). |
| fftSize | Size of the transform (the spectrum has fftSize / 2 + 1 bins). |
| numBands | Number of bands, 2 to 512. |
| loHz | Centre of the lowest band. |
| hiHz | Centre of the highest band (at most 0.49 of the rate). |
Definition at line 154 of file AuditoryBands.h.
◆ prepareDetailed()
template<FloatType T>
| void dspark::AuditoryBands< T >::prepareDetailed |
( |
double |
sampleRate, |
|
|
int |
fftSize, |
|
|
int |
barkBands, |
|
|
double |
loHz, |
|
|
double |
hiHz, |
|
|
double |
bandsPerOctave |
|
) |
| |
|
inline |
Lays the bands out with more of them in the low end.
Starts from the layout of prepare() (barkBands bands uniform in Bark from loHz to hiHz) and lets no band be wider than 1 / bandsPerOctave of an octave: the density of bands along frequency is the larger of the two, so the bands follow the octave in the low end and the Bark scale from where a band of that scale is the narrower one. The number of bands follows from it (getNumBands()).
- Parameters
-
| sampleRate | Rate of the spectrum (invalid values are ignored). |
| fftSize | Size of the transform. |
| barkBands | Bands of the Bark layout it starts from, 2 to 512. |
| loHz | Centre of the lowest band. |
| hiHz | Centre of the highest band (at most 0.49 of the rate). |
| bandsPerOctave | Bands per octave at least; 0 or less is prepare(). |
Definition at line 216 of file AuditoryBands.h.
◆ prepareLike()
Takes the bands of another instance over a spectrum of its own.
The centres, the thresholds and the exponents are those of the other instance; the bins are those of this rate and this transform. A band over half this rate reads nothing that means anything.
- Parameters
-
| other | The instance whose bands are taken (already prepared). |
| sampleRate | Rate of this spectrum (invalid values are ignored). |
| fftSize | Size of this transform. |
Definition at line 278 of file AuditoryBands.h.
◆ setReferenceSpl()
The SPL of a full-scale sine for the loudness law (60 to 130 dB).
Definition at line 295 of file AuditoryBands.h.
◆ smoothAcross()
Smooths values across bands in both directions with a one-pole (forward, then backward): a spread like the ear's masking.
- Parameters
-
| v | The values, in place. |
| n | How many. |
| coeff | Pole, 0 (none) to just under 1. |
Definition at line 405 of file AuditoryBands.h.
◆ specificLoudness()
Specific loudness of band powers: (P + P_th)^a - P_th^a, with the band's exponent and threshold.
Definition at line 417 of file AuditoryBands.h.
◆ totalLoudness()
- Returns
- The total loudness: the specific loudness integrated over Bark (trapezoids).
Definition at line 428 of file AuditoryBands.h.
The documentation for this class was generated from the following file: