eDSP  0.0.1
A cross-platform DSP library written in C++.
Functions
edsp::feature::spectral Namespace Reference

Functions

template<typename ForwardIt >
constexpr auto spectral_crest (ForwardIt first, ForwardIt last)
 Computes the spectral crest of the of the magnitude spectrum represented by the elements in the range [first, last) More...
 
template<typename ForwardIt >
constexpr auto spectral_decrease (ForwardIt first, ForwardIt last)
 Computes the spectral decrease of the of the magnitude spectrum represented by the elements in the range [first, last) More...
 
template<typename ForwardIt >
constexpr auto spectral_entropy (ForwardIt first, ForwardIt last)
 Computes the spectral entropy of the of the power spectral density represented by the elements in the range [first, last) More...
 
template<typename ForwardIt >
constexpr auto spectral_flatness (ForwardIt first, ForwardIt last)
 Computes the spectral flatness of the of the magnitude spectrum represented by the elements in the range [first, last) More...
 
template<typename ForwardIt >
constexpr auto spectral_flux (ForwardIt first1, ForwardIt last1, ForwardIt first2)
 Computes the spectral flux of the of the magnitude spectrum represented by the elements in the range [first, last) More...
 
template<typename ForwardIt >
constexpr auto spectral_irregularity (ForwardIt first, ForwardIt last)
 Computes the spectral irregularity of the of the magnitude spectrum represented by the elements in the range [first, last) More...
 
template<typename ForwardIt >
constexpr auto spectral_kurtosis (ForwardIt first, ForwardIt last)
 Computes the spectral kurtosis of the of the magnitude spectrum represented by the elements in the range [first, last) More...
 
template<typename ForwardIt , typename Numeric >
constexpr auto spectral_rolloff (ForwardIt first, ForwardIt last, Numeric percentage=0.95)
 Computes the spectral roll-off of the of the magnitude spectrum represented by the elements in the range [first, last) More...
 
template<typename ForwardIt >
constexpr auto spectral_skewness (ForwardIt first, ForwardIt last)
 Computes the spectral skewness of the of the magnitude spectrum represented by the elements in the range [first, last) More...
 
template<typename ForwardIt >
constexpr auto spectral_slope (ForwardIt first1, ForwardIt last1, ForwardIt first2)
 Computes the spectral slope of the of the magnitude spectrum represented by the elements in the range [first, last) More...
 
template<typename ForwardIt >
constexpr auto spectral_spread (ForwardIt first1, ForwardIt last1, ForwardIt first2)
 Computes the spectral spread of the of the magnitude spectrum represented by the elements in the range [first, last) More...
 
template<typename ForwardIt >
constexpr auto spectral_variation (ForwardIt first1, ForwardIt last1, ForwardIt first2)
 Computes the spectral variation of the of the magnitude spectrum represented by the elements in the range [first, last) More...
 

Function Documentation

◆ spectral_crest()

template<typename ForwardIt >
constexpr auto edsp::feature::spectral::spectral_crest ( ForwardIt  first,
ForwardIt  last 
)

Computes the spectral crest of the of the magnitude spectrum represented by the elements in the range [first, last)

The spectral crest is a measure of the noisiness of the spectrum.

Parameters
firstForward iterator defining the begin of the magnitude spectrum.
lastForward iterator defining the end of the magnitude spectrum.
Returns
Estimated spectral crest.
See also
spectral_flatness, crest

◆ spectral_decrease()

template<typename ForwardIt >
constexpr auto edsp::feature::spectral::spectral_decrease ( ForwardIt  first,
ForwardIt  last 
)

Computes the spectral decrease of the of the magnitude spectrum represented by the elements in the range [first, last)

The spectral decrease represents the amount of decreasing of the spectral amplitude. It is defined as:

\[ d = \frac{1}{ \sum_{n=2}^{N-1} x(n)} \sum_{n=2}^{N-1} \frac{x(n) - x(n-1)}{n - 1} \]

Parameters
firstForward iterator defining the begin of the magnitude spectrum.
lastForward iterator defining the end of the magnitude spectrum.
Returns
Estimated spectral decrease.

◆ spectral_entropy()

template<typename ForwardIt >
constexpr auto edsp::feature::spectral::spectral_entropy ( ForwardIt  first,
ForwardIt  last 
)

Computes the spectral entropy of the of the power spectral density represented by the elements in the range [first, last)

Spectral Entropy describes the complexity of a system. The PSD of a audio signal can be computed as the normalized version of the Power Spectral Density:

\[ p_i=\frac{P(\omega_i)}{\sum_iP(\omega_i)} \]

The Power Spectral entropy can be now calculated using a standard formula for an entropy calculation.

Warning
This function normalize/modifies the input range.
Parameters
firstForward iterator defining the begin of the magnitude spectrum.
lastForward iterator defining the end of the magnitude spectrum.
first2Forward iterator defining the begin of the center frequencies range.
Returns
Estimated spectral entropy.
See also
entropy

◆ spectral_flatness()

template<typename ForwardIt >
constexpr auto edsp::feature::spectral::spectral_flatness ( ForwardIt  first,
ForwardIt  last 
)

Computes the spectral flatness of the of the magnitude spectrum represented by the elements in the range [first, last)

The spectral flatness is a measure of the noisiness of the spectrum.

Parameters
firstForward iterator defining the begin of the magnitude spectrum.
lastForward iterator defining the end of the magnitude spectrum.
Returns
Estimated spectral flatness.
See also
spectral_crest, flatness

◆ spectral_flux()

template<typename ForwardIt >
constexpr auto edsp::feature::spectral::spectral_flux ( ForwardIt  first1,
ForwardIt  last1,
ForwardIt  first2 
)

