jamie@1
|
1 /* libxtract feature extraction library
|
jamie@1
|
2 *
|
jamie@1
|
3 * Copyright (C) 2006 Jamie Bullock
|
jamie@1
|
4 *
|
jamie@1
|
5 * This program is free software; you can redistribute it and/or modify
|
jamie@1
|
6 * it under the terms of the GNU General Public License as published by
|
jamie@1
|
7 * the Free Software Foundation; either version 2 of the License, or
|
jamie@1
|
8 * (at your option) any later version.
|
jamie@1
|
9 *
|
jamie@1
|
10 * This program is distributed in the hope that it will be useful,
|
jamie@1
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
jamie@1
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
jamie@1
|
13 * GNU General Public License for more details.
|
jamie@1
|
14 *
|
jamie@1
|
15 * You should have received a copy of the GNU General Public License
|
jamie@1
|
16 * along with this program; if not, write to the Free Software
|
jamie@1
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
jamie@1
|
18 * USA.
|
jamie@1
|
19 */
|
jamie@1
|
20
|
jamie@1
|
21 #ifndef XTRACT_H
|
jamie@1
|
22 #define XTRACT_H
|
jamie@1
|
23
|
jamie@1
|
24 #ifdef __cplusplus
|
jamie@1
|
25 extern "C" {
|
jamie@1
|
26 #endif
|
jamie@1
|
27
|
jamie@1
|
28 /**
|
jamie@1
|
29 * \file libxtract.h: main header file and API definition
|
jamie@1
|
30 */
|
jamie@1
|
31
|
jamie@1
|
32 #define VERSION "0.1"
|
jamie@1
|
33
|
jamie@1
|
34
|
jamie@1
|
35 #include "xtract_scalar.h"
|
jamie@1
|
36 #include "xtract_vector.h"
|
jamie@1
|
37 #include "xtract_delta.h"
|
jamie@1
|
38 #include "xtract_types.h"
|
jamie@1
|
39 #include "xtract_macros.h"
|
jamie@1
|
40
|
jamie@1
|
41 #define XTRACT_FEATURES 40
|
jamie@1
|
42 #define LOG_LIMIT 10e-10
|
jamie@1
|
43 #define SR_LIMIT 192000
|
jamie@1
|
44 #define BARK_BANDS 26
|
jamie@1
|
45
|
jamie@1
|
46 /** \brief Enumeration of features, elements are used as indixes to an array of pointers to feature extracton functions */
|
jamie@1
|
47 enum features_ {
|
jamie@1
|
48 MEAN,
|
jamie@1
|
49 VARIANCE,
|
jamie@1
|
50 STANDARD_DEVIATION,
|
jamie@1
|
51 AVERAGE_DEVIATION,
|
jamie@1
|
52 SKEWNESS,
|
jamie@1
|
53 KURTOSIS,
|
jamie@1
|
54 IRREGULARITY_K,
|
jamie@1
|
55 IRREGULARITY_J,
|
jamie@1
|
56 TRISTIMULUS_1,
|
jamie@1
|
57 TRISTIMULUS_2,
|
jamie@1
|
58 TRISTIMULUS_3,
|
jamie@1
|
59 SMOOTHNESS,
|
jamie@1
|
60 SPREAD,
|
jamie@1
|
61 ZCR,
|
jamie@1
|
62 ROLLOFF,
|
jamie@1
|
63 LOUDNESS,
|
jamie@1
|
64 FLATNESS,
|
jamie@1
|
65 TONALITY,
|
jamie@1
|
66 CREST,
|
jamie@1
|
67 NOISINESS,
|
jamie@1
|
68 RMS_AMPLITUDE,
|
jamie@1
|
69 INHARMONICITY,
|
jamie@1
|
70 POWER,
|
jamie@1
|
71 ODD_EVEN_RATIO,
|
jamie@1
|
72 SHARPNESS,
|
jamie@1
|
73 SLOPE,
|
jamie@1
|
74 F0,
|
jamie@1
|
75 HPS,
|
jamie@1
|
76 MAGNITUDE_SPECTRUM,
|
jamie@1
|
77 AUTOCORRELATION,
|
jamie@1
|
78 AUTOCORRELATION_FFT,
|
jamie@1
|
79 AMDF,
|
jamie@1
|
80 ASDF,
|
jamie@1
|
81 MFCC,
|
jamie@1
|
82 DCT,
|
jamie@1
|
83 BARK_COEFFICIENTS,
|
jamie@1
|
84 PEAKS,
|
jamie@1
|
85 FLUX,
|
jamie@1
|
86 ATTACK_TIME,
|
jamie@1
|
87 DECAY_TIME,
|
jamie@1
|
88 DELTA_FEATURE
|
jamie@1
|
89 };
|
jamie@1
|
90
|
jamie@1
|
91 /** \brief Enumeration of feature types */
|
jamie@1
|
92 enum feature_types_ {
|
jamie@1
|
93 SCALAR,
|
jamie@1
|
94 VECTOR,
|
jamie@1
|
95 DELTA
|
jamie@1
|
96 };
|
jamie@1
|
97
|
jamie@1
|
98 /** \brief Enumeration of mfcc types */
|
jamie@1
|
99 enum mfcc_types_ {
|
jamie@1
|
100 EQUAL_GAIN,
|
jamie@1
|
101 EQUAL_AREA
|
jamie@1
|
102 };
|
jamie@1
|
103
|
jamie@1
|
104 /** \brief Enumeration of return codes */
|
jamie@1
|
105 enum return_codes_ {
|
jamie@1
|
106 SUCCESS,
|
jamie@1
|
107 MALLOC_FAILED,
|
jamie@1
|
108 BAD_ARGV,
|
jamie@1
|
109 BAD_VECTOR_SIZE
|
jamie@1
|
110 };
|
jamie@1
|
111
|
jamie@1
|
112 /**
|
jamie@1
|
113 *
|
jamie@2
|
114 * \brief An array of pointers to functions that perform the extraction
|
jamie@1
|
115 *
|
jamie@2
|
116 * \param *data: a pointer to the start of the input data (usually the first element in an array)
|
jamie@1
|
117 *
|
jamie@2
|
118 * \param N: the number of elements to be processed
|
jamie@1
|
119 *
|
jamie@2
|
120 * \param *argv: an abitrary number of additional arguments, used to pass additional parameters to the function being called
|
jamie@1
|
121 *
|
jamie@2
|
122 * \param *result: a pointer to the first element in the result
|
jamie@1
|
123 *
|
jamie@1
|
124 * Each function will iterate over N array elements, the first of which is
|
jamie@2
|
125 * 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
|
126 *
|
jamie@1
|
127 * For scalar and delta features, *result will point to a single value.
|
jamie@1
|
128 *
|
jamie@1
|
129 * For vector features it will point to the first element in an array.
|
jamie@1
|
130 *
|
jamie@1
|
131 * Memory for this array must be allocated and freed by the calling
|
jamie@1
|
132 * function.
|
jamie@1
|
133 *
|
jamie@1
|
134 * All functions return an integer error code as descibed in the enumeration
|
jamie@1
|
135 * return_codes_
|
jamie@2
|
136 *
|
jamie@2
|
137 * example:<br>
|
jamie@2
|
138 * xtract[PEAKS](amplitude_spectrum, 512, threshold, peaks)
|
jamie@2
|
139 */
|
jamie@2
|
140 int(*xtract[XTRACT_FEATURES])(float *data, int N, void *argv, float *result);
|
jamie@1
|
141
|
jamie@2
|
142 /** \brief A structure to store a set of n_filters Mel filters */
|
jamie@1
|
143 typedef struct xtract_mel_filter_ {
|
jamie@1
|
144 int n_filters;
|
jamie@1
|
145 float **filters;
|
jamie@1
|
146 } xtract_mel_filter;
|
jamie@1
|
147
|
jamie@2
|
148 /** \brief A function to initialise a mel filter bank
|
jamie@2
|
149 *
|
jamie@2
|
150 * 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
|
151 */
|
jamie@1
|
152 int xtract_init_mfcc(int N, float nyquist, int style, float freq_max, float freq_min, int freq_bands, float **fft_tables);
|
jamie@1
|
153
|
jamie@2
|
154 /** \brief A function to initialise bark filter bounds
|
jamie@2
|
155 *
|
jamie@2
|
156 * 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@2
|
157 */
|
jamie@1
|
158 int xtract_init_bark(int N, float nyquist, int *band_limits);
|
jamie@1
|
159
|
jamie@1
|
160
|
jamie@1
|
161 /* Free functions */
|
jamie@1
|
162
|
jamie@1
|
163 #ifdef __cplusplus
|
jamie@1
|
164 }
|
jamie@1
|
165 #endif
|
jamie@1
|
166
|
jamie@1
|
167 #endif
|