LibXtract  0.7.1
Data Structures | Macros | Typedefs | Enumerations | Functions
API

Data Structures

struct  _xtract_function_descriptor
 Data structure containing useful information about functions provided by LibXtract. More...
 
struct  xtract_mel_filter_
 A structure to store a set of n_filters Mel filters. More...
 

Macros

#define XTRACT_FEATURES   62
 

Typedefs

typedef enum type_ xtract_type_t
 Enumeration of data types.
 
typedef enum unit_ xtract_unit_t
 Enumeration of units.
 
typedef enum xtract_vector_ xtract_vector_t
 Enumeration of vector format types.
 
typedef struct
_xtract_function_descriptor 
xtract_function_descriptor_t
 Data structure containing useful information about functions provided by LibXtract.
 
typedef struct xtract_mel_filter_ xtract_mel_filter
 A structure to store a set of n_filters Mel filters.
 

Enumerations

enum  xtract_features_ {
  XTRACT_MEAN, XTRACT_VARIANCE, XTRACT_STANDARD_DEVIATION, XTRACT_AVERAGE_DEVIATION,
  XTRACT_SKEWNESS, XTRACT_KURTOSIS, XTRACT_SPECTRAL_MEAN, XTRACT_SPECTRAL_VARIANCE,
  XTRACT_SPECTRAL_STANDARD_DEVIATION, XTRACT_SPECTRAL_SKEWNESS, XTRACT_SPECTRAL_KURTOSIS, XTRACT_SPECTRAL_CENTROID,
  XTRACT_IRREGULARITY_K, XTRACT_IRREGULARITY_J, XTRACT_TRISTIMULUS_1, XTRACT_TRISTIMULUS_2,
  XTRACT_TRISTIMULUS_3, XTRACT_SMOOTHNESS, XTRACT_SPREAD, XTRACT_ZCR,
  XTRACT_ROLLOFF, XTRACT_LOUDNESS, XTRACT_FLATNESS, XTRACT_FLATNESS_DB,
  XTRACT_TONALITY, XTRACT_CREST, XTRACT_NOISINESS, XTRACT_RMS_AMPLITUDE,
  XTRACT_SPECTRAL_INHARMONICITY, XTRACT_POWER, XTRACT_ODD_EVEN_RATIO, XTRACT_SHARPNESS,
  XTRACT_SPECTRAL_SLOPE, XTRACT_LOWEST_VALUE, XTRACT_HIGHEST_VALUE, XTRACT_SUM,
  XTRACT_NONZERO_COUNT, XTRACT_HPS, XTRACT_F0, XTRACT_FAILSAFE_F0,
  XTRACT_WAVELET_F0, XTRACT_MIDICENT, XTRACT_LNORM, XTRACT_FLUX,
  XTRACT_ATTACK_TIME, XTRACT_DECAY_TIME, XTRACT_DIFFERENCE_VECTOR, XTRACT_AUTOCORRELATION,
  XTRACT_AMDF, XTRACT_ASDF, XTRACT_BARK_COEFFICIENTS, XTRACT_PEAK_SPECTRUM,
  XTRACT_SPECTRUM, XTRACT_AUTOCORRELATION_FFT, XTRACT_MFCC, XTRACT_DCT,
  XTRACT_HARMONIC_SPECTRUM, XTRACT_LPC, XTRACT_LPCC, XTRACT_SUBBANDS,
  XTRACT_WINDOWED, XTRACT_SMOOTHED
}
 Enumeration of features, elements are used as indixes to an array of pointers to feature extracton functions.
 
enum  xtract_feature_init_ { XTRACT_INIT_MFCC = 100, XTRACT_INIT_BARK, XTRACT_INIT_WINDOWED }
 Enumeration of feature initialisation functions.
 
enum  xtract_feature_types_ { XTRACT_SCALAR, XTRACT_VECTOR, XTRACT_DELTA }
 Enumeration of feature types.
 
enum  xtract_mfcc_types_ { XTRACT_EQUAL_GAIN, XTRACT_EQUAL_AREA }
 Enumeration of mfcc types.
 
enum  xtract_lnorm_filter_types_ { XTRACT_NO_LNORM_FILTER, XTRACT_POSITIVE_SLOPE, XTRACT_NEGATIVE_SLOPE }
 
enum  xtract_return_codes_ {
  XTRACT_SUCCESS, XTRACT_MALLOC_FAILED, XTRACT_BAD_ARGV, XTRACT_BAD_VECTOR_SIZE,
  XTRACT_BAD_STATE, XTRACT_DENORMAL_FOUND, XTRACT_NO_RESULT, XTRACT_FEATURE_NOT_IMPLEMENTED,
  XTRACT_ARGUMENT_ERROR
}
 Enumeration of return codes.
 
enum  xtract_spectrum_ { XTRACT_MAGNITUDE_SPECTRUM, XTRACT_LOG_MAGNITUDE_SPECTRUM, XTRACT_POWER_SPECTRUM, XTRACT_LOG_POWER_SPECTRUM }
 Enumeration of spectrum types.
 
enum  xtract_subband_scales_ { XTRACT_OCTAVE_SUBBANDS, XTRACT_LINEAR_SUBBANDS }
 Subband scales.
 
enum  type_ { XTRACT_FLOAT, XTRACT_FLOATARRAY, XTRACT_INT, XTRACT_MEL_FILTER }
 Enumeration of data types.
 
enum  unit_ {
  XTRACT_HERTZ = 2, XTRACT_ANY_AMPLITUDE_HERTZ, XTRACT_DBFS, XTRACT_DBFS_HERTZ,
  XTRACT_PERCENT, XTRACT_BINS, XTRACT_SONE, XTRACT_MIDI_CENT
}
 Enumeration of units.
 
