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

Classes

class  leq
 This class estimates the Equivalent Continuous Sound Level over consecutive frames. More...
 

Functions

template<typename InputIt , typename OutputIt >
constexpr void amdf (InputIt first, InputIt last, OutputIt d_first)
 Computes the AMDF (Average Magnitude Difference Function) of the contiguous elements in the range [first, last) and stores the result in another range, beginning at d_first. More...
 
template<typename ForwardIt , typename Numeric >
constexpr auto duration (ForwardIt first, ForwardIt last, Numeric samplerate)
 Computes the duration of the elements in the range [first, last) More...
 
template<typename ForwardIt , typename Numeric >
constexpr auto effective_duration (ForwardIt first, ForwardIt last, Numeric samplerate, Numeric threshold)
 Computes the effective duration of the elements in the range [first, last) More...
 
template<typename ForwardIt >
constexpr auto energy (ForwardIt first, ForwardIt last)
 Computes the energy of the elements in the range [first, last) More...
 
template<typename ForwardIt , typename Numeric >
constexpr auto lat (ForwardIt first, ForwardIt last, Numeric samplerate, Numeric start_threshold, Numeric stop_threshold)
 The laq class estimates the logarithmic attack time of an envelope signal. More...
 
template<typename ForwardIt >
constexpr auto power (ForwardIt first, ForwardIt last)
 Computes the instant power of the elements in the range [first, last) More...
 

Function Documentation

◆ amdf()

template<typename InputIt , typename OutputIt >
constexpr void edsp::feature::temporal::amdf ( InputIt  first,
InputIt  last,
OutputIt  d_first 
)

Computes the AMDF (Average Magnitude Difference Function) of the contiguous elements in the range [first, last) and stores the result in another range, beginning at d_first.

Computes the AZCR (Average Zero Crossing Rate) of the contiguous elements in the range [first, last) and stores the result in another range, beginning at d_first.

Computes the ASDF (Average Square Difference Function) of the contiguous elements in the range [first, last) and stores the result in another range, beginning at d_first.

The definition of AMDF is:

\[ Q_x[k,n_0] \triangleq \frac{1}{N} \sum\limits_{n=0}^{N-1} \Big| x[n+n_0] - x[n+n_0+k] \Big| \]

Parameters
firstInput iterator defining the begin of the range to examine.
lastInput iterator defining the end of the range to examine.
d_firstOutput iterator defining the begin of the output range.

The definition of ASDF is:

\[ Q_x[k,n_0] \triangleq \frac{1}{N} \sum\limits_{n=0}^{N-1} \big( x[n+n_0] - x[n+n_0+k] \big)^2 \]

There is a relation between the ASDF function and the ACF function:

\[ \begin{align} x[k] & \triangleq \frac{1}{N} \sum x[n] x[n+k] \\ & = \overline{x^2[n]} - \tfrac{1}{2} Q_x[k] \\ & = R_x[0] - \tfrac{1}{2} Q_x[k] \\ \end{align} \]

Parameters
firstInput iterator defining the begin of the range to examine.
lastInput iterator defining the end of the range to examine.
d_firstOutput iterator defining the begin of the output range.
See also
acf, amdf

The definition of AZCR is:

\[ {\displaystyle zcr={\frac {1}{T-1}}\sum _{t=1}^{T-1}\mathbb {1} _{\mathbb {R} _{<0}}(s_{t}s_{t-1})} \]

Parameters
firstInput iterator defining the begin of the range to examine.
lastInput iterator defining the end of the range to examine.
d_firstOutput iterator defining the begin of the output range.

◆ duration()

template<typename ForwardIt , typename Numeric >
constexpr auto edsp::feature::temporal::duration ( ForwardIt  first,
ForwardIt  last,
Numeric  samplerate 
)

Computes the duration of the elements in the range [first, last)

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
samplerateSampling frequency in Hz.
Returns
The estimated duration in seconds.

◆ effective_duration()

template<typename ForwardIt , typename Numeric >
constexpr auto edsp::feature::temporal::effective_duration ( ForwardIt  first,
ForwardIt  last,
Numeric  samplerate,
Numeric  threshold 
)

Computes the effective duration of the elements in the range [first, last)

The effective duration is a measure of the time the signal is perceptually meaningful. It is approximated by the time the energy envelope is above a given threshold.

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
samplerateSampling frequency in Hz.
thresholdNumeric value in the range [0, 1] representing the active threshold.
Returns
The estimated duration in seconds.

◆ energy()

template<typename ForwardIt >
constexpr auto edsp::feature::temporal::energy ( ForwardIt  first,
ForwardIt  last 
)

Computes the energy of the elements in the range [first, last)

The energy estimates the signal power at a given time, it is estimated directly from the signal frame around a given time:

\[ e = \sum\limits_{n=0}^{N-1} x^2(n) \]

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
Returns
The energy of the elements in the range.

◆ lat()

template<typename ForwardIt , typename Numeric >
constexpr auto edsp::feature::temporal::lat ( ForwardIt  first,
ForwardIt  last,
Numeric  samplerate,
Numeric  start_threshold,
Numeric  stop_threshold 
)

The laq class estimates the logarithmic attack time of an envelope signal.

The log-attack time is the logarithmic (decimal base) of the time duration between the time the signal to the time it reaches its stable part:

\[ lat = \log10 \left( t_{stop} - t_{start} \right) \]

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
samplerateSampling frequency in Hz.
start_thresholdNumeric value between [0, 1] representing the percentage of the amplitude signal representing the start of the attack time.
stop_thresholdNumeric value between [0, 1] representing the percentage of the amplitude signal representing the limit of the attack time.
Returns
Estimated attack time in seconds.

◆ power()

template<typename ForwardIt >
constexpr auto edsp::feature::temporal::power ( ForwardIt  first,
ForwardIt  last 
)

Computes the instant power of the elements in the range [first, last)

The energy of signal can be computed as:

\[ P_x = \frac{1}{N} \sum\limits_{n=0}^{N-1} x^2(n) \]

Parameters
firstForward iterator defining the begin of the range to examine.
lastForward iterator defining the end of the range to examine.
Returns
The instant power of the elements in the range.
See also
energy