Computes the spectral flux of the of the magnitude spectrum represented by the elements in the range [first, last)

Parameters
first1Forward iterator defining the begin of the first magnitude spectrum.
last1Forward iterator defining the end of the first magnitude spectrum.
first2Input iterator defining the beginning of the second magnitude spectrum.
Returns
The estimated flux.
See also
flux

◆ spectral_irregularity()

template<typename ForwardIt >
constexpr auto edsp::feature::spectral::spectral_irregularity ( ForwardIt  first,
ForwardIt  last 
)

Computes the spectral irregularity of the of the magnitude spectrum represented by the elements in the range [first, last)

The spectral irregularity quantifies the variations of the logarithmically-scaled rate-map across frequencies. This implementation is based on [Jensen 1999] where the spectral irregularity is estimated as the sum of the square of the difference in amplitude between adjoining partials.

See also
[Jensen, 1999] K. Jensen, Timbre Models of Musical Sounds, Ph.D. dissertation, University of Copenhagen, Rapport Nr. 99/7.
Parameters
firstForward iterator defining the begin of the magnitude spectrum.
lastForward iterator defining the end of the magnitude spectrum.
Returns
Estimated spectral irregularity.
See also
irregularity

◆ spectral_kurtosis()

template<typename ForwardIt >
constexpr auto edsp::feature::spectral::spectral_kurtosis ( ForwardIt  first,
ForwardIt  last 
)

Computes the spectral kurtosis of the of the magnitude spectrum represented by the elements in the range [first, last)

Parameters
firstForward iterator defining the begin of the magnitude spectrum.
lastForward iterator defining the end of the magnitude spectrum.
Returns
Estimated spectral kurtosis.
See also
kurtosis

◆ spectral_rolloff()

template<typename ForwardIt , typename Numeric >
constexpr auto edsp::feature::spectral::spectral_rolloff ( ForwardIt  first,
ForwardIt  last,
Numeric  percentage = 0.95 
)

Computes the spectral roll-off of the of the magnitude spectrum represented by the elements in the range [first, last)

The spectral roll-off point is the frequency so that \( \alpha \) of the signal energy is contained below this frequency.

Parameters
firstForward iterator defining the begin of the magnitude spectrum.
lastForward iterator defining the end of the magnitude spectrum.
percentageNumber between [0, 1] representing the percentage of the total energy of the roll-off frequency.
Returns
Estimated roll-off index.
See also
rolloff

◆ spectral_skewness()

template<typename ForwardIt >
constexpr auto edsp::feature::spectral::spectral_skewness ( ForwardIt  first,
ForwardIt  last 
)

Computes the spectral skewness of the of the magnitude spectrum represented by the elements in the range [first, last)

Parameters
firstForward iterator defining the begin of the magnitude spectrum.
lastForward iterator defining the end of the magnitude spectrum.
Returns
Estimated spectral skewness.
See also
skewness

◆ spectral_slope()

template<typename ForwardIt >
constexpr auto edsp::feature::spectral::spectral_slope ( ForwardIt  first1,
ForwardIt  last1,
ForwardIt  first2 
)

Computes the spectral slope of the of the magnitude spectrum represented by the elements in the range [first, last)

The spectral slope represents the amount of decreasing of the spectral amplitude. It is computed by linear regression of the spectral amplitude:

\[ G = a f + b \]

where a is the parameter of interest. In this case is computed as follows:

\[ a = \frac{1}{\sum_k a(k)} \frac{N \sum_k a(k) f(k) - \sum_k a(k) * \sum_k f(k)} {N \sum_k f^2(k) - \left( \sum_k f(k) \right)^2} \]

where f is a vector representing the different frequency bins.

Parameters
first1Forward iterator defining the begin of the magnitude spectrum.
last1Forward iterator defining the end of the magnitude spectrum.
first2Forward iterator defining the begin of the center frequencies range.
Returns
Estimated spectral slope.

◆ spectral_spread()

template<typename ForwardIt >
constexpr auto edsp::feature::spectral::spectral_spread ( ForwardIt  first1,
ForwardIt  last1,
ForwardIt  first2 
)

Computes the spectral spread of the of the magnitude spectrum represented by the elements in the range [first, last)

The spectral spread describes the average deviation of the rate-map around its centroid, which is commonly associated with the bandwidth of the signal

\[ ss = \frac{\sum_{n = 0}^{N-1}((f(n) - sc)^2 X(n)}{\sum_{n = 0}^{N-1}X(n)} \]

where sc is the spectral centroid.

Parameters
first1Forward iterator defining the begin of the magnitude spectrum.
last2Forward iterator defining the end of the magnitude spectrum.
first2Forward iterator defining the begin of the center frequencies range. The estimated spectral spread
See also
http://www.nyu.edu/classes/bello/MIR_files/timbre.pdf

◆ spectral_variation()

template<typename ForwardIt >
constexpr auto edsp::feature::spectral::spectral_variation ( ForwardIt  first1,
ForwardIt  last1,
ForwardIt  first2 
)

Computes the spectral variation of the of the magnitude spectrum represented by the elements in the range [first, last)

The spectral variation is a representation of the similarity between two magnitude spectrums. It is a parameter similar to the spectral flux.

\[ v = 1 - \frac{\sum_k X_1(k) X_2(K) }{ \sqrt{ \sum_k X_1(k)} \sqrt{\sum_k X_2(k)}} \]

If the variation is close to 0, the spectrum are really similar. Otherwise, if it is close to 1, the are highly dissimilar.

Parameters
first1Forward iterator defining the begin of the first magnitude spectrum.
last1Forward iterator defining the end of the first magnitude spectrum.
first2Input iterator defining the beginning of the second magnitude spectrum.
Returns
The estimated spectral variation.
See also
flux