LibXtract 1.6.0
Delta extraction functions

Functions

int xtract_flux (const double *data, const int N, const void *argv, double *result)
 Extract flux.
int xtract_lnorm (const double *data, const int N, const void *argv, double *result)
 Extract the L-norm of a vector.
int xtract_attack_time (const double *data, const int N, const void *argv, double *result)
 Extract the attack time of an envelope: the time from the first element that reaches the start fraction of the maximum to the first element from there that reaches the stop fraction.
int xtract_decay_time (const double *data, const int N, const void *argv, double *result)
 Extract the decay time of an envelope: the time from its maximum to the first later element at or below the threshold fraction of the maximum, or to the last element when none is.
int xtract_difference_vector (const double *data, const int N, const void *argv, double *result)
 Extract the difference between two vectors.
int xtract_kullback_leibler_divergence (const double *data, const int N, const void *argv, double *result)
 Extract the Kullback-Leibler divergence of the current spectral frame from the previous one, each frame scaled to sum to 1.
int xtract_itakura_saito_divergence (const double *data, const int N, const void *argv, double *result)
 Extract the Itakura-Saito divergence of the current spectral frame from the previous one.
int xtract_modified_kullback_leibler (const double *data, const int N, const void *argv, double *result)
 Extract the modified Kullback-Leibler onset function of Hainsworth and Macleod: the sum over the frame of the logarithm of 1 plus the ratio of each element to its value in the previous frame, so that an element rising from near silence dominates, an element falling by a large factor adds almost nothing and a gain common to both frames leaves the result almost unchanged.

Detailed Description

Functions that extract a scalar or vector value from 2 or more input vectors

Function Documentation

◆ xtract_attack_time()

int xtract_attack_time ( const double * data,
const int N,
const void * argv,
double * result )

Extract the attack time of an envelope: the time from the first element that reaches the start fraction of the maximum to the first element from there that reaches the stop fraction.

Parameters
*dataa pointer to the first element in an array of doubles representing an amplitude envelope or any segment with a single peak
Nthe number of elements to be considered, at least 1
*argva pointer to an array of three doubles: the sample rate, finite and at least 0, with 0 selecting 44100 Hz; the start fraction of the maximum; and the stop fraction of the maximum, each from 0 to 1
*resultthe attack time of N values from the array pointed to by *data in seconds, or 0 with no result when the maximum is not positive

◆ xtract_decay_time()

int xtract_decay_time ( const double * data,
const int N,
const void * argv,
double * result )

Extract the decay time of an envelope: the time from its maximum to the first later element at or below the threshold fraction of the maximum, or to the last element when none is.

Parameters
*dataa pointer to the first element in an array of doubles representing an amplitude envelope or any segment with a single peak
Nthe number of elements to be considered, at least 1
*argva pointer to an array of two doubles: the sample rate, finite and at least 0, with 0 selecting 44100 Hz; and the threshold fraction of the maximum, from 0 to 1
*resultthe decay time of N values from the array pointed to by *data in seconds, or 0 with no result when the maximum is not positive

◆ xtract_difference_vector()

int xtract_difference_vector ( const double * data,
const int N,
const void * argv,
double * result )

Extract the difference between two vectors.

Parameters
*dataa pointer to an array representing two distinct vectors, e.g. two successive magnitude spectra.
Nthe size of the array pointed to by *data, at least 2 and even
*argva pointer to NULL
*resulta pointer to an array of size N / 2 representing the difference between the two input vectors.

◆ xtract_flux()

int xtract_flux ( const double * data,
const int N,
const void * argv,
double * result )

Extract flux.

Parameters
*dataa pointer to the first element in an array of doubles comprising two successive spectral frames: the current frame in the first N/2 elements, the previous frame in the second N/2 elements
Nthe total number of elements in the array pointed to by *data (twice the frame size), at least 2 and even
*argva pointer to an array of three doubles as for xtract_lnorm(): the norm order, the filter type (enumeration xtract_lnorm_filter_types_), and the normalise flag. XTRACT_POSITIVE_SLOPE counts only the bins that rose from the previous frame, which is the half-wave rectified flux used for onset detection, and XTRACT_NEGATIVE_SLOPE only the bins that fell
*resulta pointer to a double representing the spectral flux: the L-p norm of the difference between the two frames

◆ xtract_itakura_saito_divergence()

int xtract_itakura_saito_divergence ( const double * data,
const int N,
const void * argv,
double * result )

Extract the Itakura-Saito divergence of the current spectral frame from the previous one.

Parameters
*dataa pointer to the first element in an array of doubles comprising two successive frames of positive coefficients: the current frame in the first N/2 elements, the previous frame in the second N/2 elements. Itakura and Saito define the divergence on power spectra; the elements are used as given
Nthe total number of elements in the array pointed to by *data (twice the frame size), at least 2 and even
*argvnot used
*resultthe divergence, at least 0, 0 for identical frames and unchanged when both frames are scaled by the same gain, or 0 with no result when either frame has an element that is not positive

◆ xtract_kullback_leibler_divergence()

int xtract_kullback_leibler_divergence ( const double * data,
const int N,
const void * argv,
double * result )

Extract the Kullback-Leibler divergence of the current spectral frame from the previous one, each frame scaled to sum to 1.

Parameters
*dataa pointer to the first element in an array of doubles comprising two successive frames of non-negative coefficients, e.g. magnitude spectra: the current frame in the first N/2 elements, the previous frame in the second N/2 elements
Nthe total number of elements in the array pointed to by *data (twice the frame size), at least 2 and even
*argvnot used
*resultthe divergence in nats, at least 0 and 0 for frames that differ only by a gain. Elements that are not positive count as 0. The result is 0 with no result when the current frame has no positive element, or has a positive element where the previous frame has none

◆ xtract_lnorm()

int xtract_lnorm ( const double * data,
const int N,
const void * argv,
double * result )

Extract the L-norm of a vector.

Parameters
*dataa pointer to the first element in an array of doubles representing the difference between two subsequent frames of output from a vector-based feature e.g. the *result from xtract_difference_vector()
Nthe length of the array pointed to by *data, at least 1
*argva pointer to an array of doubles, the first representing the "norm order". The second argument represents the filter type determining what values we consider from the difference vector as given in the enumeration xtract_lnorm_filter_types_ (libxtract.h), the third sets whether we want the result to be normalised in the range 0-1 (0 = no normalise, 1 = normalise)
*resulta pointer to a double representing the flux

◆ xtract_modified_kullback_leibler()

int xtract_modified_kullback_leibler ( const double * data,
const int N,
const void * argv,
double * result )

Extract the modified Kullback-Leibler onset function of Hainsworth and Macleod: the sum over the frame of the logarithm of 1 plus the ratio of each element to its value in the previous frame, so that an element rising from near silence dominates, an element falling by a large factor adds almost nothing and a gain common to both frames leaves the result almost unchanged.

Parameters
*dataa pointer to the first element in an array of doubles comprising two successive frames of non-negative coefficients, e.g. magnitude spectra: the current frame in the first N/2 elements, the previous frame in the second N/2 elements
Nthe total number of elements in the array pointed to by *data (twice the frame size), at least 2 and even
*argva pointer to a double, the value added to every element of the previous frame before the ratio is taken, finite and at least 0; it bounds the contribution of an element that rises from 0
*resultthe onset function, at least 0 and 0 when the current frame has no positive element; an unchanged positive element adds the logarithm of 2 when the value in argv is 0, and less when it is positive. Elements that are not positive count as 0. The result is 0 with no result when the value in argv is 0 and an element rises from 0