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@20
|
24 /** \mainpage
|
jamie@20
|
25 *
|
jamie@20
|
26 * LibXtract is a simple, portable, lightweight library of audio feature extraction functions. The purpose of the library is to provide a relatively exhaustive set of feature extraction primatives that are designed to be 'cascaded' to create a extraction hierarchies.
|
jamie@20
|
27 * For example, 'variance', 'average deviation', 'skewness' and 'kurtosis', all require the 'mean' of the input vector to be precomputed. However, rather than compute the 'mean' 'inside' each function, it is expected that the 'mean' will be passed in as an argument. This means that if the user wishes to use all of these features, the mean is calculated only once, and then passed to any functions that require it.
|
jamie@20
|
28 *
|
jamie@20
|
29 * This philosophy of 'cascading' features is followed throughout the library, for example with features that operate on the magnitude spectrum of a signal vector (e.g. 'irregularity'), the magnitude spectrum is not calculated 'inside' the respective function, instead, a pointer to the first element in an array containing the magnitude spectrum is passed in as an argument.
|
jamie@20
|
30 *
|
jamie@105
|
31 * Hopefully this not only makes the library more efficient when computing large numbers of features, but also makes it more flexible because extraction functions can be combined arbitrarily (one can take the irregularility of the Mel Frequency Cepstral Coefficients for example).
|
jamie@20
|
32 *
|
jamie@105
|
33 * All feature extraction functions follow the same prototype:
|
jamie@105
|
34 *
|
jamie@146
|
35 int xtract_function_name(const double *data, const int N, const void *argv, double *result){
|
jamie@105
|
36 *
|
jamie@146
|
37 * \param const double *data points to an array of doubles representing the input data
|
jamie@105
|
38 * \param const int N represents the number of elementes from *data to be considered in the calculation
|
jamie@105
|
39 * \param const void *argv represents an arbitrary list of arguments. Used to pass in values required by the feature calculation
|
jamie@146
|
40 * \param double *result points to an array of doubles, or a single double represnting the result of the calculation
|
jamie@105
|
41 *
|
jamie@105
|
42 *
|
jamie@105
|
43 * It is up to the calling function to allocate enough memory for the *data, *argv, and *result, and to free it when required. Some feature extraction functions may also require an _init() function to be called in order to perform some initialisation. The struct xtract_function_descriptor_t is used to give an indication of recommended default values, and argc for the *argv array.
|
jamie@83
|
44 *
|
jamie@83
|
45 * LibXtract can be downloaded from http://www.sf.net/projects/libxtract
|
jamie@83
|
46 *
|
jamie@20
|
47 */
|
jamie@20
|
48
|
jamie@1
|
49 #ifndef XTRACT_H
|
jamie@1
|
50 #define XTRACT_H
|
jamie@1
|
51
|
jamie@1
|
52 #ifdef __cplusplus
|
jamie@1
|
53 extern "C" {
|
jamie@1
|
54 #endif
|
jamie@1
|
55
|
jamie@21
|
56 /**
|
jamie@21
|
57 * \file libxtract.h
|
jamie@21
|
58 * \brief main header file and API definition
|
jamie@1
|
59 */
|
jamie@1
|
60
|
jamie@1
|
61 #include "xtract_scalar.h"
|
jamie@1
|
62 #include "xtract_vector.h"
|
jamie@1
|
63 #include "xtract_delta.h"
|
jamie@1
|
64 #include "xtract_types.h"
|
jamie@1
|
65 #include "xtract_macros.h"
|
jamie@107
|
66 #include "xtract_helper.h"
|
jamie@1
|
67
|
jamie@20
|
68 /** \defgroup libxtract API
|
jamie@20
|
69 *
|
jamie@20
|
70 * Defines a very simple API that provides access to the functions in the library
|
jamie@20
|
71 * @{
|
jamie@20
|
72 */
|
jamie@20
|
73
|
jamie@167
|
74 #define XTRACT_FEATURES 60
|
jamie@30
|
75
|
jamie@1
|
76 /** \brief Enumeration of features, elements are used as indixes to an array of pointers to feature extracton functions */
|
jamie@56
|
77 enum xtract_features_ {
|
jamie@56
|
78 XTRACT_MEAN,
|
jamie@56
|
79 XTRACT_VARIANCE,
|
jamie@56
|
80 XTRACT_STANDARD_DEVIATION,
|
jamie@56
|
81 XTRACT_AVERAGE_DEVIATION,
|
jamie@56
|
82 XTRACT_SKEWNESS,
|
jamie@56
|
83 XTRACT_KURTOSIS,
|
jamie@56
|
84 XTRACT_SPECTRAL_MEAN,
|
jamie@56
|
85 XTRACT_SPECTRAL_VARIANCE,
|
jamie@56
|
86 XTRACT_SPECTRAL_STANDARD_DEVIATION,
|
jamie@123
|
87 /*XTRACT_SPECTRAL_AVERAGE_DEVIATION, */
|
jamie@56
|
88 XTRACT_SPECTRAL_SKEWNESS,
|
jamie@56
|
89 XTRACT_SPECTRAL_KURTOSIS,
|
jamie@56
|
90 XTRACT_SPECTRAL_CENTROID,
|
jamie@56
|
91 XTRACT_IRREGULARITY_K,
|
jamie@56
|
92 XTRACT_IRREGULARITY_J,
|
jamie@56
|
93 XTRACT_TRISTIMULUS_1,
|
jamie@56
|
94 XTRACT_TRISTIMULUS_2,
|
jamie@56
|
95 XTRACT_TRISTIMULUS_3,
|
jamie@56
|
96 XTRACT_SMOOTHNESS,
|
jamie@56
|
97 XTRACT_SPREAD,
|
jamie@56
|
98 XTRACT_ZCR,
|
jamie@56
|
99 XTRACT_ROLLOFF,
|
jamie@56
|
100 XTRACT_LOUDNESS,
|
jamie@56
|
101 XTRACT_FLATNESS,
|
jamie@113
|
102 XTRACT_FLATNESS_DB,
|
jamie@56
|
103 XTRACT_TONALITY,
|
jamie@56
|
104 XTRACT_CREST,
|
jamie@56
|
105 XTRACT_NOISINESS,
|
jamie@56
|
106 XTRACT_RMS_AMPLITUDE,
|
jamie@56
|
107 XTRACT_SPECTRAL_INHARMONICITY,
|
jamie@56
|
108 XTRACT_POWER,
|
jamie@56
|
109 XTRACT_ODD_EVEN_RATIO,
|
jamie@56
|
110 XTRACT_SHARPNESS,
|
jamie@56
|
111 XTRACT_SPECTRAL_SLOPE,
|
jamie@56
|
112 XTRACT_LOWEST_VALUE,
|
jamie@56
|
113 XTRACT_HIGHEST_VALUE,
|
jamie@56
|
114 XTRACT_SUM,
|
jamie@59
|
115 XTRACT_NONZERO_COUNT,
|
jamie@56
|
116 XTRACT_HPS,
|
jamie@56
|
117 XTRACT_F0,
|
jamie@56
|
118 XTRACT_FAILSAFE_F0,
|
jamie@161
|
119 XTRACT_WAVELET_F0,
|
jamie@106
|
120 XTRACT_LNORM,
|
jamie@56
|
121 XTRACT_FLUX,
|
jamie@56
|
122 XTRACT_ATTACK_TIME,
|
jamie@56
|
123 XTRACT_DECAY_TIME,
|
jamie@106
|
124 XTRACT_DIFFERENCE_VECTOR,
|
jamie@56
|
125 XTRACT_AUTOCORRELATION,
|
jamie@56
|
126 XTRACT_AMDF,
|
jamie@56
|
127 XTRACT_ASDF,
|
jamie@56
|
128 XTRACT_BARK_COEFFICIENTS,
|
jamie@56
|
129 XTRACT_PEAK_SPECTRUM,
|
jamie@56
|
130 XTRACT_SPECTRUM,
|
jamie@56
|
131 XTRACT_AUTOCORRELATION_FFT,
|
jamie@56
|
132 XTRACT_MFCC,
|
jamie@56
|
133 XTRACT_DCT,
|
jamie@104
|
134 XTRACT_HARMONIC_SPECTRUM,
|
jamie@104
|
135 XTRACT_LPC,
|
jamie@107
|
136 XTRACT_LPCC,
|
jamie@114
|
137 XTRACT_SUBBANDS,
|
jamie@107
|
138 /* Helper functions */
|
jamie@107
|
139 XTRACT_WINDOWED
|
jamie@1
|
140 };
|
jamie@1
|
141
|
jamie@55
|
142 /** \brief Enumeration of feature initialisation functions */
|
jamie@56
|
143 enum xtract_feature_init_ {
|
jamie@56
|
144 XTRACT_INIT_MFCC = 100,
|
jamie@108
|
145 XTRACT_INIT_BARK,
|
jamie@108
|
146 XTRACT_INIT_WINDOWED
|
jamie@55
|
147 };
|
jamie@55
|
148
|
jamie@1
|
149 /** \brief Enumeration of feature types */
|
jamie@56
|
150 enum xtract_feature_types_ {
|
jamie@56
|
151 XTRACT_SCALAR,
|
jamie@56
|
152 XTRACT_VECTOR,
|
jamie@56
|
153 XTRACT_DELTA
|
jamie@1
|
154 };
|
jamie@1
|
155
|
jamie@1
|
156 /** \brief Enumeration of mfcc types */
|
jamie@56
|
157 enum xtract_mfcc_types_ {
|
jamie@56
|
158 XTRACT_EQUAL_GAIN,
|
jamie@56
|
159 XTRACT_EQUAL_AREA
|
jamie@1
|
160 };
|
jamie@1
|
161
|
jamie@106
|
162 enum xtract_lnorm_filter_types_ {
|
jamie@108
|
163 XTRACT_NO_LNORM_FILTER,
|
jamie@106
|
164 XTRACT_POSITIVE_SLOPE,
|
jamie@106
|
165 XTRACT_NEGATIVE_SLOPE
|
jamie@106
|
166 };
|
jamie@106
|
167
|
jamie@1
|
168 /** \brief Enumeration of return codes */
|
jamie@56
|
169 enum xtract_return_codes_ {
|
jamie@56
|
170 XTRACT_SUCCESS,
|
jamie@56
|
171 XTRACT_MALLOC_FAILED,
|
jamie@56
|
172 XTRACT_BAD_ARGV,
|
jamie@56
|
173 XTRACT_BAD_VECTOR_SIZE,
|
jamie@113
|
174 XTRACT_DENORMAL_FOUND,
|
jamie@113
|
175 XTRACT_NO_RESULT, /* This usually occurs when the correct calculation cannot take place because required data is missing or would result in a NaN or infinity/-infinity. Under these curcumstances 0.f is usually given by *result */
|
jamie@56
|
176 XTRACT_FEATURE_NOT_IMPLEMENTED
|
jamie@1
|
177 };
|
jamie@1
|
178
|
jamie@54
|
179 /** \brief Enumeration of spectrum types */
|
jamie@56
|
180 enum xtract_spectrum_ {
|
jamie@56
|
181 XTRACT_MAGNITUDE_SPECTRUM,
|
jamie@56
|
182 XTRACT_LOG_MAGNITUDE_SPECTRUM,
|
jamie@56
|
183 XTRACT_POWER_SPECTRUM,
|
jamie@56
|
184 XTRACT_LOG_POWER_SPECTRUM
|
jamie@54
|
185 };
|
jamie@54
|
186
|
jamie@114
|
187 /** \brief Subband scales */
|
jamie@114
|
188 enum xtract_subband_scales_ {
|
jamie@114
|
189 XTRACT_OCTAVE_SUBBANDS,
|
jamie@114
|
190 XTRACT_LINEAR_SUBBANDS
|
jamie@114
|
191 };
|
jamie@114
|
192
|
jamie@50
|
193 /** \brief Enumeration of data types*/
|
jamie@50
|
194 typedef enum type_ {
|
jamie@56
|
195 XTRACT_FLOAT,
|
jamie@56
|
196 XTRACT_FLOATARRAY,
|
jamie@56
|
197 XTRACT_INT,
|
jamie@56
|
198 XTRACT_MEL_FILTER
|
jamie@56
|
199 } xtract_type_t;
|
jamie@50
|
200
|
jamie@50
|
201 /** \brief Enumeration of units*/
|
jamie@50
|
202 typedef enum unit_ {
|
jamie@55
|
203 /* NONE, ANY */
|
jamie@56
|
204 XTRACT_HERTZ = 2,
|
jamie@56
|
205 XTRACT_ANY_AMPLITUDE_HERTZ,
|
jamie@56
|
206 XTRACT_DBFS,
|
jamie@56
|
207 XTRACT_DBFS_HERTZ,
|
jamie@56
|
208 XTRACT_PERCENT,
|
jamie@115
|
209 XTRACT_BINS,
|
jamie@56
|
210 XTRACT_SONE
|
jamie@56
|
211 } xtract_unit_t;
|
jamie@50
|
212
|
jamie@50
|
213 /** \brief Boolean */
|
jamie@50
|
214 typedef enum {
|
jamie@56
|
215 XTRACT_FALSE,
|
jamie@56
|
216 XTRACT_TRUE
|
jamie@56
|
217 } xtract_bool_t;
|
jamie@50
|
218
|
jamie@107
|
219 /** \brief Window types */
|
jamie@107
|
220 enum xtract_window_types_ {
|
jamie@107
|
221 XTRACT_GAUSS,
|
jamie@107
|
222 XTRACT_HAMMING,
|
jamie@107
|
223 XTRACT_HANN,
|
jamie@107
|
224 XTRACT_BARTLETT,
|
jamie@107
|
225 XTRACT_TRIANGULAR,
|
jamie@107
|
226 XTRACT_BARTLETT_HANN,
|
jamie@107
|
227 XTRACT_BLACKMAN,
|
jamie@107
|
228 XTRACT_KAISER,
|
jamie@107
|
229 XTRACT_BLACKMAN_HARRIS
|
jamie@107
|
230 };
|
jamie@107
|
231
|
jamie@50
|
232 /** \brief Enumeration of vector format types*/
|
jamie@56
|
233 typedef enum xtract_vector_ {
|
jamie@54
|
234 /* N/2 magnitude/log-magnitude/power/log-power coeffs and N/2 frequencies */
|
jamie@56
|
235 XTRACT_SPECTRAL,
|
jamie@54
|
236 /* N spectral amplitudes */
|
jamie@56
|
237 XTRACT_SPECTRAL_MAGNITUDES,
|
jamie@54
|
238 /* N/2 magnitude/log-magnitude/power/log-power peak coeffs and N/2
|
jamie@54
|
239 * frequencies */
|
jamie@56
|
240 XTRACT_SPECTRAL_PEAKS,
|
jamie@54
|
241 /* N spectral peak amplitudes */
|
jamie@59
|
242 XTRACT_SPECTRAL_PEAKS_MAGNITUDES,
|
jamie@59
|
243 /* N spectral peak frequencies */
|
jamie@59
|
244 XTRACT_SPECTRAL_PEAKS_FREQUENCIES,
|
jamie@54
|
245 /* N/2 magnitude/log-magnitude/power/log-power harmonic peak coeffs and N/2
|
jamie@54
|
246 * frequencies */
|
jamie@56
|
247 XTRACT_SPECTRAL_HARMONICS,
|
jamie@54
|
248 /* N spectral harmonic amplitudes */
|
jamie@56
|
249 XTRACT_SPECTRAL_HARMONICS_MAGNITUDES,
|
jamie@54
|
250 /* N spectral harmonic frequencies */
|
jamie@56
|
251 XTRACT_SPECTRAL_HARMONICS_FREQUENCIES,
|
jamie@104
|
252 XTRACT_AUTOCORRELATION_COEFFS,
|
jamie@56
|
253 XTRACT_ARBITRARY_SERIES,
|
jamie@56
|
254 XTRACT_AUDIO_SAMPLES,
|
jamie@56
|
255 XTRACT_MEL_COEFFS,
|
jamie@104
|
256 XTRACT_LPC_COEFFS,
|
jamie@104
|
257 XTRACT_LPCC_COEFFS,
|
jamie@56
|
258 XTRACT_BARK_COEFFS,
|
jamie@108
|
259 XTRACT_SUBFRAMES,
|
jamie@56
|
260 XTRACT_NO_DATA
|
jamie@56
|
261 } xtract_vector_t;
|
jamie@50
|
262
|
jamie@50
|
263 /** \brief Data structure containing useful information about functions provided by LibXtract. */
|
jamie@56
|
264 typedef struct _xtract_function_descriptor {
|
jamie@50
|
265
|
jamie@110
|
266 int id;
|
jamie@110
|
267
|
jamie@50
|
268 struct {
|
jamie@56
|
269 char name[XTRACT_MAX_NAME_LENGTH];
|
jamie@56
|
270 char p_name[XTRACT_MAX_NAME_LENGTH]; /* pretty name */
|
jamie@56
|
271 char desc[XTRACT_MAX_DESC_LENGTH];
|
jamie@56
|
272 char p_desc[XTRACT_MAX_DESC_LENGTH]; /* pretty description */
|
jamie@56
|
273 char author[XTRACT_MAX_AUTHOR_LENGTH];
|
jamie@50
|
274 int year;
|
jamie@50
|
275 } algo;
|
jamie@50
|
276
|
jamie@50
|
277 struct {
|
jamie@56
|
278 xtract_vector_t format;
|
jamie@56
|
279 xtract_unit_t unit;
|
jamie@50
|
280 } data;
|
jamie@50
|
281
|
jamie@51
|
282 int argc;
|
jamie@50
|
283
|
jamie@50
|
284 struct {
|
jamie@56
|
285 xtract_type_t type; /* type of the array/value pointed to by argv */
|
jamie@146
|
286 double min[XTRACT_MAXARGS];
|
jamie@146
|
287 double max[XTRACT_MAXARGS];
|
jamie@146
|
288 double def[XTRACT_MAXARGS]; /* defaults */
|
jamie@56
|
289 xtract_unit_t unit[XTRACT_MAXARGS];
|
jamie@56
|
290 int donor[XTRACT_MAXARGS]; /* suggested donor functions for argv */
|
jamie@50
|
291 } argv;
|
jamie@50
|
292
|
jamie@56
|
293 xtract_bool_t is_scalar;
|
jamie@108
|
294 xtract_bool_t is_delta; /* features in xtract_delta.h can be scalar or vector */
|
jamie@50
|
295
|
jamie@55
|
296 /* The result.<> entries in descritors.c need to be checked */
|
jamie@50
|
297 union {
|
jamie@50
|
298
|
jamie@50
|
299 struct {
|
jamie@146
|
300 double min;
|
jamie@146
|
301 double max;
|
jamie@56
|
302 xtract_unit_t unit;
|
jamie@50
|
303 } scalar;
|
jamie@50
|
304
|
jamie@50
|
305 struct {
|
jamie@56
|
306 xtract_vector_t format;
|
jamie@56
|
307 xtract_unit_t unit;
|
jamie@50
|
308 } vector;
|
jamie@50
|
309
|
jamie@50
|
310 } result;
|
jamie@50
|
311
|
jamie@56
|
312 } xtract_function_descriptor_t;
|
jamie@50
|
313
|
jamie@1
|
314 /**
|
jamie@1
|
315 *
|
jamie@2
|
316 * \brief An array of pointers to functions that perform the extraction
|
jamie@1
|
317 *
|
jamie@2
|
318 * \param *data: a pointer to the start of the input data (usually the first element in an array)
|
jamie@1
|
319 *
|
jamie@2
|
320 * \param N: the number of elements to be processed
|
jamie@1
|
321 *
|
jamie@98
|
322 * \param *argv: an abitrary number of additional arguments, used to pass additional parameters to the function being called. All arguments are compulsary!
|
jamie@1
|
323 *
|
jamie@2
|
324 * \param *result: a pointer to the first element in the result
|
jamie@1
|
325 *
|
jamie@1
|
326 * Each function will iterate over N array elements, the first of which is
|
jamie@2
|
327 * pointed to by *data. It is up to the calling function to ensure that the array is in the format expected by the function being called.
|
jamie@1
|
328 *
|
jamie@1
|
329 * For scalar and delta features, *result will point to a single value.
|
jamie@1
|
330 *
|
jamie@1
|
331 * For vector features it will point to the first element in an array.
|
jamie@1
|
332 *
|
jamie@1
|
333 * Memory for this array must be allocated and freed by the calling
|
jamie@1
|
334 * function.
|
jamie@1
|
335 *
|
jamie@21
|
336 * All functions return an integer error code as descibed in the enumeration
|
jamie@21
|
337 * return_codes_
|
jamie@2
|
338 *
|
jamie@21
|
339 * The preprocessor macro: XTRACT must be defined before this can be used
|
jamie@9
|
340 *
|
jamie@2
|
341 * example:<br>
|
jamie@21
|
342 * \verbatim
|
jamie@21
|
343 #include <stdio.h>
|
jamie@21
|
344 #define XTRACT
|
jamie@21
|
345 #include "libxtract.h"
|
jamie@21
|
346
|
jamie@21
|
347 main () {
|
jamie@146
|
348 double values[] = {1.0, 2.0, 3.0, 4.0, 5.0};
|
jamie@21
|
349 int N = 5;
|
jamie@146
|
350 double mean;
|
jamie@21
|
351
|
jamie@21
|
352 xtract[MEAN]((void *)values, N, NULL, &mean);
|
jamie@21
|
353
|
jamie@21
|
354 printf("Mean = %.2f\n", mean);
|
jamie@21
|
355 }
|
jamie@21
|
356 \endverbatim
|
jamie@9
|
357 * The calling function may additionally make some tests against the value returned by xtract
|
jamie@9
|
358 *
|
jamie@2
|
359 */
|
jamie@56
|
360 #ifdef XTRACT_H
|
jamie@146
|
361 extern int(*xtract[XTRACT_FEATURES])(const double *data, const int N, const void *argv, double *result);
|
jamie@1
|
362
|
jamie@28
|
363 #endif
|
jamie@26
|
364
|
jamie@161
|
365 /** \brief A function to initialise wavelet f0 detector state */
|
jamie@161
|
366 int xtract_init_wavelet_f0_state(void);
|
jamie@161
|
367
|
jamie@2
|
368 /** \brief A structure to store a set of n_filters Mel filters */
|
jamie@1
|
369 typedef struct xtract_mel_filter_ {
|
jamie@1
|
370 int n_filters;
|
jamie@146
|
371 double **filters;
|
jamie@1
|
372 } xtract_mel_filter;
|
jamie@1
|
373
|
jamie@2
|
374 /** \brief A function to initialise a mel filter bank
|
jamie@2
|
375 *
|
jamie@2
|
376 * It is up to the caller to pass in a pointer to memory allocated for freq_bands arrays of length N. This function populates these arrays with magnitude coefficients representing the mel filterbank on a linear scale
|
jamie@2
|
377 */
|
jamie@146
|
378 int xtract_init_mfcc(int N, double nyquist, int style, double freq_min, double freq_max, int freq_bands, double **fft_tables);
|
jamie@1
|
379
|
jamie@2
|
380 /** \brief A function to initialise bark filter bounds
|
jamie@2
|
381 *
|
jamie@2
|
382 * A pointer to an array of BARK_BANDS ints most be passed in, and is populated with BARK_BANDS fft bin numbers representing the limits of each band
|
jamie@59
|
383 *
|
jamie@59
|
384 * \param N: the audio block size
|
jamie@59
|
385 * \param sr: The sample audio sample rate
|
jamie@59
|
386 * \param *band_limits: a pointer to an array of BARK_BANDS ints
|
jamie@2
|
387 */
|
jamie@146
|
388 int xtract_init_bark(int N, double sr, int *band_limits);
|
jamie@1
|
389
|
jamie@98
|
390 /** \brief An initialisation function for functions using FFT
|
jamie@98
|
391 *
|
jamie@98
|
392 * This function initialises global data structures used by functions requiring FFT functionality. It can be called multiple times with different feature names. Calling it more than once with the same feature name is not a valid operation and will result in a memory leak.
|
jamie@98
|
393 *
|
jamie@98
|
394 * \param N: the size of the FFT
|
jamie@98
|
395 * \param feature_name: the name of the feature the FFT is being used for,
|
jamie@98
|
396 * e.g. XTRACT_DCT
|
jamie@98
|
397 *
|
jamie@98
|
398 */
|
jamie@98
|
399 int xtract_init_fft(int N, int feature_name);
|
jamie@98
|
400
|
jamie@110
|
401 /** \brief Free memory used for fft plans
|
jamie@110
|
402 *
|
jamie@110
|
403 * This function should be used to explicitly free memory allocated for ffts by xtract_init_fft(). It is primarily intended for use if a new FFT needs to be taken with a different blocksize. If only one fft size is required then there is no need to call this function since it will be called when the program exits.
|
jamie@110
|
404 * */
|
jamie@110
|
405 void xtract_free_fft(void);
|
jamie@110
|
406
|
jamie@107
|
407 /** \brief Make a window of a given type and return a pointer to it
|
jamie@107
|
408 *
|
jamie@107
|
409 * \param N: the size of the window
|
jamie@107
|
410 * \param type: the type of the window as given in the enumeration window_types_
|
jamie@107
|
411 *
|
jamie@107
|
412 */
|
jamie@146
|
413 double *xtract_init_window(const int N, const int type);
|
jamie@107
|
414
|
jamie@107
|
415 /** \brief Free a window as allocated by xtract_make_window()
|
jamie@107
|
416 *
|
jamie@146
|
417 * \param *window: a pointer to an array of doubles as allocated by xtract_make_window()
|
jamie@107
|
418 *
|
jamie@107
|
419 */
|
jamie@146
|
420 void xtract_free_window(double *window);
|
jamie@107
|
421
|
jamie@50
|
422 /* \brief A function to build an array of function descriptors */
|
jamie@110
|
423 xtract_function_descriptor_t *xtract_make_descriptors();
|
jamie@1
|
424
|
jamie@50
|
425 /* \brief A function to free an array of function descriptors */
|
jamie@110
|
426 int xtract_free_descriptors(xtract_function_descriptor_t *fd);
|
jamie@1
|
427 /* Free functions */
|
jamie@1
|
428
|
jamie@20
|
429 /** @} */
|
jamie@20
|
430
|
jamie@1
|
431 #ifdef __cplusplus
|
jamie@1
|
432 }
|
jamie@1
|
433 #endif
|
jamie@1
|
434
|
jamie@1
|
435 #endif
|