enum  xtract_bool_t { XTRACT_FALSE, XTRACT_TRUE }
 Boolean.
 
enum  xtract_window_types_ {
  XTRACT_GAUSS, XTRACT_HAMMING, XTRACT_HANN, XTRACT_BARTLETT,
  XTRACT_TRIANGULAR, XTRACT_BARTLETT_HANN, XTRACT_BLACKMAN, XTRACT_KAISER,
  XTRACT_BLACKMAN_HARRIS
}
 Window types.
 
enum  xtract_vector_ {
  XTRACT_SPECTRAL, XTRACT_SPECTRAL_MAGNITUDES, XTRACT_SPECTRAL_PEAKS, XTRACT_SPECTRAL_PEAKS_MAGNITUDES,
  XTRACT_SPECTRAL_PEAKS_FREQUENCIES, XTRACT_SPECTRAL_HARMONICS, XTRACT_SPECTRAL_HARMONICS_MAGNITUDES, XTRACT_SPECTRAL_HARMONICS_FREQUENCIES,
  XTRACT_AUTOCORRELATION_COEFFS, XTRACT_ARBITRARY_SERIES, XTRACT_AUDIO_SAMPLES, XTRACT_MEL_COEFFS,
  XTRACT_LPC_COEFFS, XTRACT_LPCC_COEFFS, XTRACT_BARK_COEFFS, XTRACT_SUBFRAMES,
  XTRACT_NO_DATA
}
 Enumeration of vector format types.
 

Functions

int xtract_init_wavelet_f0_state (void)
 An array of pointers to functions that perform the extraction. More...
 
int xtract_init_mfcc (int N, double nyquist, int style, double freq_min, double freq_max, int freq_bands, double **fft_tables)
 A function to initialise a mel filter bank. More...
 
int xtract_init_bark (int N, double sr, int *band_limits)
 A function to initialise bark filter bounds. More...
 
int xtract_init_fft (int N, int feature_name)
 An initialisation function for functions using FFT. More...
 
void xtract_free_fft (void)
 Free memory used for fft plans. More...
 
double * xtract_init_window (const int N, const int type)
 Make a window of a given type and return a pointer to it. More...
 
void xtract_free_window (double *window)
 Free a window as allocated by xtract_make_window() More...
 
xtract_function_descriptor_txtract_make_descriptors ()
 
int xtract_free_descriptors (xtract_function_descriptor_t *fd)
 

Detailed Description

Defines a very simple API that provides access to the functions in the library

Function Documentation

void xtract_free_fft ( void  )

Free memory used for fft plans.

This function should be used to explicitly free memory allocated for ffts by xtract_init_fft(). It is primarily intended for use if a new FFT needs to be taken with a different blocksize. If only one fft size is required then there is no need to call this function since it will be called when the program exits.

void xtract_free_window ( double *  window)

Free a window as allocated by xtract_make_window()

Parameters
*windowa pointer to an array of doubles as allocated by xtract_make_window()
int xtract_init_bark ( int  N,
double  sr,
int *  band_limits 
)

A function to initialise bark filter bounds.

A pointer to an array of BARK_BANDS ints most be passed in, and is populated with BARK_BANDS fft bin numbers representing the limits of each band

Parameters
Nthe audio block size
srThe sample audio sample rate
*band_limitsa pointer to an array of BARK_BANDS ints
int xtract_init_fft ( int  N,
int  feature_name 
)

An initialisation function for functions using FFT.

This function initialises global data structures used by functions requiring FFT functionality. It can be called multiple times with different feature names. Calling it more than once with the same feature name is not a valid operation and will result in a memory leak.

Parameters
Nthe size of the FFT
feature_namethe name of the feature the FFT is being used for, e.g. XTRACT_DCT
int xtract_init_mfcc ( int  N,
double  nyquist,
int  style,
double  freq_min,
double  freq_max,
int  freq_bands,
double **  fft_tables 
)

A function to initialise a mel filter bank.

It is up to the caller to pass in a pointer to memory allocated for freq_bands arrays of length N. This function populates these arrays with magnitude coefficients representing the mel filterbank on a linear scale

int xtract_init_wavelet_f0_state ( void  )

An array of pointers to functions that perform the extraction.

Parameters
*dataa pointer to the start of the input data (usually the first element in an array)
Nthe number of elements to be processed
*argvan abitrary number of additional arguments, used to pass additional parameters to the function being called. All arguments are compulsary!
*resulta pointer to the first element in the result

Each function will iterate over N array elements, the first of which is pointed to by *data. It is up to the calling function to ensure that the array is in the format expected by the function being called.

For scalar and delta features, *result will point to a single value.

For vector features it will point to the first element in an array.

Memory for this array must be allocated and freed by the calling function.

All functions return an integer error code as descibed in the enumeration return_codes_

The preprocessor macro: XTRACT must be defined before this can be used

example:

#include <stdio.h>
#define XTRACT
#include "libxtract.h"

main () {
double values[] = {1.0, 2.0, 3.0, 4.0, 5.0};
int N = 5;
double mean;

xtract[MEAN]((void *)values, N, NULL, &mean);

printf("Mean = %.2f\n", mean);
}

The calling function may additionally make some tests against the value returned by xtractA function to initialise wavelet f0 detector state

double* xtract_init_window ( const int  N,
const int  type 
)

Make a window of a given type and return a pointer to it.

Parameters
Nthe size of the window
typethe type of the window as given in the enumeration window_types_