annotate xtract/xtract_scalar.h @ 146:baaa9d8b4d10

switched from single to double precision througout. closes #9
author Jamie Bullock <jamie@jamiebullock.com>
date Wed, 09 Jan 2013 12:45:29 +0000
parents e4f704649c50
children 9283aaf1ffb8
rev   line source
jamie@141 1 /*
jamie@141 2 * Copyright (C) 2012 Jamie Bullock
jamie@1 3 *
jamie@141 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
jamie@141 5 * of this software and associated documentation files (the "Software"), to
jamie@141 6 * deal in the Software without restriction, including without limitation the
jamie@141 7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
jamie@141 8 * sell copies of the Software, and to permit persons to whom the Software is
jamie@141 9 * furnished to do so, subject to the following conditions:
jamie@1 10 *
jamie@141 11 * The above copyright notice and this permission notice shall be included in
jamie@141 12 * all copies or substantial portions of the Software.
jamie@1 13 *
jamie@141 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
jamie@141 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
jamie@141 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
jamie@141 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
jamie@141 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
jamie@141 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
jamie@141 20 * IN THE SOFTWARE.
jamie@141 21 *
jamie@1 22 */
jamie@1 23
jamie@2 24 /** \file xtract_scalar.h: declares functions that extract a feature as a single value from an input vector */
jamie@1 25
jamie@56 26 #ifndef XTRACT_SCALAR_H
jamie@56 27 #define XTRACT_SCALAR_H
jamie@1 28
jamie@1 29 #ifdef __cplusplus
jamie@1 30 extern "C" {
jamie@1 31 #endif
jamie@1 32
jamie@20 33 /**
jamie@83 34 * \defgroup scalar scalar extraction functions
jamie@116 35 *
jamie@116 36 * Functions that extract a feature as a single value from an input vector
jamie@20 37 *
jamie@20 38 * @{
jamie@20 39 */
jamie@1 40
jamie@92 41 void test(void);
jamie@92 42
jamie@2 43 /** \brief Extract the mean of an input vector
jamie@2 44 *
jamie@52 45 * \param *data: a pointer to the first element
jamie@2 46 * \param N: the number of array elements to be considered
jamie@2 47 * \param *argv: a pointer to NULL
jamie@2 48 * \param *result: the mean of N values from the array pointed to by *data
jamie@2 49 */
jamie@146 50 int xtract_mean(const double *data, const int N, const void *argv, double *result);
jamie@1 51
jamie@2 52 /** \brief Extract the variance of an input vector
jamie@2 53 *
jamie@146 54 * \param *data: a pointer to the first element in an array of doubles
jamie@2 55 * \param N: the number of elements to be considered
jamie@146 56 * \param *argv: a pointer to a double representing the mean of the input vector
jamie@2 57 * \param *result: the variance of N values from the array pointed to by *data
jamie@2 58 */
jamie@146 59 int xtract_variance(const double *data, const int N, const void *argv, double *result);
jamie@2 60
jamie@2 61 /** \brief Extract the deviation of an input vector
jamie@2 62 *
jamie@146 63 * \param *data: a pointer to the first element in an array of doubles
jamie@2 64 * \param N: the number of elements to be considered
jamie@146 65 * \param *argv: a pointer to a double representing the variance of the input vector
jamie@2 66 * \param *result: the deviation of N values from the array pointed to by *data
jamie@2 67 */
jamie@146 68 int xtract_standard_deviation(const double *data, const int N, const void *argv, double *result);
jamie@2 69
jamie@2 70 /** \brief Extract the average deviation of an input vector
jamie@2 71 *
jamie@146 72 * \param *data: a pointer to the first element in an array of doubles
jamie@2 73 * \param N: the number of elements to be considered
jamie@146 74 * \param *argv: a pointer to a double representing the mean of the input vector
jamie@2 75 * \param *result: the average deviation of N values from the array pointed to by *data
jamie@2 76 */
jamie@146 77 int xtract_average_deviation(const double *data, const int N, const void *argv, double *result);
jamie@125 78
jamie@2 79
jamie@2 80 /** \brief Extract the skewness of an input vector
jamie@2 81 *
jamie@146 82 * \param *data: a pointer to the first element in an array of doubles
jamie@2 83 * \param N: the number of elements to be considered
jamie@146 84 * \param *argv: a pointer to an array of doubles representing the mean and standard deviation of the input vector
jamie@2 85 * \param *result: the skewness of N values from the array pointed to by *data
jamie@2 86 */
jamie@146 87 int xtract_skewness(const double *data, const int N, const void *argv, double *result);
jamie@2 88
jamie@2 89 /** \brief Extract the kurtosis of an input vector
jamie@2 90 *
jamie@146 91 * \param *data: a pointer to the first element in an array of doubles
jamie@2 92 * \param N: the number of elements to be considered
jamie@2 93 * \param *argv: a pointer to an array of values representing the mean and standard deviation of the input vector
jamie@2 94 * \param *result: the kurtosis of N values from the array pointed to by *data
jamie@2 95 */
jamie@146 96 int xtract_kurtosis(const double *data, const int N, const void *argv, double *result);
jamie@1 97
jamie@52 98 /** \brief Extract the mean of an input spectrum
jamie@52 99 *
jamie@146 100 * \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@52 101 * \param N: the size of the array pointed to by *data
jamie@52 102 * \param *argv: a pointer to NULL
jamie@52 103 * \param *result: the mean of the spectrum pointed to by *data
jamie@52 104 */
jamie@146 105 int xtract_spectral_mean(const double *data, const int N, const void *argv, double *result);
jamie@52 106
jamie@52 107 /** \brief Extract the variance of an input spectrum
jamie@52 108 *
jamie@146 109 * \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@52 110 * \param N: the number of elements to be considered
jamie@52 111 * \param N: the size of the array pointed to by *data
jamie@146 112 * \param *argv: a pointer to a double representing the spectral mean of the input spectrum
jamie@52 113 * \param *result: the variance of the spectrum pointed to by *data
jamie@52 114 */
jamie@146 115 int xtract_spectral_variance(const double *data, const int N, const void *argv, double *result);
jamie@52 116
jamie@52 117 /** \brief Extract the deviation of an input spectrum
jamie@52 118 *
jamie@146 119 * \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@52 120 * \param N: the size of the array pointed to by *data
jamie@146 121 * \param *argv: a pointer to a double representing the spectral variance of the input spectrum
jamie@52 122 * \param *result: the deviation of the spectrum pointed to by *data
jamie@52 123 */
jamie@146 124 int xtract_spectral_standard_deviation(const double *data, const int N, const void *argv, double *result);
jamie@52 125
jamie@52 126 /** \brief Extract the average deviation of an input spectrum
jamie@52 127 *
jamie@146 128 * \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@52 129 * \param N: the size of the array pointed to by *data
jamie@146 130 * \param *argv: a pointer to a double representing the spectral mean of the input spectrum
jamie@52 131 * \param *result: the average deviation of the spectrum pointed to by *data
jamie@52 132 */
jamie@125 133 /*
jamie@146 134 int xtract_spectral_average_deviation(const double *data, const int N, const void *argv, double *result);
jamie@125 135 */
jamie@52 136
jamie@52 137 /** \brief Extract the skewness of an input spectrum
jamie@52 138 *
jamie@146 139 * \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@52 140 * \param N: the size of the array pointed to by *data
jamie@146 141 * \param *argv: a pointer to an array of doubles representing the spectral mean and spectral standard deviation of the input spectrum
jamie@52 142 * \param *result: the skewness of the spectrum pointed to by *data
jamie@52 143 */
jamie@146 144 int xtract_spectral_skewness(const double *data, const int N, const void *argv, double *result);
jamie@52 145
jamie@52 146 /** \brief Extract the kurtosis of an input spectrum
jamie@52 147 *
jamie@146 148 * \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@52 149 * \param N: the size of the array pointed to by *data
jamie@59 150 * \param *argv: a pointer to an array of values representing the spectral mean and spectral standard deviation of the input spectrum
jamie@52 151 * \param *result: the kurtosis of the spectrum pointed to by *data
jamie@52 152 */
jamie@146 153 int xtract_spectral_kurtosis(const double *data, const int N, const void *argv, double *result);
jamie@52 154
jamie@41 155 /** \brief Extract the centroid of an input vector
jamie@11 156 *
jamie@146 157 * \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@11 158 * \param N: the number of elements to be considered
jamie@11 159 * \param *argv: a pointer to NULL
jamie@11 160 * \param *result: the centroid of the values pointed to by *data
jamie@47 161 *
jamie@78 162 * Note: for a more 'accurate' result *result from xtract_peak_spectrum() can be passed in. This gives the interpolated peak frequency locations.
jamie@47 163 *
jamie@11 164 */
jamie@146 165 int xtract_spectral_centroid(const double *data, const int N, const void *argv, double *result);
jamie@11 166
jamie@2 167 /** \brief Calculate the Irregularity of an input vector using a method described by Krimphoff (1994)
jamie@2 168 *
jamie@146 169 * \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@2 170 * \param N: the number of elements to be considered
jamie@2 171 * \param *argv: a pointer to NULL
jamie@2 172 * \param *result: the irregularity of N values from the array pointed to by *data
jamie@2 173 */
jamie@146 174 int xtract_irregularity_k(const double *data, const int N, const void *argv, double *result);
jamie@1 175
jamie@2 176 /** \brief Calculate the Irregularity of an input vector using a method described by Jensen (1999)
jamie@2 177 *
jamie@146 178 * \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@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 irregularity of N values from the array pointed to by *data
jamie@2 182 */
jamie@146 183 int xtract_irregularity_j(const double *data, const int N, const void *argv, double *result);
jamie@1 184
jamie@2 185 /** \brief Calculate the Tristimulus of an input vector using a method described by Pollard and Jansson (1982)
jamie@2 186 *
jamie@146 187 * \param *data: a pointer to the first element in an array of doubles representing the magnitude coefficients of the harmonic spectrum of an audio vector e.g. a pointer to the first half of the array pointed to by *result from xtract_harmonics(). The amplitudes of the peak spectrum (e.g. *result from xtract_peak_spectrum()) can be used if one wishes to consider all partials not just harmonics.
jamie@2 188 * \param N: the number of elements to be considered
jamie@2 189 * \param *argv: a pointer to NULL
jamie@2 190 * \param *result: the tristimulus of N values from the array pointed to by *data
jamie@2 191 *
jamie@2 192 * These three functions provide the first, second and third order tristimulus formulae
jamie@2 193 *
jamie@2 194 */
jamie@146 195 int xtract_tristimulus_1(const double *data, const int N, const void *argv, double *result);
jamie@146 196 int xtract_tristimulus_2(const double *data, const int N, const void *argv, double *result);
jamie@146 197 int xtract_tristimulus_3(const double *data, const int N, const void *argv, double *result);
jamie@1 198
jamie@2 199 /** \brief Extract the smoothness of an input vector using a method described by McAdams (1999)
jamie@2 200 *
jamie@146 201 * \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@2 202 * \param N: the number of elements to be considered
jamie@43 203 * \param *argv: a pointer to the first element of an array of integers containing the lower bound, upper bound, and pre-scaling factor, whereby array data in the range lower < n < upper will be pre-scaled by p before processing.
jamie@2 204 * \param *result: the smoothness of N values from the array pointed to by *data
jamie@2 205 */
jamie@146 206 int xtract_smoothness(const double *data, const int N, const void *argv, double *result);
jamie@1 207
jamie@2 208 /** \brief Extract the spectral spread of an input vector using a method described by Casagrande(2005)
jamie@2 209 *
jamie@146 210 * \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@2 211 * \param N: the number of elements to be considered
jamie@146 212 * \param *argv: a pointer to a double corresponding to the spectral centroid
jamie@2 213 * \param *result: the spectral spread of N values from the array pointed to by *data
jamie@2 214 */
jamie@146 215 int xtract_spread(const double *data, const int N, const void *argv, double *result);
jamie@1 216
jamie@1 217 /* Zero crossing rate */
jamie@1 218
jamie@2 219 /** \brief Extract the zero crossing rate of an input vector
jamie@2 220 *
jamie@146 221 * \param *data: a pointer to the first element in an array of doubles
jamie@2 222 * \param N: the number of elements to be considered
jamie@2 223 * \param *argv: a pointer to NULL
jamie@2 224 * \param *result: the zero crossing rate of N values from the array pointed to by *data
jamie@2 225 */
jamie@146 226 int xtract_zcr(const double *data, const int N, const void *argv, double *result);
jamie@1 227
jamie@2 228 /** \brief Extract the spectral rolloff of an input vector using a method described by Bee Suan Ong (2005)
jamie@2 229 *
jamie@146 230 * \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@2 231 * \param N: the number of elements to be considered
jamie@146 232 * \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@42 233 * \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@2 234 */
jamie@146 235 int xtract_rolloff(const double *data, const int N, const void *argv, double *result);
jamie@1 236
jamie@47 237 /** \brief Extract the 'total loudness' of an input vector using a method described by Moore, Glasberg et al (2005)
jamie@2 238 *
jamie@146 239 * \param *data: a pointer to the first element in an array of doubles representing a set of BARK_BANDS bark coefficients
jamie@2 240 * \param N: the number of coefficients to be considered
jamie@2 241 * \param *argv: a pointer to NULL
jamie@47 242 * \param *result: the total loudness of N values from the array pointed to by *data
jamie@47 243 *
jamie@47 244 * Note: if N = 1, the 'specific loudness' of the bark band pointed to by *data will be given by *result
jamie@47 245 *
jamie@2 246 */
jamie@146 247 int xtract_loudness(const double *data, const int N, const void *argv, double *result);
jamie@1 248
jamie@113 249 /** \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@113 250 *
jamie@113 251 * \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@2 252 *
jamie@146 253 * \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@113 254 * \param N: the number of *data array elements to be considered
jamie@2 255 * \param *argv: a pointer to NULL
jamie@113 256 * \param *result: the flatness of N values from the array pointed to by *data
jamie@2 257 */
jamie@146 258 int xtract_flatness(const double *data, const int N, const void *argv, double *result);
jamie@1 259
jamie@113 260 /** \brief Extract the LOG spectral flatness measure of an input vector
jamie@113 261 *
jamie@113 262 * \param *data: a pointer to NULL.
jamie@113 263 * \param N: not used - can safely be set to 0.
jamie@146 264 * \param *argv: a pointer to a double represnting spectral flatness.
jamie@113 265 * \param *result: the LOG spectral flatness of N values from the array pointed to by *data
jamie@113 266 *
jamie@113 267 * flatness_db = 10 * log10(flatness)
jamie@113 268 *
jamie@113 269 */
jamie@146 270 int xtract_flatness_db(const double *data, const int N, const void *argv, double *result);
jamie@1 271
jamie@113 272 /** \brief Extract the tonality factor of an input vector using a method described by Peeters 2003
jamie@2 273 *
jamie@113 274 * \param *data: a pointer to NULL.
jamie@113 275 * \param N: not used - can safely be set to 0.
jamie@113 276 * \param *argv: a pointer to the LOG spectral flatness measure of an audio vector (e.g. the output from xtract_flatness_db)
jamie@2 277 * \param *result: the tonality factor of N values from the array pointed to by *data
jamie@2 278 */
jamie@146 279 int xtract_tonality(const double *data, const int N, const void *argv, double *result);
jamie@1 280
jamie@2 281 /** \brief Extract the noisiness of an input vector using a method described by Tae Hong Park (2000)
jamie@2 282 *
jamie@55 283 * \param *data: a pointer to NULL
jamie@55 284 * \param N:
jamie@146 285 * \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@55 286 * \param *result: the noisiness coefficient as calculated from argv
jamie@2 287 */
jamie@146 288 int xtract_noisiness(const double *data, const int N, const void *argv, double *result);
jamie@1 289
jamie@2 290 /** \brief Extract the RMS amplitude of an input vector using a method described by Tae Hong Park (2000)
jamie@2 291 *
jamie@146 292 * \param *data: a pointer to the first element in an array of doubles
jamie@2 293 * \param N: the number of elements to be considered
jamie@2 294 * \param *argv: a pointer to NULL
jamie@2 295 * \param *result: the RMS amplitude of N values from the array pointed to by *data
jamie@2 296 */
jamie@146 297 int xtract_rms_amplitude(const double *data, const int N, const void *argv, double *result);
jamie@1 298
jamie@2 299 /** \brief Extract the Inharmonicity of an input vector
jamie@2 300 *
jamie@146 301 * \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@2 302 * \param N: the number of elements to be considered
jamie@146 303 * \param *argv: a pointer to a double representing the fundamental frequency of the input vector.
jamie@2 304 * \param *result: the inharmonicity of N values from the array pointed to by *data
jamie@2 305 */
jamie@146 306 int xtract_spectral_inharmonicity(const double *data, const int N, const void *argv, double *result);
jamie@1 307
jamie@2 308 /** \brief Extract the spectral crest of an input vector using a method described by Peeters (2003)
jamie@2 309 *
jamie@55 310 * \param *data: a pointer to NULL
jamie@55 311 * \param N: not used
jamie@146 312 * \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@2 313 * \param *result: the spectral crest of N values from the array pointed to by *data
jamie@2 314 */
jamie@146 315 int xtract_crest(const double *data, const int N, const void *argv, double *result);
jamie@1 316
jamie@2 317 /** \brief Extract the Spectral Power of an input vector using a method described by Bee Suan Ong (2005)
jamie@2 318 *
jamie@146 319 * \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@2 320 * \param N: the number of elements to be considered
jamie@2 321 * \param *argv: a pointer to NULL
jamie@2 322 * \param *result: the spectral power of N values from the array pointed to by *data
jamie@2 323 */
jamie@146 324 int xtract_power(const double *data, const int N, const void *argv, double *result);
jamie@1 325
jamie@1 326 /* Odd to even harmonic ratio */
jamie@2 327 /** \brief Extract the Odd to even harmonic ratio of an input vector
jamie@2 328 *
jamie@146 329 * \param *data: a pointer to the first element in an array of doubles representing the amplitudes of the harmonic spectrum of an audio vector. It is sufficient to pass in a pointer to the first half of the array pointed to by *result from xtract_harmonic_spectrum().
jamie@59 330 * \param N: the number of elements to be considered. If using the array pointed to by *result from xtract_harmonics, N should equal half the total array size i.e., just the amplitudes of the peaks.
jamie@59 331 * \param *argv: a pointer to NULL
jamie@113 332 * \param *result: the even/odd harmonic ratio of N values from the array pointed to by *data
jamie@2 333 */
jamie@146 334 int xtract_odd_even_ratio(const double *data, const int N, const void *argv, double *result);
jamie@1 335
jamie@2 336 /** \brief Extract the Sharpness of an input vector
jamie@2 337 *
jamie@146 338 * \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@2 339 * \param N: the number of elements to be considered
jamie@2 340 * \param *argv: a pointer to NULL
jamie@2 341 * \param *result: the Sharpness of N values from the array pointed to by *data
jamie@2 342 */
jamie@146 343 int xtract_sharpness(const double *data, const int N, const void *argv, double *result);
jamie@1 344
jamie@48 345 /** \brief Extract the Slope of an input vector using a method described by Peeters(2003)
jamie@2 346 *
jamie@146 347 * \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@2 348 * \param N: the number of elements to be considered
jamie@2 349 * \param *argv: a pointer to NULL
jamie@2 350 * \param *result: the Slope of N values from the array pointed to by *data
jamie@2 351 */
jamie@146 352 int xtract_spectral_slope(const double *data, const int N, const void *argv, double *result);
jamie@1 353
jamie@45 354 /** \brief Extract the value of the lowest value in an input vector
jamie@2 355 *
jamie@146 356 * \param *data: a pointer to the first element in an array of doubles
jamie@2 357 * \param N: the number of elements to be considered
jamie@146 358 * \param *argv: a pointer to a double representing the lower limit for the search. i.e. (*result > *argv) returns 1.
jamie@45 359 * \param *result: a pointer to a value representing the lowest component in *data that falls above a given threshold.
jamie@2 360 *
jamie@43 361 */
jamie@146 362 int xtract_lowest_value(const double *data, const int N, const void *argv, double *result);
jamie@45 363
jamie@45 364 /** \brief Extract the value of the highest value in an input vector
jamie@45 365 *
jamie@146 366 * \param *data: a pointer to the first element in an array of doubles
jamie@45 367 * \param N: the number of elements to be considered
jamie@45 368 * \param *argv: a pointer to NULL.
jamie@45 369 * \param *result: a pointer to a value representing the highest component in *data.
jamie@45 370 *
jamie@45 371 */
jamie@146 372 int xtract_highest_value(const double *data, const int N, const void *argv, double *result);
jamie@45 373
jamie@45 374 /** \brief Extract the sum of the values in an input vector
jamie@45 375 *
jamie@146 376 * \param *data: a pointer to the first element in an array of doubles
jamie@45 377 * \param N: the number of elements to be considered
jamie@45 378 * \param *argv: a pointer to NULL.
jamie@45 379 * \param *result: a pointer to a value representing the sum of all of the values pointed to by *data.
jamie@45 380 *
jamie@45 381 */
jamie@146 382 int xtract_sum(const double *data, const int N, const void *argv, double *result);
jamie@1 383
jamie@2 384 /** \brief Extract the Pitch of an input vector using Harmonic Product Spectrum (HPS) analysis
jamie@2 385 *
jamie@22 386 * \warning {This function doesn't work properly}
jamie@22 387 *
jamie@146 388 * \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@2 389 * \param N: the number of elements to be considered
jamie@2 390 * \param *argv: a pointer to NULL
jamie@2 391 * \param *result: the pitch of N values from the array pointed to by *data
jamie@2 392 */
jamie@146 393 int xtract_hps(const double *data, const int N, const void *argv, double *result);
jamie@1 394
jamie@5 395 /** \brief Extract the fundamental frequency of an input vector
jamie@5 396 *
jamie@146 397 * \param *data: a pointer to the first element in an array of doubles representing an audio vector
jamie@5 398 * \param N: the number of elements to be considered
jamie@146 399 * \param *argv: a pointer to a double representing the audio sample rate
jamie@5 400 * \param *result: the pitch of N values from the array pointed to by *data
jamie@12 401 *
jamie@22 402 * 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@117 403 *
jamie@117 404 * 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@12 405 *
jamie@5 406 */
jamie@146 407 int xtract_f0(const double *data, const int N, const void *argv, double *result);
jamie@43 408
jamie@43 409 /** \brief Extract the fundamental frequency of an input vector
jamie@43 410 *
jamie@146 411 * \param *data: a pointer to the first element in an array of doubles representing an audio vector
jamie@43 412 * \param N: the number of elements to be considered
jamie@146 413 * \param *argv: a pointer to a double representing the audio sample rate
jamie@43 414 * \param *result: the pitch of N values from the array pointed to by *data
jamie@43 415 *
jamie@43 416 * This function wraps xtract_f0, but provides the frequency of the lowest partial in the peak spectrum if f0 can't be found.
jamie@43 417 *
jamie@43 418 */
jamie@146 419 int xtract_failsafe_f0(const double *data, const int N, const void *argv, double *result);
jamie@5 420
jamie@59 421 /** \brief Extract the number of non-zero elements in an input vector
jamie@59 422 *
jamie@146 423 * \param *data: a pointer to the first element in an array of doubles
jamie@59 424 * \param N: the number of elements to be considered
jamie@59 425 * \param *argv: not used
jamie@59 426 * \param *result: the number of non-zero elements in the array pointed to by *data
jamie@59 427 *
jamie@59 428 */
jamie@146 429 int xtract_nonzero_count(const double *data, const int N, const void *argv, double *result);
jamie@59 430
jamie@20 431 /** @} */
jamie@20 432
jamie@1 433 #ifdef __cplusplus
jamie@1 434 }
jamie@1 435 #endif
jamie@1 436
jamie@1 437 #endif
jamie@1 438
jamie@1 439
jamie@1 440