annotate xtract/xtract_scalar.h @ 11:81eb5810a301

Added spectral centroid
author Jamie Bullock <jamie@postlude.co.uk>
date Sun, 08 Oct 2006 15:31:40 +0000
parents cac976b2a69d
children 1aec087ddfca
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@2 21 /** \file xtract_scalar.h: declares functions that extract a feature as a single value from an input vector */
jamie@1 22
jamie@1 23 #ifndef XTRACT_SCALAR
jamie@1 24 #define XTRACT_SCALAR
jamie@1 25
jamie@1 26 #ifdef __cplusplus
jamie@1 27 extern "C" {
jamie@1 28 #endif
jamie@1 29
jamie@1 30
jamie@2 31 /** \brief Extract the mean of an input vector
jamie@2 32 *
jamie@2 33 * \param *data: a pointer to the first element in an array of floats
jamie@2 34 * \param N: the number of array elements to be considered
jamie@2 35 * \param *argv: a pointer to NULL
jamie@2 36 * \param *result: the mean of N values from the array pointed to by *data
jamie@2 37 */
jamie@2 38 int xtract_mean(float *data, int N, void *argv, float *result);
jamie@1 39
jamie@2 40 /** \brief Extract the variance of an input vector
jamie@2 41 *
jamie@2 42 * \param *data: a pointer to the first element in an array of floats
jamie@2 43 * \param N: the number of elements to be considered
jamie@2 44 * \param *argv: a pointer to a value representing the mean of the input vector
jamie@2 45 * \param *result: the variance of N values from the array pointed to by *data
jamie@2 46 */
jamie@1 47 int xtract_variance(float *data, int N, void *argv, float *result);
jamie@2 48
jamie@2 49 /** \brief Extract the deviation of an input vector
jamie@2 50 *
jamie@2 51 * \param *data: a pointer to the first element in an array of floats
jamie@2 52 * \param N: the number of elements to be considered
jamie@2 53 * \param *argv: a pointer to a value representing the variance of the input vector
jamie@2 54 * \param *result: the deviation of N values from the array pointed to by *data
jamie@2 55 */
jamie@1 56 int xtract_standard_deviation(float *data, int N, void *argv, float *result);
jamie@2 57
jamie@2 58 /** \brief Extract the average deviation of an input vector
jamie@2 59 *
jamie@2 60 * \param *data: a pointer to the first element in an array of floats
jamie@2 61 * \param N: the number of elements to be considered
jamie@2 62 * \param *argv: a pointer to a value representing the mean of the input vector
jamie@2 63 * \param *result: the average deviation of N values from the array pointed to by *data
jamie@2 64 */
jamie@1 65 int xtract_average_deviation(float *data, int N, void *argv, float *result);
jamie@2 66
jamie@2 67 /** \brief Extract the skewness of an input vector
jamie@2 68 *
jamie@2 69 * \param *data: a pointer to the first element in an array of floats
jamie@2 70 * \param N: the number of elements to be considered
jamie@2 71 * \param *argv: a pointer to an array of values representing the mean and standard deviation of the input vector
jamie@2 72 * \param *result: the skewness of N values from the array pointed to by *data
jamie@2 73 */
jamie@1 74 int xtract_skewness(float *data, int N, void *argv, float *result);
jamie@2 75
jamie@2 76 /** \brief Extract the kurtosis of an input vector
jamie@2 77 *
jamie@2 78 * \param *data: a pointer to the first element in an array of floats
jamie@2 79 * \param N: the number of elements to be considered
jamie@2 80 * \param *argv: a pointer to an array of values representing the mean and standard deviation of the input vector
jamie@2 81 * \param *result: the kurtosis of N values from the array pointed to by *data
jamie@2 82 */
jamie@1 83 int xtract_kurtosis(float *data, int N, void *argv, float *result);
jamie@1 84
jamie@11 85 /** \brief Extract the kurtosis of an input vector
jamie@11 86 *
jamie@11 87 * \param *data: a pointer to the first element in an array of floats represeting a frequency spectrum of size N/2 and a magnitude peak spectrum of size N/2 (This is the output format of xtract_peaks)
jamie@11 88 * \param N: the number of elements to be considered
jamie@11 89 * \param *argv: a pointer to NULL
jamie@11 90 * \param *result: the centroid of the values pointed to by *data
jamie@11 91 */
jamie@11 92 int xtract_centroid(float *data, int N, void *argv, float *result);
jamie@11 93
jamie@2 94 /** \brief Calculate the Irregularity of an input vector using a method described by Krimphoff (1994)
jamie@2 95 *
jamie@2 96 * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector
jamie@2 97 * \param N: the number of elements to be considered
jamie@2 98 * \param *argv: a pointer to NULL
jamie@2 99 * \param *result: the irregularity of N values from the array pointed to by *data
jamie@2 100 */
jamie@2 101 int xtract_irregularity_k(float *data, int N, void *argv, float *result);
jamie@1 102
jamie@2 103 /** \brief Calculate the Irregularity of an input vector using a method described by Jensen (1999)
jamie@2 104 *
jamie@2 105 * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector
jamie@2 106 * \param N: the number of elements to be considered
jamie@2 107 * \param *argv: a pointer to NULL
jamie@2 108 * \param *result: the irregularity of N values from the array pointed to by *data
jamie@2 109 */
jamie@1 110 int xtract_irregularity_j(float *data, int N, void *argv, float *result);
jamie@1 111
jamie@2 112 /** \brief Calculate the Tristimulus of an input vector using a method described by Pollard and Jansson (1982)
jamie@2 113 *
jamie@2 114 * \param *data: a pointer to the first element in an array of floats representing the amplitudes of the harmonic spectrum of an audio vector
jamie@2 115 * \param N: the number of elements to be considered
jamie@2 116 * \param *argv: a pointer to NULL
jamie@2 117 * \param *result: the tristimulus of N values from the array pointed to by *data
jamie@2 118 *
jamie@2 119 * These three functions provide the first, second and third order tristimulus formulae
jamie@2 120 *
jamie@2 121 */
jamie@1 122 int xtract_tristimulus_1(float *data, int N, void *argv, float *result);
jamie@1 123 int xtract_tristimulus_2(float *data, int N, void *argv, float *result);
jamie@1 124 int xtract_tristimulus_3(float *data, int N, void *argv, float *result);
jamie@1 125
jamie@2 126 /** \brief Extract the smoothness of an input vector using a method described by McAdams (1999)
jamie@2 127 *
jamie@2 128 * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector
jamie@2 129 * \param N: the number of elements to be considered
jamie@2 130 * \param *argv: a pointer to NULL
jamie@2 131 * \param *result: the smoothness of N values from the array pointed to by *data
jamie@2 132 */
jamie@1 133 int xtract_smoothness(float *data, int N, void *argv, float *result);
jamie@1 134
jamie@2 135 /** \brief Extract the spectral spread of an input vector using a method described by Casagrande(2005)
jamie@2 136 *
jamie@2 137 * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector
jamie@2 138 * \param N: the number of elements to be considered
jamie@2 139 * \param *argv: a pointer to NULL
jamie@2 140 * \param *result: the spectral spread of N values from the array pointed to by *data
jamie@2 141 */
jamie@1 142 int xtract_spread(float *data, int N, void *argv, float *result);
jamie@1 143
jamie@1 144 /* Zero crossing rate */
jamie@1 145
jamie@2 146 /** \brief Extract the zero crossing rate of an input vector
jamie@2 147 *
jamie@2 148 * \param *data: a pointer to the first element in an array of floats
jamie@2 149 * \param N: the number of elements to be considered
jamie@2 150 * \param *argv: a pointer to NULL
jamie@2 151 * \param *result: the zero crossing rate of N values from the array pointed to by *data
jamie@2 152 */
jamie@1 153 int xtract_zcr(float *data, int N, void *argv, float *result);
jamie@1 154
jamie@2 155 /** \brief Extract the spectral rolloff of an input vector using a method described by Bee Suan Ong (2005)
jamie@2 156 *
jamie@2 157 * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector
jamie@2 158 * \param N: the number of elements to be considered
jamie@2 159 * \param *argv: a pointer to a floating point value representing the threshold for rolloff, i.e. the percentile at which the rolloff is determined
jamie@2 160 * \param *result: the spectral rolloff of N values from the array pointed to by *data
jamie@2 161 */
jamie@1 162 int xtract_rolloff(float *data, int N, void *argv, float *result);
jamie@1 163
jamie@1 164 /* Loudness */
jamie@1 165 /* A set of BARK_BANDS bark coefficients must be passed in, the loudness is calculated approximately according to Moore, Glasberg et al, 1997 */
jamie@1 166
jamie@2 167 /** \brief Extract the loudness of an input vector using a method described by Moore, Glasberg et al (2005)
jamie@2 168 *
jamie@2 169 * \param *data: a pointer to the first element in an array of floats representing a set of BARK_BANDS bark coefficients
jamie@2 170 * \param N: the number of coefficients to be considered
jamie@2 171 * \param *argv: a pointer to NULL
jamie@2 172 * \param *result: the loudness of N values from the array pointed to by *data
jamie@2 173 */
jamie@1 174 int xtract_loudness(float *data, int N, void *argv, float *result);
jamie@1 175
jamie@2 176 /** \brief Extract the spectral flatness measure of an input vector using a method described by Tristan Jehan (2005)
jamie@2 177 *
jamie@2 178 * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector
jamie@2 179 * \param N: the number of elements to be considered
jamie@2 180 * \param *argv: a pointer to NULL
jamie@2 181 * \param *result: the spectral flatness of N values from the array pointed to by *data
jamie@2 182 */
jamie@1 183 int xtract_flatness(float *data, int N, void *argv, float *result);
jamie@1 184
jamie@1 185
jamie@2 186 /** \brief Extract the tonality factor of an input vector using a method described by Tristan Jehan (2005)
jamie@2 187 *
jamie@2 188 * \param *data: a pointer to the first element in an array of floats representing the spectral peaks of an audio vector
jamie@2 189 * \param N: the number of elements to be considered
jamie@2 190 * \param *argv: a pointer to NULL
jamie@2 191 * \param *result: the tonality factor of N values from the array pointed to by *data
jamie@2 192 */
jamie@1 193 int xtract_tonality(float *data, int N, void *argv, float *result);
jamie@1 194
jamie@2 195 /** \brief Extract the noisiness of an input vector using a method described by Tae Hong Park (2000)
jamie@2 196 *
jamie@2 197 * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector
jamie@2 198 * \param N: the number of elements to be considered
jamie@2 199 * \param *argv: a pointer to NULL
jamie@2 200 * \param *result: the noisiness of N values from the array pointed to by *data
jamie@2 201 */
jamie@1 202 int xtract_noisiness(float *data, int N, void *argv, float *result);
jamie@1 203
jamie@2 204 /** \brief Extract the RMS amplitude of an input vector using a method described by Tae Hong Park (2000)
jamie@2 205 *
jamie@2 206 * \param *data: a pointer to the first element in an array of floats
jamie@2 207 * \param N: the number of elements to be considered
jamie@2 208 * \param *argv: a pointer to NULL
jamie@2 209 * \param *result: the RMS amplitude of N values from the array pointed to by *data
jamie@2 210 */
jamie@1 211 int xtract_rms_amplitude(float *data, int N, void *argv, float *result);
jamie@1 212
jamie@2 213 /** \brief Extract the Inharmonicity of an input vector
jamie@2 214 *
jamie@2 215 * \param *data: a pointer to the first element in an array of floats representing the amplitudes of the spectral peaks in an audio vector
jamie@2 216 * \param N: the number of elements to be considered
jamie@2 217 * \param *argv: a pointer to a multidimensional array containing the fundamental frequency of the input vector in the first element of the first dimension, and the frequencies of the spectral peaks in the second dimension
jamie@2 218 * \param *result: the inharmonicity of N values from the array pointed to by *data
jamie@2 219 */
jamie@1 220 int xtract_inharmonicity(float *data, int N, void *argv, float *result);
jamie@1 221
jamie@2 222 /** \brief Extract the spectral crest of an input vector using a method described by Peeters (2003)
jamie@2 223 *
jamie@2 224 * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector
jamie@2 225 * \param N: the number of elements to be considered
jamie@2 226 * \param *argv: a pointer to NULL
jamie@2 227 * \param *result: the spectral crest of N values from the array pointed to by *data
jamie@2 228 */
jamie@1 229 int xtract_crest(float *data, int N, void *argv, float *result);
jamie@1 230
jamie@2 231 /** \brief Extract the Spectral Power of an input vector using a method described by Bee Suan Ong (2005)
jamie@2 232 *
jamie@2 233 * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector
jamie@2 234 * \param N: the number of elements to be considered
jamie@2 235 * \param *argv: a pointer to NULL
jamie@2 236 * \param *result: the spectral power of N values from the array pointed to by *data
jamie@2 237 */
jamie@1 238 int xtract_power(float *data, int N, void *argv, float *result);
jamie@1 239
jamie@1 240 /* Odd to even harmonic ratio */
jamie@2 241 /** \brief Extract the Odd to even harmonic ratio of an input vector
jamie@2 242 *
jamie@2 243 * \param *data: a pointer to the first element in an array of floats representing the harmonic spectrum of an audio vector
jamie@2 244 * \param N: the number of elements to be considered
jamie@2 245 * \param *argv: a pointer to NULL
jamie@2 246 * \param *result: the odd/even harmonic ratio of N values from the array pointed to by *data
jamie@2 247 */
jamie@1 248 int xtract_odd_even_ratio(float *data, int N, void *argv, float *result);
jamie@1 249
jamie@2 250 /** \brief Extract the Sharpness of an input vector
jamie@2 251 *
jamie@2 252 * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector
jamie@2 253 * \param N: the number of elements to be considered
jamie@2 254 * \param *argv: a pointer to NULL
jamie@2 255 * \param *result: the Sharpness of N values from the array pointed to by *data
jamie@2 256 */
jamie@1 257 int xtract_sharpness(float *data, int N, void *argv, float *result);
jamie@1 258
jamie@2 259 /** \brief Extract the Slope of an input vector
jamie@2 260 *
jamie@2 261 * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector
jamie@2 262 * \param N: the number of elements to be considered
jamie@2 263 * \param *argv: a pointer to NULL
jamie@2 264 * \param *result: the Slope of N values from the array pointed to by *data
jamie@2 265 */
jamie@1 266 int xtract_slope(float *data, int N, void *argv, float *result);
jamie@1 267
jamie@5 268 /** \brief Extract the value of the first partial in an input vector that closely matches a certain 'guess'
jamie@2 269 *
jamie@2 270 * \param *data: a pointer to the first element in an array of floats that represents the frequencies of the spectral peaks of an audio vector
jamie@2 271 * \param N: the number of elements to be considered
jamie@5 272 * \param *argv: a pointer to a float value representing the guess
jamie@2 273 * \param *result: the F0 of N values from the array pointed to by *data
jamie@2 274 *
jamie@2 275 * This method takes a guess which can come from taking the ZCR of an autocorrelation function, and then finds the spectral peak that most closely matches the gess */
jamie@5 276 int xtract_lowest_match(float *data, int N, void *argv, float *result);
jamie@1 277
jamie@2 278 /** \brief Extract the Pitch of an input vector using Harmonic Product Spectrum (HPS) analysis
jamie@2 279 *
jamie@2 280 * \param *data: a pointer to the first element in an array of floats representing the magnitude spectrum of an audio vector
jamie@2 281 * \param N: the number of elements to be considered
jamie@2 282 * \param *argv: a pointer to NULL
jamie@2 283 * \param *result: the pitch of N values from the array pointed to by *data
jamie@2 284 */
jamie@1 285 int xtract_hps(float *data, int N, void *argv, float *result);
jamie@1 286
jamie@5 287 /** \brief Extract the fundamental frequency of an input vector
jamie@5 288 *
jamie@5 289 * \param *data: a pointer to the first element in an array of floats representing an audio vector
jamie@5 290 * \param N: the number of elements to be considered
jamie@5 291 * \param *argv: a pointer to NULL
jamie@5 292 * \param *result: the pitch of N values from the array pointed to by *data
jamie@5 293 */
jamie@5 294 int xtract_f0(float *data, int N, void *argv, float *result);
jamie@5 295
jamie@1 296 #ifdef __cplusplus
jamie@1 297 }
jamie@1 298 #endif
jamie@1 299
jamie@1 300 #endif
jamie@1 301
jamie@1 302
jamie@1 303