annotate include/xtract/xtract_scalar.h @ 285:89fe52066db1 tip master

MSCV missing ssize_t fix
author Jamie Bullock <jamie@jamiebullock.com>
date Tue, 16 Jul 2019 18:29:20 +0100
parents 39f1f8cf6756
children
rev   line source
jamie@254 1 /*
jamie@254 2 * Copyright (C) 2012 Jamie Bullock
jamie@254 3 *
jamie@254 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
jamie@254 5 * of this software and associated documentation files (the "Software"), to
jamie@254 6 * deal in the Software without restriction, including without limitation the
jamie@254 7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
jamie@254 8 * sell copies of the Software, and to permit persons to whom the Software is
jamie@254 9 * furnished to do so, subject to the following conditions:
jamie@254 10 *
jamie@254 11 * The above copyright notice and this permission notice shall be included in
jamie@254 12 * all copies or substantial portions of the Software.
jamie@254 13 *
jamie@254 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
jamie@254 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
jamie@254 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
jamie@254 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
jamie@254 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
jamie@254 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
jamie@254 20 * IN THE SOFTWARE.
jamie@254 21 *
jamie@254 22 */
jamie@254 23
jamie@254 24 /** \file xtract_scalar.h: declares functions that extract a feature as a single value from an input vector */
jamie@254 25
jamie@254 26 #ifndef XTRACT_SCALAR_H
jamie@254 27 #define XTRACT_SCALAR_H
jamie@254 28
jamie@254 29 #ifdef __cplusplus
jamie@254 30 extern "C" {
jamie@254 31 #endif
jamie@254 32
jamie@254 33 /**
jamie@254 34 * \defgroup scalar scalar extraction functions
jamie@254 35 *
jamie@254 36 * Functions that extract a feature as a single value from an input vector
jamie@254 37 *
jamie@254 38 * @{
jamie@254 39 */
jamie@254 40
jamie@254 41 /** \brief Extract the mean of an input vector
jamie@254 42 *
jamie@254 43 * \param *data: a pointer to the first element
jamie@254 44 * \param N: the number of array elements to be considered
jamie@254 45 * \param *argv: a pointer to NULL
jamie@254 46 * \param *result: the mean of N values from the array pointed to by *data
jamie@254 47 */
jamie@254 48 int xtract_mean(const double *data, const int N, const void *argv, double *result);
jamie@254 49
jamie@254 50 /** \brief Extract the variance of an input vector
jamie@254 51 *
jamie@254 52 * \param *data: a pointer to the first element in an array of doubles
jamie@254 53 * \param N: the number of elements to be considered
jamie@254 54 * \param *argv: a pointer to a double representing the mean of the input vector
jamie@254 55 * \param *result: the variance of N values from the array pointed to by *data
jamie@254 56 */
jamie@254 57 int xtract_variance(const double *data, const int N, const void *argv, double *result);
jamie@254 58
jamie@254 59 /** \brief Extract the deviation of an input vector
jamie@254 60 *
jamie@254 61 * \param *data: a pointer to the first element in an array of doubles
jamie@254 62 * \param N: the number of elements to be considered
jamie@254 63 * \param *argv: a pointer to a double representing the variance of the input vector
jamie@254 64 * \param *result: the deviation of N values from the array pointed to by *data
jamie@254 65 */
jamie@254 66 int xtract_standard_deviation(const double *data, const int N, const void *argv, double *result);
jamie@254 67
jamie@254 68 /** \brief Extract the average deviation of an input vector
jamie@254 69 *
jamie@254 70 * \param *data: a pointer to the first element in an array of doubles
jamie@254 71 * \param N: the number of elements to be considered
jamie@254 72 * \param *argv: a pointer to a double representing the mean of the input vector
jamie@254 73 * \param *result: the average deviation of N values from the array pointed to by *data
jamie@254 74 */
jamie@254 75 int xtract_average_deviation(const double *data, const int N, const void *argv, double *result);
jamie@254 76
jamie@254 77
jamie@254 78 /** \brief Extract the skewness of an input vector
jamie@254 79 *
jamie@254 80 * \param *data: a pointer to the first element in an array of doubles
jamie@254 81 * \param N: the number of elements to be considered
jamie@254 82 * \param *argv: a pointer to an array of doubles representing the mean and standard deviation of the input vector
jamie@254 83 * \param *result: the skewness of N values from the array pointed to by *data
jamie@254 84 */
jamie@254 85 int xtract_skewness(const double *data, const int N, const void *argv, double *result);
jamie@254 86
jamie@254 87 /** \brief Extract the kurtosis of an input vector
jamie@254 88 *
jamie@254 89 * \param *data: a pointer to the first element in an array of doubles
jamie@254 90 * \param N: the number of elements to be considered
jamie@254 91 * \param *argv: a pointer to an array of values representing the mean and standard deviation of the input vector
jamie@254 92 * \param *result: the kurtosis of N values from the array pointed to by *data
jamie@254 93 */
jamie@254 94 int xtract_kurtosis(const double *data, const int N, const void *argv, double *result);
jamie@254 95
jamie@254 96 /** \brief Extract the mean of an input spectrum
jamie@254 97 *
jamie@254 98 * \param *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()).
jamie@254 99 * \param N: the size of the array pointed to by *data
jamie@254 100 * \param *argv: a pointer to NULL
jamie@254 101 * \param *result: the mean of the spectrum pointed to by *data
jamie@254 102 */
jamie@254 103 int xtract_spectral_mean(const double *data, const int N, const void *argv, double *result);
jamie@254 104
jamie@254 105 /** \brief Extract the variance of an input spectrum
jamie@254 106 *
jamie@254 107 * \param *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()).
jamie@254 108 * \param N: the number of elements to be considered
jamie@254 109 * \param N: the size of the array pointed to by *data
jamie@254 110 * \param *argv: a pointer to a double representing the spectral mean of the input spectrum
jamie@254 111 * \param *result: the variance of the spectrum pointed to by *data
jamie@254 112 */
jamie@254 113 int xtract_spectral_variance(const double *data, const int N, const void *argv, double *result);
jamie@254 114
jamie@254 115 /** \brief Extract the deviation of an input spectrum
jamie@254 116 *
jamie@254 117 * \param *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()).
jamie@254 118 * \param N: the size of the array pointed to by *data
jamie@254 119 * \param *argv: a pointer to a double representing the spectral variance of the input spectrum
jamie@254 120 * \param *result: the deviation of the spectrum pointed to by *data
jamie@254 121 */
jamie@254 122 int xtract_spectral_standard_deviation(const double *data, const int N, const void *argv, double *result);
jamie@254 123
jamie@254 124 /** \brief Extract the average deviation of an input spectrum
jamie@254 125 *
jamie@254 126 * \param *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()).
jamie@254 127 * \param N: the size of the array pointed to by *data
jamie@254 128 * \param *argv: a pointer to a double representing the spectral mean of the input spectrum
jamie@254 129 * \param *result: the average deviation of the spectrum pointed to by *data
jamie@254 130 */
jamie@254 131 /*
jamie@254 132 int xtract_spectral_average_deviation(const double *data, const int N, const void *argv, double *result);
jamie@254 133 */
jamie@254 134
jamie@254 135 /** \brief Extract the skewness of an input spectrum
jamie@254 136 *
jamie@254 137 * \param *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()).
jamie@254 138 * \param N: the size of the array pointed to by *data
jamie@254 139 * \param *argv: a pointer to an array of doubles representing the spectral mean and spectral standard deviation of the input spectrum
jamie@254 140 * \param *result: the skewness of the spectrum pointed to by *data
jamie@254 141 */
jamie@254 142 int xtract_spectral_skewness(const double *data, const int N, const void *argv, double *result);
jamie@254 143
jamie@254 144 /** \brief Extract the kurtosis of an input spectrum
jamie@254 145 *
jamie@254 146 * \param *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()).
jamie@254 147 * \param N: the size of the array pointed to by *data
jamie@254 148 * \param *argv: a pointer to an array of values representing the spectral mean and spectral standard deviation of the input spectrum
jamie@254 149 * \param *result: the kurtosis of the spectrum pointed to by *data
jamie@254 150 */
jamie@254 151 int xtract_spectral_kurtosis(const double *data, const int N, const void *argv, double *result);
jamie@254 152
jamie@254 153 /** \brief Extract the centroid of an input vector
jamie@254 154 *
jamie@254 155 * \param *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()).
jamie@254 156 * \param N: the number of elements to be considered
jamie@254 157 * \param *argv: a pointer to NULL
jamie@254 158 * \param *result: the centroid of the values pointed to by *data
jamie@254 159 *
jamie@254 160 * Note: for a more 'accurate' result *result from xtract_peak_spectrum() can be passed in. This gives the interpolated peak frequency locations.
jamie@254 161 *
jamie@254 162 */
jamie@254 163 int xtract_spectral_centroid(const double *data, const int N, const void *argv, double *result);
jamie@254 164
jamie@254 165 /** \brief Calculate the Irregularity of an input vector using a method described by Krimphoff (1994)
jamie@254 166 *
jamie@254 167 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
jamie@254 168 * \param N: the number of elements to be considered
jamie@254 169 * \param *argv: a pointer to NULL
jamie@254 170 * \param *result: the irregularity of N values from the array pointed to by *data
jamie@254 171 */
jamie@254 172 int xtract_irregularity_k(const double *data, const int N, const void *argv, double *result);
jamie@254 173
jamie@254 174 /** \brief Calculate the Irregularity of an input vector using a method described by Jensen (1999)
jamie@254 175 *
jamie@254 176 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
jamie@254 177 * \param N: the number of elements to be considered
jamie@254 178 * \param *argv: a pointer to NULL
jamie@254 179 * \param *result: the irregularity of N values from the array pointed to by *data
jamie@254 180 */
jamie@254 181 int xtract_irregularity_j(const double *data, const int N, const void *argv, double *result);
jamie@254 182
jamie@254 183 /** \brief Calculate the Tristimulus of an input vector using a method described by Pollard and Jansson (1982)
jamie@254 184 *
jamie@254 185 * \param *data: a pointer to the first element in an array of doubles representing a harmonic spectrum of size N/2, and a frequency spectrum of size N/2 (This is the output format of xtract_harmonic_spectrum())
jamie@254 186 * \param N: the number of elements to be considered
jamie@254 187 * \param *argv: a pointer to a double representing the fundamental frequency of the input vector.
jamie@254 188 * \param *result: the tristimulus of N values from the array pointed to by *data
jamie@254 189 *
jamie@254 190 * These three functions provide the first, second and third order tristimulus formulae
jamie@254 191 *
jamie@254 192 */
jamie@254 193 int xtract_tristimulus_1(const double *data, const int N, const void *argv, double *result);
jamie@254 194 int xtract_tristimulus_2(const double *data, const int N, const void *argv, double *result);
jamie@254 195 int xtract_tristimulus_3(const double *data, const int N, const void *argv, double *result);
jamie@254 196
jamie@254 197 /** \brief Extract the smoothness of an input vector using a method described by McAdams (1999)
jamie@254 198 *
jamie@254 199 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
jamie@254 200 * \param N: the number of elements to be considered
jamie@254 201 * \param *argv: a pointer to NULL
jamie@254 202 * \param *result: the smoothness of N values from the array pointed to by *data
jamie@254 203 */
jamie@254 204 int xtract_smoothness(const double *data, const int N, const void *argv, double *result);
jamie@254 205
jamie@254 206 /** \brief Extract the spectral spread of an input vector using a method described by Casagrande(2005)
jamie@254 207 *
jamie@254 208 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
jamie@254 209 * \param N: the number of elements to be considered
jamie@254 210 * \param *argv: a pointer to a double corresponding to the spectral centroid
jamie@254 211 * \param *result: the spectral spread of N values from the array pointed to by *data
jamie@254 212 */
jamie@254 213 int xtract_spread(const double *data, const int N, const void *argv, double *result);
jamie@254 214
jamie@254 215 /* Zero crossing rate */
jamie@254 216
jamie@254 217 /** \brief Extract the zero crossing rate of an input vector
jamie@254 218 *
jamie@254 219 * \param *data: a pointer to the first element in an array of doubles
jamie@254 220 * \param N: the number of elements to be considered
jamie@254 221 * \param *argv: a pointer to NULL
jamie@254 222 * \param *result: the zero crossing rate of N values from the array pointed to by *data
jamie@254 223 */
jamie@254 224 int xtract_zcr(const double *data, const int N, const void *argv, double *result);
jamie@254 225
jamie@254 226 /** \brief Extract the spectral rolloff of an input vector using a method described by Bee Suan Ong (2005)
jamie@254 227 *
jamie@254 228 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
jamie@254 229 * \param N: the number of elements to be considered
jamie@254 230 * \param *argv: a pointer to an array containing a double representing (samplerate / N ) and a double representing the threshold for rolloff, i.e. the percentile at which the rolloff is determined, expressed as a percentage, and
jamie@254 231 * \param *result: the spectral rolloff in Hz of N values from the array pointed to by *data. This is the point in the spectrum below which argv[0] of the energy is distributed.
jamie@254 232 */
jamie@254 233 int xtract_rolloff(const double *data, const int N, const void *argv, double *result);
jamie@254 234
jamie@254 235 /** \brief Extract the 'total loudness' of an input vector using a method described by Moore, Glasberg et al (2005)
jamie@254 236 *
jamie@254 237 * \param *data: a pointer to the first element in an array of doubles representing a set of BARK_BANDS bark coefficients
jamie@254 238 * \param N: the number of coefficients to be considered
jamie@254 239 * \param *argv: a pointer to NULL
jamie@254 240 * \param *result: the total loudness of N values from the array pointed to by *data
jamie@254 241 *
jamie@254 242 * Note: if N = 1, the 'specific loudness' of the bark band pointed to by *data will be given by *result
jamie@254 243 *
jamie@254 244 */
jamie@254 245 int xtract_loudness(const double *data, const int N, const void *argv, double *result);
jamie@254 246
jamie@254 247 /** \brief Extract the spectral flatness measure of an input vector, where the flatness measure (SFM) is defined as the ratio of the geometric mean to the arithmetic mean of a magnitude spectrum.
jamie@254 248 *
jamie@254 249 * \note The computation method used here is the most efficient by a significant margin, but suffers from precision problems due to the multiplication operationin the geometric mean calculation. This is particularly accute for larger values of N (>=256). However, as noted by Peeters (2003), the SFM should generally be computed on a small number of 'bands' rather than on the complete magnitude spectrum. It is therefore highly recommended that xtract_bands() is used prior to calling xtract_flatness().
jamie@254 250 *
jamie@254 251 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum(). Alternatively the magnitudes from a number of 'subbands' can be used by using *result from xtract_bands().
jamie@254 252 * \param N: the number of *data array elements to be considered
jamie@254 253 * \param *argv: a pointer to NULL
jamie@254 254 * \param *result: the flatness of N values from the array pointed to by *data
jamie@254 255 */
jamie@254 256 int xtract_flatness(const double *data, const int N, const void *argv, double *result);
jamie@254 257
jamie@254 258 /** \brief Extract the LOG spectral flatness measure of an input vector
jamie@254 259 *
jamie@254 260 * \param *data: a pointer to NULL.
jamie@254 261 * \param N: not used - can safely be set to 0.
jamie@254 262 * \param *argv: a pointer to a double represnting spectral flatness.
jamie@254 263 * \param *result: the LOG spectral flatness of N values from the array pointed to by *data
jamie@254 264 *
jamie@254 265 * flatness_db = 10 * log10(flatness)
jamie@254 266 *
jamie@254 267 */
jamie@254 268 int xtract_flatness_db(const double *data, const int N, const void *argv, double *result);
jamie@254 269
jamie@254 270 /** \brief Extract the tonality factor of an input vector using a method described by Peeters 2003
jamie@254 271 *
jamie@254 272 * \param *data: a pointer to NULL.
jamie@254 273 * \param N: not used - can safely be set to 0.
jamie@254 274 * \param *argv: a pointer to the LOG spectral flatness measure of an audio vector (e.g. the output from xtract_flatness_db)
jamie@254 275 * \param *result: the tonality factor of N values from the array pointed to by *data
jamie@254 276 */
jamie@254 277 int xtract_tonality(const double *data, const int N, const void *argv, double *result);
jamie@254 278
jamie@254 279 /** \brief Extract the noisiness of an input vector using a method described by Tae Hong Park (2000)
jamie@254 280 *
jamie@254 281 * \param *data: a pointer to NULL
jamie@254 282 * \param N:
jamie@254 283 * \param *argv: a pointer to an array containing a double represnting the number of harmonic partials in a spectrum, and a double representing the number of partials in a spectrum
jamie@254 284 * \param *result: the noisiness coefficient as calculated from argv
jamie@254 285 */
jamie@254 286 int xtract_noisiness(const double *data, const int N, const void *argv, double *result);
jamie@254 287
jamie@254 288 /** \brief Extract the RMS amplitude of an input vector using a method described by Tae Hong Park (2000)
jamie@254 289 *
jamie@254 290 * \param *data: a pointer to the first element in an array of doubles
jamie@254 291 * \param N: the number of elements to be considered
jamie@254 292 * \param *argv: a pointer to NULL
jamie@254 293 * \param *result: the RMS amplitude of N values from the array pointed to by *data
jamie@254 294 */
jamie@254 295 int xtract_rms_amplitude(const double *data, const int N, const void *argv, double *result);
jamie@254 296
jamie@254 297 /** \brief Extract the Inharmonicity of an input vector
jamie@254 298 *
jamie@254 299 * \param *data: a pointer to the first element in an array of doubles represeting a magnitude peak spectrum of size N/2, and a frequency spectrum of size N/2 (This is the output format of xtract_peak_spectrum())
jamie@254 300 * \param N: the number of elements to be considered
jamie@254 301 * \param *argv: a pointer to a double representing the fundamental frequency of the input vector.
jamie@254 302 * \param *result: the inharmonicity of N values from the array pointed to by *data
jamie@254 303 */
jamie@254 304 int xtract_spectral_inharmonicity(const double *data, const int N, const void *argv, double *result);
jamie@254 305
jamie@254 306 /** \brief Extract the spectral crest of an input vector using a method described by Peeters (2003)
jamie@254 307 *
jamie@254 308 * \param *data: a pointer to NULL
jamie@254 309 * \param N: not used
jamie@254 310 * \param *argv: a pointer to an array containing a double representing the maximum value in a spectrum, and a double representing the mean value of a spectrum
jamie@254 311 * \param *result: the spectral crest of N values from the array pointed to by *data
jamie@254 312 */
jamie@254 313 int xtract_crest(const double *data, const int N, const void *argv, double *result);
jamie@254 314
jamie@254 315 /** \brief Extract the Spectral Power of an input vector using a method described by Bee Suan Ong (2005)
jamie@254 316 *
jamie@254 317 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
jamie@254 318 * \param N: the number of elements to be considered
jamie@254 319 * \param *argv: a pointer to NULL
jamie@254 320 * \param *result: the spectral power of N values from the array pointed to by *data
jamie@254 321 */
jamie@254 322 int xtract_power(const double *data, const int N, const void *argv, double *result);
jamie@254 323
jamie@254 324 /* Odd to even harmonic ratio */
jamie@254 325 /** \brief Extract the Odd to even harmonic ratio of an input vector
jamie@254 326 *
jamie@254 327 * \param *data: a pointer to the first element in an array of doubles representing a harmonic spectrum of size N/2, and a frequency spectrum of size N/2 (This is the output format of xtract_harmonic_spectrum())
jamie@254 328 * \param N: the number of elements to be considered.
jamie@254 329 * \param *argv: a pointer to a double representing the fundamental frequency of the input vector.
jamie@254 330 * \param *result: the even/odd harmonic ratio of N values from the array pointed to by *data
jamie@254 331 */
jamie@254 332 int xtract_odd_even_ratio(const double *data, const int N, const void *argv, double *result);
jamie@254 333
jamie@254 334 /** \brief Extract the Sharpness of an input vector
jamie@254 335 *
jamie@254 336 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients from the spectrum of an audio vector, (e.g. the first half of the array pointed to by *result from xtract_spectrum().
jamie@254 337 * \param N: the number of elements to be considered
jamie@254 338 * \param *argv: a pointer to NULL
jamie@254 339 * \param *result: the Sharpness of N values from the array pointed to by *data
jamie@254 340 */
jamie@254 341 int xtract_sharpness(const double *data, const int N, const void *argv, double *result);
jamie@254 342
jamie@254 343 /** \brief Extract the Slope of an input vector using a method described by Peeters(2003)
jamie@254 344 *
jamie@254 345 * \param *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()).
jamie@254 346 * \param N: the number of elements to be considered
jamie@254 347 * \param *argv: a pointer to NULL
jamie@254 348 * \param *result: the Slope of N values from the array pointed to by *data
jamie@254 349 */
jamie@254 350 int xtract_spectral_slope(const double *data, const int N, const void *argv, double *result);
jamie@254 351
jamie@254 352 /** \brief Extract the value of the lowest value in an input vector
jamie@254 353 *
jamie@254 354 * \param *data: a pointer to the first element in an array of doubles
jamie@254 355 * \param N: the number of elements to be considered
jamie@254 356 * \param *argv: a pointer to a double representing the lower limit for the search. All values in the array pointed to by *data that are below or equal to this threshold will be ignored.
jamie@254 357 * \param *result: a pointer to a value representing the lowest component in *data that falls above a given threshold.
jamie@254 358 *
jamie@254 359 * \return XTRACT_SUCCESS is a lowest value was found or XTRACT_NO_VALUE if all values
jamie@254 360 * in the array pointed to by *data are below or equal to the threshold set with *argv
jamie@254 361 *
jamie@254 362 * \note If XTRACT_NO_VALUE is returned, *result will be set to DBL_MAX
jamie@254 363 *
jamie@254 364 */
jamie@254 365 int xtract_lowest_value(const double *data, const int N, const void *argv, double *result);
jamie@254 366
jamie@254 367 /** \brief Extract the value of the highest value in an input vector
jamie@254 368 *
jamie@254 369 * \param *data: a pointer to the first element in an array of doubles
jamie@254 370 * \param N: the number of elements to be considered
jamie@254 371 * \param *argv: a pointer to NULL.
jamie@254 372 * \param *result: a pointer to a value representing the highest component in *data.
jamie@254 373 *
jamie@254 374 */
jamie@254 375 int xtract_highest_value(const double *data, const int N, const void *argv, double *result);
jamie@254 376
jamie@254 377 /** \brief Extract the sum of the values in an input vector
jamie@254 378 *
jamie@254 379 * \param *data: a pointer to the first element in an array of doubles
jamie@254 380 * \param N: the number of elements to be considered
jamie@254 381 * \param *argv: a pointer to NULL.
jamie@254 382 * \param *result: a pointer to a value representing the sum of all of the values pointed to by *data.
jamie@254 383 *
jamie@254 384 */
jamie@254 385 int xtract_sum(const double *data, const int N, const void *argv, double *result);
jamie@254 386
jamie@254 387 /** \brief Extract the Pitch of an input vector using Harmonic Product Spectrum (HPS) analysis
jamie@254 388 *
jamie@254 389 * \param *data: a pointer to the first element in an array of doubles representing the spectrum of an audio vector (e.g. *result from xtract_spectrum). It is expected that the first half of the array pointed to by *data will contain amplitudes for each frequecy bin, and the second half will contain the respective frequencies
jamie@254 390 * \param N: The length of the vector pointed to by *data.
jamie@254 391 * \param *argv: a pointer to NULL
jamie@254 392 * \param *result: the pitch of N values from the array pointed to by *data
jamie@254 393 */
jamie@254 394 int xtract_hps(const double *data, const int N, const void *argv, double *result);
jamie@254 395
jamie@254 396 /** \brief Extract the fundamental frequency of an input vector
jamie@254 397 *
jamie@254 398 * \param *data: a pointer to the first element in an array of doubles representing an audio vector
jamie@254 399 * \param N: the number of elements to be considered
jamie@254 400 * \param *argv: a pointer to a double representing the audio sample rate
jamie@254 401 * \param *result: the pitch of N values from the array pointed to by *data
jamie@254 402 *
jamie@254 403 * This algorithm is based on the AMDF, with peak and centre clipping. It would benefit from further improvements to improve noise robustness and overall efficiency
jamie@254 404 *
jamie@254 405 * It is based on suggestion by Robert Bristow-Johnson in a discussion on the comp.dsp mailing list, subject "Reference implementation of pitch detection"
jamie@254 406 *
jamie@254 407 */
jamie@254 408 int xtract_f0(const double *data, const int N, const void *argv, double *result);
jamie@254 409
jamie@254 410 /** \brief Extract the fundamental frequency of an input vector
jamie@254 411 *
jamie@254 412 * \param *data: a pointer to the first element in an array of doubles representing an audio vector
jamie@254 413 * \param N: the number of elements to be considered
jamie@254 414 * \param *argv: a pointer to a double representing the audio sample rate
jamie@254 415 * \param *result: the pitch of N values from the array pointed to by *data
jamie@254 416 *
jamie@254 417 * This function wraps xtract_f0, but provides the frequency of the lowest partial in the peak spectrum if f0 can't be found.
jamie@254 418 *
jamie@254 419 */
jamie@254 420 int xtract_failsafe_f0(const double *data, const int N, const void *argv, double *result);
jamie@254 421
jamie@254 422 /** \brief Extract the fundamental frequency of an input vector using wavelet-based method
jamie@254 423 *
jamie@254 424 * \param *data: a pointer to the first element in an array of doubles representing an audio vector
jamie@254 425 * \param N: the number of elements to be considered
jamie@254 426 * \param *argv: a pointer to a double representing the audio sample rate
jamie@254 427 * \param *result: the pitch of N values from the array pointed to by *data
jamie@254 428 *
jamie@254 429 * This function uses the time-domain wavelet-based method described in Larson and Maddox (2005) and
jamie@254 430 * implemented in the dywapitchtrack library
jamie@254 431 *
jamie@254 432 * xtract_init_wavelet_f0_state() must be called exactly once prior to calling xtract_wavelet_f0()
jamie@254 433 *
jamie@254 434 */
jamie@254 435 int xtract_wavelet_f0(const double *data, const int N, const void *argv, double *result);
jamie@254 436
jamie@254 437
jamie@254 438 /** \brief Convenience function to convert a frequency in Hertz to a "pitch" value in MIDI cents
jamie@254 439 *
jamie@254 440 * \param *data: not used
jamie@254 441 * \param N: not used
jamie@254 442 * \param *argv: a pointer to a double-precision floating point value representing a frequency in Hertz
jamie@254 443 * \param *result: a pointer to a double-precision floating point value representing a "pitch" in MIDI cents
jamie@254 444 * \return if *argv value causes a *result within the range 0..127, XTRACT_SUCCESS will be returned, otherwise XTRACT_ARGUMENT_ERROR
jamie@254 445 *
jamie@254 446 */
jamie@254 447 int xtract_midicent(const double *data, const int N, const void *argv, double *result);
jamie@254 448
jamie@254 449
jamie@254 450 /** \brief Extract the number of non-zero elements in an input vector
jamie@254 451 *
jamie@254 452 * \param *data: a pointer to the first element in an array of doubles
jamie@254 453 * \param N: the number of elements to be considered
jamie@254 454 * \param *argv: not used
jamie@254 455 * \param *result: the number of non-zero elements in the array pointed to by *data
jamie@254 456 *
jamie@254 457 */
jamie@254 458 int xtract_nonzero_count(const double *data, const int N, const void *argv, double *result);
jamie@254 459
jamie@254 460 /**
jamie@254 461 * \brief Return XTRACT_SUCCESS if the 'current' value is considered a peak
jamie@254 462 *
jamie@254 463 * @param data a pointer to an array containing time series as provided by *result from xtract_last_n() where the Nth value is considered the 'current' value
jamie@254 464 * @param N an integer representing the number of elements in the time series
jamie@254 465 * @param argv a pointer to a double representing the threshold, whereby the current value will be considered a peak if it is above the average of the last N values (*data) by the threshold
jamie@254 466 * @param result a pointer to a copy of the current value if the current value is considered a peak
jamie@254 467 *
jamie@254 468 *
jamie@254 469 * @return XTRACT_SUCCESS if a peak was found or XTRACT_NO_RESULT if not
jamie@254 470 */
jamie@254 471 int xtract_peak(const double *data, const int N, const void *argv, double *result);
jamie@254 472
jamie@254 473
jamie@254 474 /** @} */
jamie@254 475
jamie@254 476 #ifdef __cplusplus
jamie@254 477 }
jamie@254 478 #endif
jamie@254 479
jamie@254 480 #endif
jamie@254 481
jamie@254 482
jamie@254 483