|
LibXtract 1.6.0
|
Functions | |
| int | xtract_spectrum (const double *data, const int N, const void *argv, double *result) |
| Extract frequency domain spectrum from time domain signal. | |
| int | xtract_autocorrelation_fft (const double *data, const int N, const void *argv, double *result) |
| Extract autocorrelation from time domain signal using FFT based method. | |
| int | xtract_mfcc (const double *data, const int N, const void *argv, double *result) |
| Extract Mel Frequency Cepstral Coefficients based on a method described by Rabiner. | |
| int | xtract_mel_spectrogram (const double *data, const int N, const void *argv, double *result) |
| Extract a Mel spectrogram (log-scaled mel-filtered energies). | |
| int | xtract_gfcc (const double *data, const int N, const void *argv, double *result) |
| Extract Gammatone Frequency Cepstral Coefficients. | |
| int | xtract_gammatone_spectrogram (const double *data, const int N, const void *argv, double *result) |
| Extract a gammatone spectrogram (log-scaled gammatone-filtered energies). | |
| int | xtract_mmbses (const double *data, const int N, const void *argv, double *result) |
| Extract Mel based Multi-Band Spectral Entropy Signature coefficients. | |
| int | xtract_spectral_subband_centroids (const double *data, const int N, const void *argv, double *result) |
| Extract centroids of the spectral mel subbands. | |
| int | xtract_dct (const double *data, const int N, const void *argv, double *result) |
| Extract the Discrete Cosine transform of a time domain signal. | |
| int | xtract_autocorrelation (const double *data, const int N, const void *argv, double *result) |
| Extract autocorrelation from time domain signal using time-domain autocorrelation technique. | |
| int | xtract_amdf (const double *data, const int N, const void *argv, double *result) |
| Extract Average Magnitude Difference Function from time domain signal. | |
| int | xtract_asdf (const double *data, const int N, const void *argv, double *result) |
| Extract Average Squared Difference Function from time domain signal. | |
| int | xtract_bark_coefficients (const double *data, const int N, const void *argv, double *result) |
| Extract Bark band coefficients based on a method. | |
| int | xtract_peak_spectrum (const double *data, const int N, const void *argv, double *result) |
| Extract the amplitude and frequency of spectral peaks from a magnitude spectrum. | |
| int | xtract_harmonic_spectrum (const double *data, const int N, const void *argv, double *result) |
| Extract the harmonic spectrum of from a of a peak spectrum. | |
| int | xtract_lpc (const double *data, const int N, const void *argv, double *result) |
| Extract Linear Predictive Coding Coefficients. | |
| int | xtract_lpcc (const double *data, const int N, const void *argv, double *result) |
| Extract Linear Predictive Coding Cepstral Coefficients. | |
| int | xtract_subbands (const double *data, const int N, const void *argv, double *result) |
| Extract subbands from a spectrum. | |
| int | xtract_moving_sum (const double *data, const int N, const void *argv, double *result) |
| Extract the sum of a series over a sliding window. | |
| int | xtract_moving_average (const double *data, const int N, const void *argv, double *result) |
| Extract the mean of a series over a sliding window. | |
| int | xtract_moving_variance (const double *data, const int N, const void *argv, double *result) |
| Extract the variance of a series over a sliding window. | |
| int | xtract_moving_standard_deviation (const double *data, const int N, const void *argv, double *result) |
| Extract the standard deviation of a series over a sliding window. | |
| int | xtract_moving_max (const double *data, const int N, const void *argv, double *result) |
| Extract the largest value of a series over a sliding window. | |
| int | xtract_moving_min (const double *data, const int N, const void *argv, double *result) |
| Extract the smallest value of a series over a sliding window. | |
| int | xtract_ewma_average (const double *data, const int N, const void *argv, double *result) |
| Extract the exponentially weighted moving average of a series. | |
| int | xtract_ewma_variance (const double *data, const int N, const void *argv, double *result) |
| Extract the exponentially weighted moving variance of a series about its exponentially weighted moving average. | |
| int | xtract_spectral_contrast (const double *data, const int N, const void *argv, double *result) |
| Extract the spectral contrast of a spectrum: in each of a set of octave bands, the natural log of the ratio of the mean of the band's largest coefficients to the mean of its smallest. | |
| int | xtract_chroma (const double *data, const int N, const void *argv, double *result) |
| Extract the chroma of a spectrum: the coefficients of the bins nearest each of the twelve pitch classes summed and scaled so that the largest class is 1. | |
| int | xtract_cqt (const double *data, const int N, const void *argv, double *result) |
| Extract the constant-Q spectrum of a magnitude/phase spectrum: the magnitude in each band of a kernel from xtract_init_cqt(), followed by the band centre frequencies. | |
| int | xtract_quantise (const double *data, const int N, const void *argv, double *result) |
| Extract the level of each element of an input vector on a scale of equal steps between two bounds. | |
| int | xtract_histogram (const double *data, const int N, const void *argv, double *result) |
| Extract the fraction of the elements of an input vector at each level. | |
Functions that extract a feature as a vector from an input vector
| int xtract_amdf | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract Average Magnitude Difference Function from time domain signal.
| *data | a pointer to the first element in an array of doubles representing an audio vector |
| N | the number of array elements to be considered, at least 1 |
| *argv | a pointer to NULL |
| *result | the AMDF of N values from the array pointed to by *data |
| int xtract_asdf | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract Average Squared Difference Function from time domain signal.
| *data | a pointer to the first element in an array of doubles representing an audio vector |
| N | the number of array elements to be considered, at least 1 |
| *argv | a pointer to NULL |
| *result | the ASDF of N values from the array pointed to by *data |
| int xtract_autocorrelation | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract autocorrelation from time domain signal using time-domain autocorrelation technique.
| *data | a pointer to the first element in an array of doubles representing an audio vector |
| N | the number of array elements to be considered, at least 1 |
| *argv | a pointer to NULL |
| *result | the autocorrelation of N values from the array pointed to by *data |
| int xtract_autocorrelation_fft | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract autocorrelation from time domain signal using FFT based method.
| *data | a pointer to the first element in an array of doubles representing an audio vector |
| N | the number of array elements to be considered, equal to the size passed to xtract_init_fft(); any other size, or no initialisation, is a bad state |
| *argv | a pointer to NULL |
| *result | the autocorrelation of N values from the array pointed to by *data |
| int xtract_bark_coefficients | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract Bark band coefficients based on a method.
| *data | a pointer to the first element in an array of spectral coefficients, the first half of the array pointed to by *result from xtract_spectrum() called with DC included (argv[2] == 1), so that element k is bin k as the band limits expect |
| N | the number of coefficients, half the transform size the band limits were initialised with, at least 1 |
| *argv | a pointer to an array of XTRACT_BARK_BANDS ints representing the limits of each bark band, obtained by calling xtract_init_bark() with the transform size; each limit must be at least 0 and no lower than the one before it |
| *result | a pointer to an array of XTRACT_BARK_BANDS doubles containing the resultant bark coefficients, the sum of the coefficients in each band |
The limits array pointed to by *argv must be obtained by first calling xtract_init_bark
| int xtract_chroma | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the chroma of a spectrum: the coefficients of the bins nearest each of the twelve pitch classes summed and scaled so that the largest class is 1.
| *data | a pointer to the first element in an array of doubles containing N/2 magnitude/power coefficients followed by N/2 bin frequencies in Hz, e.g. the *result from xtract_spectrum(). The coefficients are summed as given, so a power spectrum gives the energy in each class |
| N | the size of the array pointed to by *data, at least 2 and even |
| *argv | a pointer to an array of three doubles, each finite and at least 0: the frequency of A4 in Hz, with 0 selecting 440; the lowest bin frequency included, with 0 including every bin above 0 Hz; and the highest bin frequency included, with 0 including every bin above the lowest, and otherwise greater than the lowest. The 40 Hz and 5000 Hz range the descriptor gives as defaults is applied only when passed |
| *result | a pointer to an array of XTRACT_PITCH_CLASSES doubles, the first for C and the last for B, each from the bins whose frequency rounds to that pitch class in any octave, scaled to a maximum of 1. The array is zeroed with no result when no included bin has a positive coefficient; bins at or below 0 Hz are never included |
| int xtract_cqt | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the constant-Q spectrum of a magnitude/phase spectrum: the magnitude in each band of a kernel from xtract_init_cqt(), followed by the band centre frequencies.
| *data | a magnitude/phase spectrum with DC included, the *result of xtract_spectrum() by XTRACT_MAGNITUDE_PHASE_SPECTRUM with the third argument 1: the first N/2 elements are the bin magnitudes from DC upward and the next N/2 their phases |
| N | the number of array elements to be considered, at least 2 and even, and equal to the N the kernel was built for |
| *argv | a pointer to an xtract_cqt_kernel from xtract_init_cqt() |
| *result | a pointer to an array of twice the kernel's n_bins doubles: the n_bins band magnitudes, on the scale of the magnitudes given, followed by the band centre frequencies in Hz. This is the layout of the *result of xtract_spectrum(), so it can be passed on to xtract_chroma(), xtract_spectral_contrast() and the other functions that take a spectrum with its frequencies |
| int xtract_dct | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the Discrete Cosine transform of a time domain signal.
| *data | a pointer to the first element in an array of doubles representing an audio vector |
| N | the number of array elements to be considered, at least 1 |
| *argv | a pointer to a cosine table as allocated by xtract_init_dct(N), or NULL. Both give the same result but the table avoids the need to recompute the table on each call |
| *result | a pointer to an array of at least N doubles to receive the DCT coefficients |
| int xtract_ewma_average | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the exponentially weighted moving average of a series.
| *data | a pointer to the first element in an array of doubles |
| N | the number of elements in the array pointed to by *data, at least 1 |
| *argv | a pointer to a double holding the smoothing factor, the weight given to each new element, between 0 and 1 inclusive |
| *result | a pointer to an array of N doubles, one average per element of *data, the first equal to the first element |
| int xtract_ewma_variance | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the exponentially weighted moving variance of a series about its exponentially weighted moving average.
| *data | a pointer to the first element in an array of doubles |
| N | the number of elements in the array pointed to by *data, at least 1 |
| *argv | a pointer to a double holding the smoothing factor, the weight given to each new element, between 0 and 1 inclusive |
| *result | a pointer to an array of N doubles, one variance per element of *data, the first being 0 |
| int xtract_gammatone_spectrogram | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract a gammatone spectrogram (log-scaled gammatone-filtered energies).
This computes the intermediate step of GFCC extraction: the gammatone filter bank is applied to the magnitude spectrum and the result is log-scaled.
| *data | a pointer to the first element in an array of spectral coefficients, the first half of the array pointed to by *result from xtract_spectrum() called with DC included (argv[2] == 1), so that element k is bin k as the filterbank expects. the gammatone filterbank is applied to the power spectrum (XTRACT_POWER_SPECTRUM) in the same way; a magnitude spectrum may be passed instead |
| N | the number of coefficients, half the transform size the filterbank was initialised with, at least 1 |
| *argv | a pointer to a data structure of type xtract_mel_filter, containing n_filters coefficient tables to make up a gammatone filterbank; n_filters must be at least 1 and filters, and each of its rows, non-NULL, each row holding at least N coefficients |
| *result | a pointer to an array containing the resultant log gammatone energies (one per filter) |
The data structure pointed to by *argv must be obtained by first calling xtract_init_gfcc
| int xtract_gfcc | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract Gammatone Frequency Cepstral Coefficients.
GFCCs are cepstral coefficients computed through a gammatone filter bank. They are more robust to noise than MFCCs, which use a mel filter bank.
| *data | a pointer to the first element in an array of spectral coefficients, the first half of the array pointed to by *result from xtract_spectrum() called with DC included (argv[2] == 1), so that element k is bin k as the filterbank expects. the gammatone filterbank is applied to the power spectrum (XTRACT_POWER_SPECTRUM) in the same way; a magnitude spectrum may be passed instead |
| N | the number of coefficients, half the transform size the filterbank was initialised with, at least 1 |
| *argv | a pointer to a data structure of type xtract_mel_filter, containing n_filters coefficient tables to make up a gammatone filterbank; n_filters must be at least 1 and filters, and each of its rows, non-NULL, each row holding at least N coefficients |
| *result | a pointer to an array containing the resultant GFCC |
The data structure pointed to by *argv must be obtained by first calling xtract_init_gfcc. Its dct_table field is passed to xtract_dct() as the table for the final transform; set it from xtract_init_dct(n_filters) or to NULL
| int xtract_harmonic_spectrum | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the harmonic spectrum of from a of a peak spectrum.
| *data | a pointer to the first element in an array of doubles representing the peak spectrum of an audio vector (e.g. *result from xtract_peaks). It is expected that the first half of the array pointed to by *data will contain amplitudes for each peak considered, and the second half will contain the respective frequencies |
| N | the size of the array pointed to by *data, at least 2 and even |
| *argv | a pointer to an array containing the fundamental (f0) of the spectrum, finite and at least 0 (0 gives no result), and a threshold (t) where 0<=t<=1.0, and t determines the distance from the nearest harmonic number within which a partial can be considered harmonic. |
| *result | a pointer to an array of size N containing N/2 magnitude coefficients and N/2 bin frequencies. |
| int xtract_histogram | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the fraction of the elements of an input vector at each level.
| *data | a pointer to the first element in an array of doubles, each a whole number from 0 to one less than the number of levels, as xtract_quantise() gives them |
| N | the number of elements to be considered, at least 1 |
| *argv | a pointer to an int, the number of levels, at least 1 |
| *result | a pointer to an array of doubles, one per level: the number of elements at that level divided by N, so that the array sums to 1. It is not written when an element is not a whole number or is outside the levels, which is an argument error |
| int xtract_lpc | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract Linear Predictive Coding Coefficients.
Based on algorithm in Rabiner and Juang as implemented by Jutta Degener in Dr. Dobb's Journal December, 1994.
Returns N-1 reflection (PARCOR) coefficients and N-1 LPC coefficients via *result
| *data | N autocorrelation values e.g the data pointed to by *result from xtract_autocorrelation() |
| N | the number of autocorrelation values to be considered, at least 2 |
| *argv | a pointer to NULL |
| *result | a pointer to an array containing N-1 reflection coefficients and N-1 LPC coefficients. |
An array of size 2 * (N - 1) must be allocated, and *result must point to its first element.
| int xtract_lpcc | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract Linear Predictive Coding Cepstral Coefficients.
| *data | a pointer to an array of N doubles: a gain term followed by the p LPC coefficients a[1] to a[p], e.g. one element followed by the second half of the array pointed to by *result from xtract_lpc(). The gain term is not read |
| N | the size of the array pointed to by *data, one more than the number of LPC coefficients p, at least 2 |
| *argv | a pointer to an int representing the order (Q) of the result vector. Must be greater than 0. According to Rabiner and Juang the recommended ratio is Q ~ (3/2)p where p is the number of LPC coefficients and Q > p; XTRACT_LPCC_CEPSTRUM_ORDER(p) computes this value. If argv is NULL, Q defaults to p (the result is then no longer than the input). |
| *result | a pointer to an array containing the resultant LPCC. |
An array of size Q must be allocated, and *result must point to its first element. With an explicit argv, Q is argv[0]; with argv == NULL, Q is the number of LPC coefficients.
| int xtract_mel_spectrogram | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract a Mel spectrogram (log-scaled mel-filtered energies).
This computes the intermediate step of MFCC extraction: the mel filter bank is applied to the magnitude spectrum and the result is log-scaled.
| *data | a pointer to the first element in an array of spectral coefficients, the first half of the array pointed to by *result from xtract_spectrum() called with DC included (argv[2] == 1), so that element k is bin k as the filterbank expects. Rabiner and Juang define the mel cepstrum on the power spectrum (XTRACT_POWER_SPECTRUM); a magnitude spectrum may be passed instead |
| N | the number of coefficients, half the transform size the filterbank was initialised with, at least 1 |
| *argv | a pointer to a data structure of type xtract_mel_filter, containing n_filters coefficient tables to make up a mel-spaced filterbank; n_filters must be at least 1 and filters, and each of its rows, non-NULL, each row holding at least N coefficients |
| *result | a pointer to an array containing the resultant log mel energies (one per filter) |
The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc
| int xtract_mfcc | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract Mel Frequency Cepstral Coefficients based on a method described by Rabiner.
| *data | a pointer to the first element in an array of spectral coefficients, the first half of the array pointed to by *result from xtract_spectrum() called with DC included (argv[2] == 1), so that element k is bin k as the filterbank expects. Rabiner and Juang define the mel cepstrum on the power spectrum (XTRACT_POWER_SPECTRUM); a magnitude spectrum may be passed instead |
| N | the number of coefficients, half the transform size the filterbank was initialised with, at least 1 |
| *argv | a pointer to a data structure of type xtract_mel_filter, containing n_filters coefficient tables to make up a mel-spaced filterbank; n_filters must be at least 1 and filters, and each of its rows, non-NULL, each row holding at least N coefficients |
| *result | a pointer to an array containing the resultant MFCC |
The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc. Its dct_table field is passed to xtract_dct() as the table for the final transform; set it from xtract_init_dct(n_filters) or to NULL
| int xtract_mmbses | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract Mel based Multi-Band Spectral Entropy Signature coefficients.
| *data | a magnitude/phase spectrum, the result from xtract_spectrum() by XTRACT_MAGNITUDE_PHASE_SPECTRUM. The first N/2 elements are bin magnitudes and the next N/2 the corresponding phases. |
| N | the number of array elements to be considered (the full magnitude+phase array length; N/2 frequency bins are processed), at least 2 and even |
| *argv | a pointer to a data structure of type xtract_mel_filter, containing n_filters coefficient tables to make up a mel-spaced filterbank; n_filters must be at least 1 and filters, and each of its rows, non-NULL, each row holding at least N / 2 coefficients |
| *result | a pointer to an array of n_filters elements containing the resultant MEL-MBSES |
Each filter band's complex coefficients are modelled as a zero-mean bivariate (real, imaginary) Gaussian and the band's value is that distribution's differential entropy, H = ln(2*pi*e) + (1/2)ln(det of the 2x2 covariance).
The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc. The method is described by: Rincon et al: A Context-Aware Baby Monitor for the Automatic Selective Archiving of the Language of Infants (2013)
| int xtract_moving_average | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the mean of a series over a sliding window.
| *data | a pointer to the first element in an array of doubles |
| N | the number of elements in the array pointed to by *data, at least the window length |
| *argv | a pointer to an int holding the window length, at least 1 and at most N |
| *result | a pointer to an array of N - window + 1 doubles, one mean per window position, the first over the first window elements of *data |
| int xtract_moving_max | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the largest value of a series over a sliding window.
| *data | a pointer to the first element in an array of doubles |
| N | the number of elements in the array pointed to by *data, at least the window length |
| *argv | a pointer to an int holding the window length, at least 1 and at most N |
| *result | a pointer to an array of N - window + 1 doubles, one maximum per window position, the first over the first window elements of *data |
| int xtract_moving_min | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the smallest value of a series over a sliding window.
| *data | a pointer to the first element in an array of doubles |
| N | the number of elements in the array pointed to by *data, at least the window length |
| *argv | a pointer to an int holding the window length, at least 1 and at most N |
| *result | a pointer to an array of N - window + 1 doubles, one minimum per window position, the first over the first window elements of *data |
| int xtract_moving_standard_deviation | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the standard deviation of a series over a sliding window.
| *data | a pointer to the first element in an array of doubles |
| N | the number of elements in the array pointed to by *data, at least the window length |
| *argv | a pointer to an int holding the window length, at least 2 and at most N |
| *result | a pointer to an array of N - window + 1 doubles, one sample standard deviation per window position, the square root of what xtract_moving_variance gives |
| int xtract_moving_sum | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the sum of a series over a sliding window.
| *data | a pointer to the first element in an array of doubles |
| N | the number of elements in the array pointed to by *data, at least the window length |
| *argv | a pointer to an int holding the window length, at least 1 and at most N |
| *result | a pointer to an array of N - window + 1 doubles, one sum per window position, the first over the first window elements of *data |
| int xtract_moving_variance | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the variance of a series over a sliding window.
| *data | a pointer to the first element in an array of doubles |
| N | the number of elements in the array pointed to by *data, at least the window length |
| *argv | a pointer to an int holding the window length, at least 2 and at most N |
| *result | a pointer to an array of N - window + 1 doubles, one sample variance (with Bessel's correction, as xtract_variance gives) per window position, the first over the first window elements of *data |
| int xtract_peak_spectrum | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the amplitude and frequency of spectral peaks from a magnitude spectrum.
| *data | a pointer to an array of size N containing N magnitude/power/log magnitude/log power coefficients: the first half of the array pointed to by *result from xtract_spectrum() with DC discarded (argv[2] == 0, the default), so that coefficient n is bin n + 1 and the reported frequencies follow that layout |
| N | the size of the input array, at least 1 (note: it is assumed that enough memory has been allocated for an output array twice the size) |
| *argv | a pointer to an array of doubles, the first representing the bin spacing in Hz, the sample rate divided by the transform length (twice N for the first half of an xtract_spectrum() output), finite and at least 0 (0 selects 44100 Hz over a transform of 2N), the second representing the peak threshold as percentage of the magnitude of the maximum peak found, from 0 to 100 |
| *result | a pointer to an array of size N * 2 containing N magnitude/power/log magnitude/log power coefficients and N bin frequencies. |
| int xtract_quantise | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the level of each element of an input vector on a scale of equal steps between two bounds.
| *data | a pointer to the first element in an array of doubles |
| N | the number of elements to be considered, at least 1 |
| *argv | a pointer to an array of three doubles: the lower bound and the upper bound, each finite and the upper not below the lower, as xtract_lowest_value() and xtract_highest_value() give them for the whole range of a vector; and the number of levels, a whole number from 1 to 2147483647 |
| *result | a pointer to an array of N doubles: for each element the whole number of its level, from 0 to one less than the number of levels. The range between the bounds is divided into that many steps of equal width, and an element takes the number of the step it falls in. An element at or below the lower bound is at level 0 and one at or above the upper bound is at the highest level. An element that is NaN gives NaN |
| int xtract_spectral_contrast | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract the spectral contrast of a spectrum: in each of a set of octave bands, the natural log of the ratio of the mean of the band's largest coefficients to the mean of its smallest.
| *data | a pointer to the first element in an array of doubles containing N/2 magnitude/power coefficients followed by N/2 bin frequencies in Hz, e.g. the *result from xtract_spectrum() |
| N | the size of the array pointed to by *data, at least 2 and even |
| *argv | a pointer to an array of three doubles: the number of octave bands, cast to an integer, at least 1; the lower edge of the first octave band in Hz, finite and at least 0; and the fraction of a band's bins averaged at each end, from 0 to 1, at least one bin being averaged whatever the fraction |
| *result | a pointer to an array of argv[0] + 1 doubles: the contrast of the bins below the first edge, then of each octave band from that edge, the last band running to the highest bin frequency. A coefficient that is NaN is left out of its band. The array is zeroed with no result when a band contains no bin or the mean of its smallest coefficients is not positive |
| int xtract_spectral_subband_centroids | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract centroids of the spectral mel subbands.
| *data | a pointer to the first element in an array of doubles representing the spectrum of an audio vector, (e.g. the array pointed to by *result from xtract_spectrum(), xtract_peak_spectrum() or xtract_harmonic_spectrum()): N/2 amplitudes followed by N/2 frequencies |
| N | the size of the array pointed to by *data, at least 2 and even |
| *argv | a pointer to a data structure of type xtract_mel_filter, containing n_filters coefficient tables to make up a mel-spaced filterbank over the N/2 bins, the bank xtract_init_mfcc() builds for the transform that produced the spectrum; n_filters must be at least 1 and filters, and each of its rows, non-NULL, each row holding at least N / 2 coefficients |
| *result | a pointer to an array of n_filters doubles containing the spectral band centroids, in the unit of the frequencies |
Note: for a more 'accurate' result *result from xtract_peak_spectrum() can be passed in. This gives the interpolated peak frequency locations.
| int xtract_spectrum | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract frequency domain spectrum from time domain signal.
| *data | a pointer to the first element in an array of doubles representing an audio vector |
| N | the number of array elements to be considered, equal to the size passed to xtract_init_fft(); any other size, or no initialisation, is a bad state |
| *argv | a pointer to an array of doubles, the first representing (samplerate / N), finite and at least 0 (0 selects 44100 / N), the second will be cast to an integer and determines the spectrum type, a value of the enumeration xtract_spectrum_ (e.g. XTRACT_MAGNITUDE_SPECTRUM, XTRACT_LOG_POWER_SPECTRUM). The third argument determines whether or not the DC component is included in the output. If argv[2] == 0 (the default), the N/2 coefficients are bins 1 to N/2, so the Nyquist bin is included, DC is not, and the frequency of coefficient m is (m + 1) * samplerate / N. If argv[2] == 1, the N/2 coefficients are bins 0 to N/2 - 1, so DC is included, the Nyquist bin is not, and the frequency of coefficient m is m * samplerate / N. The output is N elements in either case. The fourth argument determines whether the magnitude/power coefficients are to be normalised. If argv[3] == 1, then the coefficients are normalised. Both flags must be 0 or 1. |
| *result | a pointer to an array of size N containing N/2 magnitude/power/log magnitude/log power coefficients and N/2 bin frequencies. For XTRACT_MAGNITUDE_PHASE_SPECTRUM the second N/2 elements are instead the bin phases in radians, in the convention where a cosine centred on a bin has phase 0 and a sine -pi/2, on every platform. |
The magnitude/power coefficients are scaled to the range 0-1 so that for a given coefficient x, 0 <= x <= 1
| int xtract_subbands | ( | const double * | data, |
| const int | N, | ||
| const void * | argv, | ||
| double * | result ) |
Extract subbands from a spectrum.
| *data | a pointer to an array of size N containing N magnitude/power/log magnitude/log power coefficients. (e.g. the first half of the array pointed to by *result from xtract_spectrum(). |
| N | the number of elements from the array pointed to by *data to be considered, at least 1 |
| *argv | A pointer to an array containing four integers. The first represents the scalar extraction function to applied to each subband e.g. XTRACT_SUM or XTRACT_MEAN, one of the features listed below; the second represents the number of subbands required, at least 1; the third represents the frequency scale to be used for the subband bounds as defined in the enumeration xtract_subband_scales_ (libxtract.h). The fourth integer represent the start point of the subbands as a location in the input array as pointed to by *data (e.g. a value of 5 would start the subband extraction at bin 5), from 0 to N - 1. More linear bands than there are bins after the start, or an octave start of 0, gives a band of no bins and is an argument error |
| *result | A pointer to an array containing the resultant subband values. The calling function is responsible for allocating and freeing memory for *result. xtract_subbands() assumes that at least argv[1] * sizeof(double) bytes have been allocated. If the requested number of bands extends the subband range beyond N, then the remaining bands will be set to 0. If the array pointed to by *result has more than argv[1] elements, the superfluous elements will be unchanged. |
xtract_subbands() divides a spectrum into subbands and applies the function given by argv[0] to the values in each subband to give a 'reduced' representation of the spectrum as *result
Specifying XTRACT_OCTAVE_SUBBANDS will extract subbands at each octave from the start bin until argv[1] is reached or N is reached Specifying XTRACT_LINEAR_SUBBANDS will extract argv[1] equal sized subbands between the start bin and N
argv[0] must be a feature that reduces a plain vector to one scalar with a NULL argv: XTRACT_MEAN, XTRACT_SUM, XTRACT_HIGHEST_VALUE, XTRACT_NONZERO_COUNT, XTRACT_RMS_AMPLITUDE, XTRACT_ZCR, XTRACT_FLATNESS, XTRACT_IRREGULARITY_K, XTRACT_IRREGULARITY_J, XTRACT_SMOOTHNESS, XTRACT_LOUDNESS or XTRACT_SHARPNESS. Any other feature is an argument error. The feature is called on each band with a NULL argv, and its own argument checks apply to the band