Sound Byte Libs 0.5.1-121-g3358a44
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
sbl::dsp::analysis Namespace Reference

Host-only measurement. More...

Detailed Description

Host-only measurement.

Classes

struct  Decay
 
struct  Measure
 
struct  Period
 
struct  Profile
 
struct  Reflectance
 

Enumerations

enum class  Window { Rectangular , Hann }
 

Functions

template<typename T >
double projection_power (const T *x, int n, double hz, double fs, Window window)
 
template<typename T >
double bin_energy (const T *x, int n, double hz, double fs)
 
template<typename T >
double bin_power (const T *x, int n, double hz, double fs)
 
template<typename T >
double mean_power (const T *x, int n)
 
template<typename T >
Period autocorr_period (const T *x, int n, double expected, double tolerance)
 
template<typename T >
Profile harmonic_profile (const T *x, int n, double f0, double fs, int harmonics)
 
template<typename T >
Measure measure_window (T *x, int n, double nominal_period, double fs, int stick, int slips, int harmonics)
 
bool helmholtz (const Measure &m, double min_slips=0.9, double max_slips=1.1)
 One release per period, give or take a window edge.
 
template<typename F >
double magnitude_at (double hz, double fs, F &&process, int settle=4000, int n=20000)
 
template<typename F >
Reflectance reflectance (double hz, double fs, F &&reflect, int settle=-1, int n=-1)
 A termination's reflection for a unit sine arriving at hz.
 
template<typename T >
Decay decay_fit (const T *x, int n, double hz, int window, double fs, double floor=1e-12)
 

Variables

constexpr double PI = 3.14159265358979323846
 
constexpr int MAX_HARMONICS = 16
 

Enumeration Type Documentation

◆ Window

enum class sbl::dsp::analysis::Window
strong
Enumerator
Rectangular 
Hann 

Definition at line 33 of file measure.hpp.

Function Documentation

◆ projection_power()

template<typename T >
double sbl::dsp::analysis::projection_power ( const T *  x,
int  n,
double  hz,
double  fs,
Window  window 
)
inline

|Σ w[i] x[i] e^(−jωi)|² by Goertzel's recursion, w the window. The one projection both energy measures are built on.

Definition at line 38 of file measure.hpp.

References Hann, and PI.

Referenced by bin_energy(), and bin_power().

◆ bin_energy()

template<typename T >
double sbl::dsp::analysis::bin_energy ( const T *  x,
int  n,
double  hz,
double  fs 
)
inline

Hann-weighted energy at hz, normalised by n². The window keeps harmonics apart when bins sit on a measured, not nominal, pitch.

Definition at line 54 of file measure.hpp.

References Hann, and projection_power().

Referenced by decay_fit(), harmonic_profile(), and measure_window().

◆ bin_power()

template<typename T >
double sbl::dsp::analysis::bin_power ( const T *  x,
int  n,
double  hz,
double  fs 
)
inline

Rectangular power at hz as mean power: a unit-amplitude sine at hz reads 0.5, and the bins of a spectrum sum to mean_power(). The DSP suite's measure.

Definition at line 61 of file measure.hpp.

References projection_power(), and Rectangular.

◆ mean_power()

template<typename T >
double sbl::dsp::analysis::mean_power ( const T *  x,
int  n 
)
inline

Definition at line 66 of file measure.hpp.

Referenced by harmonic_profile(), and measure_window().

◆ autocorr_period()

template<typename T >
Period sbl::dsp::analysis::autocorr_period ( const T *  x,
int  n,
double  expected,
double  tolerance 
)
inline

Autocorrelation near an expected lag: the best integer lag within ±tolerance of it, refined by a parabola through its neighbours. The mean is removed on a copy; every lag is summed over the same span so the peak is not biased toward short lags.

Definition at line 85 of file measure.hpp.

Referenced by measure_window().

◆ harmonic_profile()

template<typename T >
Profile sbl::dsp::analysis::harmonic_profile ( const T *  x,
int  n,
double  f0,
double  fs,
int  harmonics 
)
inline

Level, spectral centroid over the harmonics, and each harmonic's level relative to the strongest, on bins at multiples of f0 (Hann-weighted).

Definition at line 130 of file measure.hpp.

References bin_energy(), sbl::dsp::analysis::Profile::harmonics, MAX_HARMONICS, and mean_power().

◆ measure_window()

template<typename T >
Measure sbl::dsp::analysis::measure_window ( T *  x,
int  n,
double  nominal_period,
double  fs,
int  stick,
int  slips,
int  harmonics 
)
inline

Judge a window of a bowed model's output. The mean is removed from x in place, so a profile taken afterwards sees the same signal. Stick and slip counts come from the caller, who watched the exciter while it played.

Definition at line 169 of file measure.hpp.

References autocorr_period(), bin_energy(), mean_power(), sbl::dsp::analysis::Period::periodicity, and sbl::dsp::analysis::Period::samples.

◆ helmholtz()

bool sbl::dsp::analysis::helmholtz ( const Measure &  m,
double  min_slips = 0.9,
double  max_slips = 1.1 
)
inline

One release per period, give or take a window edge.

Definition at line 208 of file measure.hpp.

References sbl::dsp::analysis::Measure::slips_per_period.

◆ magnitude_at()

template<typename F >
double sbl::dsp::analysis::magnitude_at ( double  hz,
double  fs,
F &&  process,
int  settle = 4000,
int  n = 20000 
)
inline

A processor's magnitude at hz: drive it with a unit sine for settle samples, then project its output on the drive over n.

Definition at line 217 of file measure.hpp.

References PI.

◆ reflectance()

template<typename F >
Reflectance sbl::dsp::analysis::reflectance ( double  hz,
double  fs,
F &&  reflect,
int  settle = -1,
int  n = -1 
)
inline

A termination's reflection for a unit sine arriving at hz.

Definition at line 236 of file measure.hpp.

References sbl::dsp::analysis::Reflectance::phase_delay_samples, and PI.

◆ decay_fit()

template<typename T >
Decay sbl::dsp::analysis::decay_fit ( const T *  x,
int  n,
double  hz,
int  window,
double  fs,
double  floor = 1e-12 
)
inline

One partial's decay: energy at hz in consecutive windows, a straight line through dB against time until 60 dB down or the floor.

Definition at line 264 of file measure.hpp.

References bin_energy().

Variable Documentation

◆ PI

constexpr double sbl::dsp::analysis::PI = 3.14159265358979323846
inlineconstexpr

Definition at line 28 of file measure.hpp.

Referenced by magnitude_at(), projection_power(), and reflectance().

◆ MAX_HARMONICS

constexpr int sbl::dsp::analysis::MAX_HARMONICS = 16
inlineconstexpr

Definition at line 29 of file measure.hpp.

Referenced by harmonic_profile().