nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
shape_descriptors.hpp File Reference

Spectral-shape descriptors. More...

#include <memory_resource>
#include <nk/value/value.hpp>

Go to the source code of this file.

Functions

Value nk::audio::spectralCentroid (const Value &x, const Value &f, std::pmr::memory_resource *mr=nullptr)
 Spectral centroid — power-weighted mean frequency.
Value nk::audio::spectralSpread (const Value &x, const Value &f, std::pmr::memory_resource *mr=nullptr)
 Spectral spread — power-weighted std around the centroid.
Value nk::audio::spectralRolloffPoint (const Value &x, const Value &f, double percentile=0.95, std::pmr::memory_resource *mr=nullptr)
 Spectral rolloff frequency.
Value nk::audio::spectralDecrease (const Value &x, const Value &f, std::pmr::memory_resource *mr=nullptr)
 Spectral decrease — slope-like measure relative to first bin.
Value nk::audio::spectralSlope (const Value &x, const Value &f, std::pmr::memory_resource *mr=nullptr)
 Spectral slope — least-squares slope of (f, X).
Value nk::audio::spectralFlux (const Value &x, const Value &f, double p=2.0, std::pmr::memory_resource *mr=nullptr)
 Spectral flux — p-norm of frame-to-frame spectrum differences.
Value nk::audio::spectralCrest (const Value &x, const Value &f, std::pmr::memory_resource *mr=nullptr)
 Spectral crest — max(X) / mean(X) per frame.
Value nk::audio::spectralEntropy (const Value &x, const Value &f, std::pmr::memory_resource *mr=nullptr)
 Spectral entropy — Shannon entropy of normalised spectrum.
Value nk::audio::spectralFlatness (const Value &x, const Value &f, std::pmr::memory_resource *mr=nullptr)
 Spectral flatness — geomean(X) / mean(X).
Value nk::audio::spectralKurtosis (const Value &x, const Value &f, std::pmr::memory_resource *mr=nullptr)
 Spectral kurtosis — X-weighted 4th central moment.
Value nk::audio::spectralSkewness (const Value &x, const Value &f, std::pmr::memory_resource *mr=nullptr)
 Spectral skewness — X-weighted 3rd central moment.

Detailed Description

Spectral-shape descriptors.

Two input forms (shared by every function in this header):

  1. (x, fs) — x is a column-vector time-domain signal, fs is the sample rate. Internally computes STFT with rectwin(round(fs · 0.03)), overlap round(fs · 0.02), FFTLength = winLen. Returns a per-frame column vector.
  2. (X, F) — X is a power (or magnitude) spectrum, F is the frequency vector. X may be M × N (one spectrum per column). Returns a per-column metric as a row vector.

Throughout this header x / f follow that convention; only descriptor-specific extra arguments (percentile, p) are called out separately.

Definition in file shape_descriptors.hpp.