00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00035 #ifndef XTRACT_H
00036 #define XTRACT_H
00037
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041
00047 #include "xtract_scalar.h"
00048 #include "xtract_vector.h"
00049 #include "xtract_delta.h"
00050 #include "xtract_types.h"
00051 #include "xtract_macros.h"
00052
00059 #define XTRACT_FEATURES 54
00060
00062 enum xtract_features_ {
00063 XTRACT_MEAN,
00064 XTRACT_VARIANCE,
00065 XTRACT_STANDARD_DEVIATION,
00066 XTRACT_AVERAGE_DEVIATION,
00067 XTRACT_SKEWNESS,
00068 XTRACT_KURTOSIS,
00069 XTRACT_SPECTRAL_MEAN,
00070 XTRACT_SPECTRAL_VARIANCE,
00071 XTRACT_SPECTRAL_STANDARD_DEVIATION,
00072 XTRACT_SPECTRAL_AVERAGE_DEVIATION,
00073 XTRACT_SPECTRAL_SKEWNESS,
00074 XTRACT_SPECTRAL_KURTOSIS,
00075 XTRACT_SPECTRAL_CENTROID,
00076 XTRACT_IRREGULARITY_K,
00077 XTRACT_IRREGULARITY_J,
00078 XTRACT_TRISTIMULUS_1,
00079 XTRACT_TRISTIMULUS_2,
00080 XTRACT_TRISTIMULUS_3,
00081 XTRACT_SMOOTHNESS,
00082 XTRACT_SPREAD,
00083 XTRACT_ZCR,
00084 XTRACT_ROLLOFF,
00085 XTRACT_LOUDNESS,
00086 XTRACT_FLATNESS,
00087 XTRACT_TONALITY,
00088 XTRACT_CREST,
00089 XTRACT_NOISINESS,
00090 XTRACT_RMS_AMPLITUDE,
00091 XTRACT_SPECTRAL_INHARMONICITY,
00092 XTRACT_POWER,
00093 XTRACT_ODD_EVEN_RATIO,
00094 XTRACT_SHARPNESS,
00095 XTRACT_SPECTRAL_SLOPE,
00096 XTRACT_LOWEST_VALUE,
00097 XTRACT_HIGHEST_VALUE,
00098 XTRACT_SUM,
00099 XTRACT_NONZERO_COUNT,
00100 XTRACT_HPS,
00101 XTRACT_F0,
00102 XTRACT_FAILSAFE_F0,
00103 XTRACT_FLUX,
00104 XTRACT_ATTACK_TIME,
00105 XTRACT_DECAY_TIME,
00106 XTRACT_DELTA_FEATURE,
00107 XTRACT_AUTOCORRELATION,
00108 XTRACT_AMDF,
00109 XTRACT_ASDF,
00110 XTRACT_BARK_COEFFICIENTS,
00111 XTRACT_PEAK_SPECTRUM,
00112 XTRACT_SPECTRUM,
00113 XTRACT_AUTOCORRELATION_FFT,
00114 XTRACT_MFCC,
00115 XTRACT_DCT,
00116 XTRACT_HARMONIC_SPECTRUM
00117 };
00118
00120 enum xtract_feature_init_ {
00121 XTRACT_INIT_MFCC = 100,
00122 XTRACT_INIT_BARK
00123 };
00124
00126 enum xtract_feature_types_ {
00127 XTRACT_SCALAR,
00128 XTRACT_VECTOR,
00129 XTRACT_DELTA
00130 };
00131
00133 enum xtract_mfcc_types_ {
00134 XTRACT_EQUAL_GAIN,
00135 XTRACT_EQUAL_AREA
00136 };
00137
00139 enum xtract_return_codes_ {
00140 XTRACT_SUCCESS,
00141 XTRACT_MALLOC_FAILED,
00142 XTRACT_BAD_ARGV,
00143 XTRACT_BAD_VECTOR_SIZE,
00144 XTRACT_NO_RESULT,
00145 XTRACT_FEATURE_NOT_IMPLEMENTED
00146 };
00147
00149 enum xtract_spectrum_ {
00150 XTRACT_MAGNITUDE_SPECTRUM,
00151 XTRACT_LOG_MAGNITUDE_SPECTRUM,
00152 XTRACT_POWER_SPECTRUM,
00153 XTRACT_LOG_POWER_SPECTRUM
00154 };
00155
00157 typedef enum type_ {
00158 XTRACT_FLOAT,
00159 XTRACT_FLOATARRAY,
00160 XTRACT_INT,
00161 XTRACT_MEL_FILTER
00162 } xtract_type_t;
00163
00165 typedef enum unit_ {
00166
00167 XTRACT_HERTZ = 2,
00168 XTRACT_ANY_AMPLITUDE_HERTZ,
00169 XTRACT_DBFS,
00170 XTRACT_DBFS_HERTZ,
00171 XTRACT_PERCENT,
00172 XTRACT_SONE
00173 } xtract_unit_t;
00174
00176 typedef enum {
00177 XTRACT_FALSE,
00178 XTRACT_TRUE
00179 } xtract_bool_t;
00180
00182 typedef enum xtract_vector_ {
00183
00184 XTRACT_SPECTRAL,
00185
00186 XTRACT_SPECTRAL_MAGNITUDES,
00187
00188
00189 XTRACT_SPECTRAL_PEAKS,
00190
00191 XTRACT_SPECTRAL_PEAKS_MAGNITUDES,
00192
00193 XTRACT_SPECTRAL_PEAKS_FREQUENCIES,
00194
00195
00196 XTRACT_SPECTRAL_HARMONICS,
00197
00198 XTRACT_SPECTRAL_HARMONICS_MAGNITUDES,
00199
00200 XTRACT_SPECTRAL_HARMONICS_FREQUENCIES,
00201 XTRACT_ARBITRARY_SERIES,
00202 XTRACT_AUDIO_SAMPLES,
00203 XTRACT_MEL_COEFFS,
00204 XTRACT_BARK_COEFFS,
00205 XTRACT_NO_DATA
00206 } xtract_vector_t;
00207
00209 typedef struct _xtract_function_descriptor {
00210
00211 struct {
00212 char name[XTRACT_MAX_NAME_LENGTH];
00213 char p_name[XTRACT_MAX_NAME_LENGTH];
00214 char desc[XTRACT_MAX_DESC_LENGTH];
00215 char p_desc[XTRACT_MAX_DESC_LENGTH];
00216 char author[XTRACT_MAX_AUTHOR_LENGTH];
00217 int year;
00218 } algo;
00219
00220 struct {
00221 xtract_vector_t format;
00222 xtract_unit_t unit;
00223 } data;
00224
00225 int argc;
00226
00227 struct {
00228 xtract_type_t type;
00229 float min[XTRACT_MAXARGS];
00230 float max[XTRACT_MAXARGS];
00231 float def[XTRACT_MAXARGS];
00232 xtract_unit_t unit[XTRACT_MAXARGS];
00233 int donor[XTRACT_MAXARGS];
00234 } argv;
00235
00236 xtract_bool_t is_scalar;
00237
00238
00239 union {
00240
00241 struct {
00242 float min;
00243 float max;
00244 xtract_unit_t unit;
00245 } scalar;
00246
00247 struct {
00248 xtract_vector_t format;
00249 xtract_unit_t unit;
00250 } vector;
00251
00252 } result;
00253
00254 } xtract_function_descriptor_t;
00255
00302 #ifdef XTRACT_H
00303 extern int(*xtract[XTRACT_FEATURES])(const float *data, const int N, const void *argv, float *result);
00304
00305 #endif
00306
00308 typedef struct xtract_mel_filter_ {
00309 int n_filters;
00310 float **filters;
00311 } xtract_mel_filter;
00312
00317 int xtract_init_mfcc(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, float **fft_tables);
00318
00327 int xtract_init_bark(int N, float sr, int *band_limits);
00328
00329
00330 void *xtract_make_descriptors();
00331
00332
00333 int xtract_free_descriptors(void *fd);
00334
00335
00338 #ifdef __cplusplus
00339 }
00340 #endif
00341
00342 #endif