annotate xtract/xtract_vector.h @ 95:432d97ee02ef

Minor modifications to MFCC init, mainly just code formatting
author Dan Stowell <danstowell@gmail.com>
date Wed, 03 Oct 2007 10:01:15 +0000
parents 5fadbacdb2a7
children ca40a0dc29d6
rev   line source
jamie@1 1 /* libxtract feature extraction library
jamie@1 2 *
jamie@1 3 * Copyright (C) 2006 Jamie Bullock
jamie@1 4 *
jamie@1 5 * This program is free software; you can redistribute it and/or modify
jamie@1 6 * it under the terms of the GNU General Public License as published by
jamie@1 7 * the Free Software Foundation; either version 2 of the License, or
jamie@1 8 * (at your option) any later version.
jamie@1 9 *
jamie@1 10 * This program is distributed in the hope that it will be useful,
jamie@1 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jamie@1 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
jamie@1 13 * GNU General Public License for more details.
jamie@1 14 *
jamie@1 15 * You should have received a copy of the GNU General Public License
jamie@1 16 * along with this program; if not, write to the Free Software
jamie@1 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
jamie@1 18 * USA.
jamie@1 19 */
jamie@1 20
jamie@1 21 /* xtract_scalar.h: declares functions that extract a feature as a vector from an input vector */
jamie@1 22
jamie@56 23 #ifndef XTRACT_VECTOR_H
jamie@56 24 #define XTRACT_VECTOR_H
jamie@1 25
jamie@1 26 #ifdef __cplusplus
jamie@1 27 extern "C" {
jamie@1 28 #endif
jamie@20 29
jamie@20 30 /**
jamie@83 31 * \defgroup vector vector extraction functions
jamie@20 32 *
jamie@83 33 * Defines vector extraction functions, and their parameters.
jamie@20 34 * @{
jamie@20 35 */
jamie@1 36
jamie@54 37 /** \brief Extract normalized (0-1) frequency domain spectrum from time domain signal
jamie@2 38 *
jamie@2 39 * \param *data: a pointer to the first element in an array of floats representing an audio vector
jamie@2 40 * \param N: the number of array elements to be considered
jamie@70 41 * \param *argv: a pointer to an array of floats, the first representing (samplerate / N), the second will be cast to an integer and determines the spectrum type (e.g. XTRACT_MAGNITUDE_SPECTRUM, XTRACT_LOG_POWER_SPECTRUM). An optional third argument determines whether or not the DC component is included in the output. If argv[2] == 1, then the DC component is included in which case the size of the array pointed to by *result must be N+2. For any further use of the array pointed to by *result, the value of N must reflect the (larger) array size.
jamie@54 42 * \param *result: a pointer to an array of size N containing N/2 magnitude/power/log magnitude/log power coefficients and N/2 bin frequencies.
jamie@2 43 */
jamie@54 44 int xtract_spectrum(const float *data, const int N, const void *argv, float *result);
jamie@1 45
jamie@30 46 /** \brief Extract autocorrelation from time domain signal using FFT based method
jamie@30 47 *
jamie@30 48 * \param *data: a pointer to the first element in an array of floats representing an audio vector
jamie@30 49 * \param N: the number of array elements to be considered
jamie@30 50 * \param *argv: a pointer to NULL
jamie@30 51 * \param *result: the autocorrelation of N values from the array pointed to by *data
jamie@30 52 */
jamie@43 53 int xtract_autocorrelation_fft(const float *data, const int N, const void *argv, float *result);
jamie@30 54
jamie@30 55 /** \brief Extract Mel Frequency Cepstral Coefficients based on a method described by Rabiner
jamie@30 56 *
jamie@72 57 * \param *data: a pointer to the first element in an array of spectral magnitudes, e.g. the first half of the array pointed to by *resul from xtract_spectrum()
jamie@30 58 * \param N: the number of array elements to be considered
jamie@30 59 * \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 60 * \param *result: a pointer to an array containing the resultant MFCC
jamie@30 61 *
jamie@30 62 * The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc
jamie@30 63 */
jamie@43 64 int xtract_mfcc(const float *data, const int N, const void *argv, float *result);
jamie@30 65
jamie@30 66 /** \brief Extract the Discrete Cosine transform of a time domain signal
jamie@30 67 * \param *data: a pointer to the first element in an array of floats representing an audio vector
jamie@30 68 * \param N: the number of array elements to be considered
jamie@30 69 * \param *argv: a pointer to NULL
jamie@30 70 * \param *result: a pointer to an array containing resultant dct coefficients
jamie@30 71 */
jamie@43 72 int xtract_dct(const float *data, const int N, const void *argv, float *result);
jamie@1 73
jamie@2 74 /** \brief Extract autocorrelation from time domain signal using time-domain autocorrelation technique
jamie@2 75 *
jamie@2 76 * \param *data: a pointer to the first element in an array of floats representing an audio vector
jamie@2 77 * \param N: the number of array elements to be considered
jamie@2 78 * \param *argv: a pointer to NULL
jamie@2 79 * \param *result: the autocorrelation of N values from the array pointed to by *data
jamie@2 80 */
jamie@43 81 int xtract_autocorrelation(const float *data, const int N, const void *argv, float *result);
jamie@1 82
jamie@2 83 /** \brief Extract Average Magnitude Difference Function from time domain signal
jamie@2 84 *
jamie@47 85 * \param *data: a pointer to the first element in an array of floats representing an audio vector
jamie@2 86 * \param N: the number of array elements to be considered
jamie@2 87 * \param *argv: a pointer to NULL
jamie@2 88 * \param *result: the AMDF of N values from the array pointed to by *data
jamie@2 89 */
jamie@43 90 int xtract_amdf(const float *data, const int N, const void *argv, float *result);
jamie@1 91
jamie@2 92 /** \brief Extract Average Squared Difference Function from time domain signal
jamie@2 93 *
jamie@2 94 * \param *data: a pointer to the first element in an array of floats representing an audio vector
jamie@2 95 * \param N: the number of array elements to be considered
jamie@2 96 * \param *argv: a pointer to NULL
jamie@2 97 * \param *result: the ASDF of N values from the array pointed to by *data
jamie@2 98 */
jamie@43 99 int xtract_asdf(const float *data, const int N, const void *argv, float *result);
jamie@1 100
jamie@2 101 /** \brief Extract Bark band coefficients based on a method
jamie@54 102 * \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 first half of the array pointed to by *result from xtract_spectrum().
jamie@2 103 * \param N: the number of array elements to be considered
jamie@42 104 * \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 105 * \param *result: a pointer to an array containing resultant bark coefficients
jamie@2 106 *
jamie@2 107 * The limits array pointed to by *argv must be obtained by first calling xtract_init_bark
jamie@2 108 *
jamie@2 109 */
jamie@43 110 int xtract_bark_coefficients(const float *data, const int N, const void *argv, float *result);
jamie@1 111
jamie@52 112 /** \brief Extract the amplitude and frequency of spectral peaks from a magnitude spectrum
jamie@59 113 * \param *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().
jamie@59 114 * \param N: the size of the input array (note: it is assumed that enough memory has been allocated for an output array twice the size)
jamie@55 115 * \param *argv: a pointer to an array of floats, the first representing (samplerate / N), the second representing the peak threshold as percentage of the magnitude of the maximum peak found
jamie@59 116 * \param *result: a pointer to an array of size N * 2 containing N magnitude/power/log magnitude/log power coefficients and N bin frequencies.
jamie@45 117 *
jamie@2 118 */
jamie@52 119 int xtract_peak_spectrum(const float *data, const int N, const void *argv, float *result);
jamie@20 120
jamie@38 121 /** \brief Extract the harmonic spectrum of from a of a peak spectrum
jamie@52 122 * \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 amplitudes for each peak considered, and the the second half will contain the respective frequencies
jamie@38 123 * \param N: the size of the array pointed to by *data
jamie@38 124 * \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@52 125 * \param *result: a pointer to an array of size N containing N/2 magnitude coefficients and N/2 bin frequencies.
jamie@38 126 */
jamie@52 127 int xtract_harmonic_spectrum(const float *data, const int N, const void *argv, float *result);
jamie@38 128
jamie@20 129 /** @} */
jamie@20 130
jamie@1 131 #ifdef __cplusplus
jamie@1 132 }
jamie@1 133 #endif
jamie@1 134
jamie@1 135 #endif