jamie@1: /* libxtract feature extraction library jamie@1: * jamie@1: * Copyright (C) 2006 Jamie Bullock jamie@1: * jamie@1: * This program is free software; you can redistribute it and/or modify jamie@1: * it under the terms of the GNU General Public License as published by jamie@1: * the Free Software Foundation; either version 2 of the License, or jamie@1: * (at your option) any later version. jamie@1: * jamie@1: * This program is distributed in the hope that it will be useful, jamie@1: * but WITHOUT ANY WARRANTY; without even the implied warranty of jamie@1: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jamie@1: * GNU General Public License for more details. jamie@1: * jamie@1: * You should have received a copy of the GNU General Public License jamie@1: * along with this program; if not, write to the Free Software jamie@1: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, jamie@1: * USA. jamie@1: */ jamie@1: jamie@1: /* xtract_scalar.h: declares functions that extract a feature as a vector from an input vector */ jamie@1: jamie@1: #ifndef XTRACT_VECTOR jamie@1: #define XTRACT_VECTOR jamie@1: jamie@1: #ifdef __cplusplus jamie@1: extern "C" { jamie@1: #endif jamie@20: jamie@20: /** jamie@20: * \defgroup vector extraction functions jamie@20: * jamie@20: * Defines vectorr extraction functions, and their parameters. jamie@20: * @{ jamie@20: */ jamie@1: jamie@2: /** \brief Extract normalized (0-1) frequency domain magnitude spectrum from time domain signal jamie@2: * jamie@2: * \param *data: a pointer to the first element in an array of floats representing an audio vector jamie@2: * \param N: the number of array elements to be considered jamie@47: * \param *argv: a pointer to a float representing the sample rate of the audio jamie@47: * \param *result: a pointer to an array containing N/2 bin frequencies, and N/2 jamie@47: * magnitude coefficients. jamie@2: */ jamie@43: int xtract_magnitude_spectrum(const float *data, const int N, const void *argv, float *result); jamie@1: jamie@30: /** \brief Extract autocorrelation from time domain signal using FFT based method jamie@30: * jamie@30: * \param *data: a pointer to the first element in an array of floats representing an audio vector jamie@30: * \param N: the number of array elements to be considered jamie@30: * \param *argv: a pointer to NULL jamie@30: * \param *result: the autocorrelation of N values from the array pointed to by *data jamie@30: */ jamie@43: int xtract_autocorrelation_fft(const float *data, const int N, const void *argv, float *result); jamie@30: jamie@30: /** \brief Extract Mel Frequency Cepstral Coefficients based on a method described by Rabiner jamie@30: * jamie@47: * \param *data: a pointer to the first element in an array of floats representing an audio vector jamie@30: * \param N: the number of array elements to be considered jamie@30: * \param *argv: a pointer to a data structure of type xtract_mel_filter, containing n_filters coefficient tables to make up a mel-spaced filterbank jamie@30: * \param *result: a pointer to an array containing the resultant MFCC jamie@30: * jamie@30: * The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc jamie@30: */ jamie@43: int xtract_mfcc(const float *data, const int N, const void *argv, float *result); jamie@30: jamie@30: /** \brief Extract the Discrete Cosine transform of a time domain signal jamie@30: * \param *data: a pointer to the first element in an array of floats representing an audio vector jamie@30: * \param N: the number of array elements to be considered jamie@30: * \param *argv: a pointer to NULL jamie@30: * \param *result: a pointer to an array containing resultant dct coefficients jamie@30: */ jamie@43: int xtract_dct(const float *data, const int N, const void *argv, float *result); jamie@1: jamie@2: /** \brief Extract autocorrelation from time domain signal using time-domain autocorrelation technique jamie@2: * jamie@2: * \param *data: a pointer to the first element in an array of floats representing an audio vector jamie@2: * \param N: the number of array elements to be considered jamie@2: * \param *argv: a pointer to NULL jamie@2: * \param *result: the autocorrelation of N values from the array pointed to by *data jamie@2: */ jamie@43: int xtract_autocorrelation(const float *data, const int N, const void *argv, float *result); jamie@1: jamie@2: /** \brief Extract Average Magnitude Difference Function from time domain signal jamie@2: * jamie@47: * \param *data: a pointer to the first element in an array of floats representing an audio vector jamie@2: * \param N: the number of array elements to be considered jamie@2: * \param *argv: a pointer to NULL jamie@2: * \param *result: the AMDF of N values from the array pointed to by *data jamie@2: */ jamie@43: int xtract_amdf(const float *data, const int N, const void *argv, float *result); jamie@1: jamie@2: /** \brief Extract Average Squared Difference Function from time domain signal jamie@2: * jamie@2: * \param *data: a pointer to the first element in an array of floats representing an audio vector jamie@2: * \param N: the number of array elements to be considered jamie@2: * \param *argv: a pointer to NULL jamie@2: * \param *result: the ASDF of N values from the array pointed to by *data jamie@2: */ jamie@43: int xtract_asdf(const float *data, const int N, const void *argv, float *result); jamie@1: jamie@2: /** \brief Extract Bark band coefficients based on a method jamie@47: * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the magnitude spectrum of an audio vector, (e.g. the second half of the array pointed to by *result from xtract_magnitude_spectrum(). jamie@2: * \param N: the number of array elements to be considered jamie@42: * \param *argv: a pointer to an array of ints representing the limits of each bark band. This can be obtained by calling xtract_init_bark. jamie@2: * \param *result: a pointer to an array containing resultant bark coefficients jamie@2: * jamie@2: * The limits array pointed to by *argv must be obtained by first calling xtract_init_bark jamie@2: * jamie@2: */ jamie@43: int xtract_bark_coefficients(const float *data, const int N, const void *argv, float *result); jamie@1: jamie@38: /** \brief Extract the frequency and amplitude of spectral peaks from a magnitude spectrum jamie@47: * \param *data: a pointer to the first element in an array of floats representing the magnitude coefficients from the magnitude spectrum of an audio vector, (e.g. the second half of the array pointed to by *result from xtract_magnitude_spectrum(). jamie@2: * \param N: the number of array elements to be considered jamie@45: * \param *argv: a pointer to an array containing the peak threshold as percentage of the magnitude of the maximum peak found, and the sample rate in Hz. jamie@45: * \param *result: a pointer to an array of size N, containing N/2 freqs and N/2 amplitudes jamie@45: * jamie@2: */ jamie@45: jamie@43: int xtract_peaks(const float *data, const int N, const void *argv, float *result); jamie@20: jamie@38: /** \brief Extract the harmonic spectrum of from a of a peak spectrum jamie@38: * \param *data: a pointer to the first element in an array of floats 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 frequencies for each peak considered, and the the second half will contain the respective amplitudes jamie@38: * \param N: the size of the array pointed to by *data jamie@38: * \param *argv: a pointer to an array containing the fundamental (f0) of the spectrum, 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. jamie@45: * \param *result: a pointer to an array of size N containing N/2 freqs and N/2 amplitudes. jamie@38: */ jamie@43: int xtract_harmonics(const float *data, const int N, const void *argv, float *result); jamie@38: jamie@20: /** @} */ jamie@20: jamie@1: #ifdef __cplusplus jamie@1: } jamie@1: #endif jamie@1: jamie@1: #endif