LibXtract 1.6.0
Helper functions

Functions

int xtract_windowed (const double *data, const int N, const void *argv, double *result)
 Apply a window function to an array of length N.
int xtract_features_from_subframes (const double *data, const int N, const int feature, const void *argv, double *result)
 Divides the array pointed to by *data into two subframes, and applies a given feature to each subframe, returning them in a single array pointed to by result.
int xtract_is_denormal (double const d)
 Test whether a number is denormal.
bool xtract_is_poweroftwo (unsigned int x)
 Test whether a number is a power of two.
int xtract_smoothed (const double *data, const int N, const void *argv, double *result)
 Smooth a vector.

Detailed Description

Declares helper functions, and their parameters.

Note
These functions don't necessarily conform to the prototype used in xtract_scalar.h and xtract_vector.h, and as such are intended to be called directly by name. The xtract[] function pointer array (libxtract.h) contains only functions that conform to it

Function Documentation

◆ xtract_features_from_subframes()

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

Divides the array pointed to by *data into two subframes, and applies a given feature to each subframe, returning them in a single array pointed to by result.

Parameters
*dataan array of doubles
Nthe number of elements in the array pointed by *data, at least 2 and even
featurean integer representing the feature to be applied to each subframe in data, a value as given in the enumeration xtract_features_ (libxtract.h) whose result is no longer than its input: every scalar feature, and XTRACT_DCT, XTRACT_AUTOCORRELATION, XTRACT_AMDF, XTRACT_ASDF, XTRACT_AUTOCORRELATION_FFT, XTRACT_SPECTRUM, XTRACT_HARMONIC_SPECTRUM, XTRACT_DIFFERENCE_VECTOR, XTRACT_WINDOWED and XTRACT_SMOOTHED. Any other feature is an argument error, as the two results of N / 2 values could not both fit in *result
*argva pointer to the argument vector to be passed to the feature extraction function as determined by feature
*resulta pointer to the 'packed' results of the feature calculation. This may be passed in as *data to xtract_features_from_subframes() to calculate further features on the subframes, or xtract_difference_vector(), to get the difference between the subframes. A subframe that yields no result has its N / 2 values set to 0 while the other subframe is still computed, and XTRACT_NO_RESULT is returned; any other failure is returned as soon as a subframe reports it

It is important to ensure that any init*() functions that are called in preparation for functions that are called on subframes are given the subframe size as 'N', which is half the frame size. i.e. if xtract_features_from_subframes() is called with N=64, and feature=XTRACT_SPECTRUM, then xtract_init_fft() should be called with N=32.

◆ xtract_smoothed()

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

Smooth a vector.

Parameters
*dataa pointer to an array of doubles
Nthe number of elements in the array pointed to by *data to be smoothed, at least 1
*argva pointer to a double giving the smoothing gain; NULL is an argument error
*resulta pointer to the first element an array containing the smoothed data
Note
if passing in a spectrum e.g. *result from xtract_spectrum(), then N for xtract_smoothed() should be N / 2 with respect to the N for xtract_spectrum() so only amplitude components are smoothed, not frequencies!

◆ xtract_windowed()

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

Apply a window function to an array of length N.

Parameters
*dataa pointer to an array of doubles
Nthe number of elements in the array pointed to by *data, at least 1
*argva pointer to a window function of at least N elements as returned by xtract_make_window(); NULL is an argument error
*resulta pointer to the first element an array containing the windowed data

It is up to the caller to generate and free the array containing the window, and to allocate and free memory of size N to hold the data pointed to by *result