diff options
author | Jamie Bullock <jamie@postlude.co.uk> | 2007-01-29 11:30:11 +0000 |
---|---|---|
committer | Jamie Bullock <jamie@postlude.co.uk> | 2007-01-29 11:30:11 +0000 |
commit | 592c723d7fe2dc8794182d6270a127e63f6e2973 (patch) | |
tree | 9359c33fef1c62ab5122df9281baeafa04f4353a | |
parent | 64d6de56068584a090e555abf49a16d6bdf97696 (diff) | |
download | LibXtract-592c723d7fe2dc8794182d6270a127e63f6e2973.tar.gz LibXtract-592c723d7fe2dc8794182d6270a127e63f6e2973.tar.bz2 LibXtract-592c723d7fe2dc8794182d6270a127e63f6e2973.zip |
Added namespacing to enumerations and defines. Made most macros private.
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | doc/documentation.doxygen.in | 2 | ||||
-rw-r--r-- | examples/puredata/xtract~.c | 48 | ||||
-rw-r--r-- | examples/simpletest/simpletest.c | 3 | ||||
-rw-r--r-- | src/delta.c | 8 | ||||
-rw-r--r-- | src/descriptors.c | 1114 | ||||
-rw-r--r-- | src/init.c | 10 | ||||
-rw-r--r-- | src/libxtract.c | 52 | ||||
-rw-r--r-- | src/scalar.c | 119 | ||||
-rw-r--r-- | src/vector.c | 93 | ||||
-rw-r--r-- | xtract/libxtract.h | 258 | ||||
-rw-r--r-- | xtract/xtract_delta.h | 4 | ||||
-rw-r--r-- | xtract/xtract_macros.h | 47 | ||||
-rw-r--r-- | xtract/xtract_scalar.h | 4 | ||||
-rw-r--r-- | xtract/xtract_types.h | 4 | ||||
-rw-r--r-- | xtract/xtract_vector.h | 4 |
16 files changed, 846 insertions, 926 deletions
diff --git a/configure.in b/configure.in index 2e8ef17..1c4f5a2 100644 --- a/configure.in +++ b/configure.in @@ -64,7 +64,7 @@ AC_ARG_ENABLE(simpletest, # age to 0. XTRACT_SO_VERSION=0:0:0 -CFLAGS="$CFLAGS -pedantic -ansi -Wall -Werror -std=c99" +CFLAGS="$CFLAGS -pedantic -ansi -Wall -Werror -std=c99 -I/usr/local/include" LDFLAGS="$LDFLAGS -lm" AC_ARG_WITH(pd_dir, diff --git a/doc/documentation.doxygen.in b/doc/documentation.doxygen.in index eca850d..c2f373e 100644 --- a/doc/documentation.doxygen.in +++ b/doc/documentation.doxygen.in @@ -1005,7 +1005,7 @@ INCLUDE_FILE_PATTERNS = # undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = XTRACT XTRACT_FFT +PREDEFINED = XTRACT_H XTRACT_FFT # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. diff --git a/examples/puredata/xtract~.c b/examples/puredata/xtract~.c index b89287f..df74ce7 100644 --- a/examples/puredata/xtract~.c +++ b/examples/puredata/xtract~.c @@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include <math.h> #include <string.h> -#define XTRACT #include "xtract/libxtract.h" #define BLOCKSIZE 1024 @@ -53,7 +52,7 @@ static t_int *xtract_perform(t_int *w) { return_code = xtract[x->feature]((float *)in, N, x->argv, &result); - if(return_code == FEATURE_NOT_IMPLEMENTED) + if(return_code == XTRACT_FEATURE_NOT_IMPLEMENTED) pd_error(x, "Feature not implemented"); /* set nan, inf or -inf to 0 */ @@ -76,7 +75,7 @@ static t_int *xtract_perform_vector(t_int *w) { return_code = xtract[x->feature](tmp_in, N, x->argv, tmp_out); - if(return_code == FEATURE_NOT_IMPLEMENTED) + if(return_code == XTRACT_FEATURE_NOT_IMPLEMENTED) pd_error(x, "Feature not implemented"); n = N; @@ -91,7 +90,7 @@ static t_int *xtract_perform_vector(t_int *w) { static void xtract_dsp(t_xtract_tilde *x, t_signal **sp) { - if(x->feature_type == VECTOR) + if(x->feature_type == XTRACT_VECTOR) dsp_add(xtract_perform_vector, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); @@ -106,7 +105,7 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) { xtract_mel_filter *mf; t_int n, N, f, F, n_args, type; t_float *argv_max; - t_function_descriptor *fd; + xtract_function_descriptor_t *fd; char *p_name, *p_desc, *author; int *year; @@ -123,7 +122,7 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) { tmp = atom_getsymbol(argv); /* get function descriptors */ - fd = (t_function_descriptor *)xtract_make_descriptors(); + fd = (xtract_function_descriptor_t *)xtract_make_descriptors(); /* iterate over descriptors */ while(f--){ @@ -143,15 +142,15 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) { argv_max = &fd[f].argv.max[n]; post("Argument %d, max: %.2f", n, *argv_max); } - if(type == MEL_FILTER){ + if(type == XTRACT_MEL_FILTER){ x->memory.argv = (size_t)(n_args * sizeof(xtract_mel_filter)); x->argv = (xtract_mel_filter *)getbytes(x->memory.argv); } - else if(type == INT){ + else if(type == XTRACT_INT){ x->memory.argv = (size_t)(n_args * sizeof(t_int)); x->argv = (t_int *)getbytes(x->memory.argv); } - else if (type == FLOAT){ + else if (type == XTRACT_FLOAT){ x->memory.argv = (size_t)(n_args * sizeof(t_float)); x->argv = (t_float *)getbytes(x->memory.argv); } @@ -178,42 +177,43 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) { /* do init if needed */ - if(x->feature == MFCC){ + if(x->feature == XTRACT_MFCC){ mf = x->argv; mf->n_filters = 20; - post("xtract~: mfcc: filters = %d", ((xtract_mel_filter *)x->argv)->n_filters); + post("xtract~: mfcc: filters = %d", + ((xtract_mel_filter *)x->argv)->n_filters); mf->filters = (t_float **)getbytes(mf->n_filters * sizeof(t_float *)); for(n = 0; n < mf->n_filters; n++) mf->filters[n] = (float *)getbytes(N * sizeof(float)); - xtract_init_mfcc(N, NYQUIST, EQUAL_GAIN, 18000.0f, + xtract_init_mfcc(N, NYQUIST, XTRACT_EQUAL_GAIN, 18000.0f, 80.0f, mf->n_filters, mf->filters); } - else if(x->feature == BARK_COEFFICIENTS) + else if(x->feature == XTRACT_BARK_COEFFICIENTS) xtract_init_bark(N, NYQUIST, x->argv); - if(x->feature == AUTOCORRELATION || x->feature == AUTOCORRELATION_FFT || - x->feature == MFCC || x->feature == AMDF || x->feature == ASDF|| - x->feature == DCT || x->feature == BARK_COEFFICIENTS || - x->feature == SPECTRUM || x->feature == PEAK_SPECTRUM || - x->feature == HARMONIC_SPECTRUM) - x->feature_type = VECTOR; + if(x->feature == XTRACT_AUTOCORRELATION || x->feature == XTRACT_AUTOCORRELATION_FFT || + x->feature == XTRACT_MFCC || x->feature == XTRACT_AMDF || x->feature == XTRACT_ASDF|| + x->feature == XTRACT_DCT || x->feature == XTRACT_BARK_COEFFICIENTS || + x->feature == XTRACT_SPECTRUM || x->feature == XTRACT_PEAK_SPECTRUM || + x->feature == XTRACT_HARMONIC_SPECTRUM) + x->feature_type = XTRACT_VECTOR; - else if (x->feature == FLUX || x->feature == ATTACK_TIME || - x->feature == DECAY_TIME || x->feature == DELTA) - x->feature_type = DELTA; + else if (x->feature == XTRACT_FLUX || x->feature == XTRACT_ATTACK_TIME || + x->feature == XTRACT_DECAY_TIME || x->feature == XTRACT_DELTA) + x->feature_type = XTRACT_DELTA; - else x->feature_type = SCALAR; + else x->feature_type = XTRACT_SCALAR; /* argv through right inlet */ inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("list")); /* if feature is vector, create signal out */ - if(x->feature_type == VECTOR) outlet_new(&x->x_obj, &s_signal); + if(x->feature_type == XTRACT_VECTOR) outlet_new(&x->x_obj, &s_signal); /* otherwise: float */ else outlet_new(&x->x_obj, &s_float); diff --git a/examples/simpletest/simpletest.c b/examples/simpletest/simpletest.c index 1ba066f..45df60a 100644 --- a/examples/simpletest/simpletest.c +++ b/examples/simpletest/simpletest.c @@ -16,7 +16,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define XTRACT #include "xtract/libxtract.h" #include <stdio.h> @@ -24,7 +23,7 @@ int main() { float mean = 0, vector[] = {1, 2, 3}; - xtract[MEAN]((void *)&vector, 3, NULL, (void *)&mean); + xtract[XTRACT_MEAN]((void *)&vector, 3, NULL, (void *)&mean); printf("\nThe mean of [1, 2, 3] = %.1f\n\n", mean); diff --git a/src/delta.c b/src/delta.c index 8766927..f1a5ee0 100644 --- a/src/delta.c +++ b/src/delta.c @@ -24,25 +24,25 @@ int xtract_flux(const float *data, const int N, const void *argv , float *result){ - return FEATURE_NOT_IMPLEMENTED; + return XTRACT_FEATURE_NOT_IMPLEMENTED; } int xtract_attack_time(const float *data, const int N, const void *argv , float *result){ - return FEATURE_NOT_IMPLEMENTED; + return XTRACT_FEATURE_NOT_IMPLEMENTED; } int xtract_decay_time(const float *data, const int N, const void *argv, float *result){ - return FEATURE_NOT_IMPLEMENTED; + return XTRACT_FEATURE_NOT_IMPLEMENTED; } int xtract_delta_feature(const float *data, const int N, const void *argv, float *result){ - return FEATURE_NOT_IMPLEMENTED; + return XTRACT_FEATURE_NOT_IMPLEMENTED; } diff --git a/src/descriptors.c b/src/descriptors.c index fb23303..c47ad60 100644 --- a/src/descriptors.c +++ b/src/descriptors.c @@ -19,26 +19,26 @@ */ #include "xtract/libxtract.h" +#include "xtract_macros_private.h" #include <stdlib.h> #include <string.h> #define XTRACT void *xtract_make_descriptors(){ - t_function_descriptor *fd, *d; - t_type *argv_type; int f , F; - char *name, *p_name, *desc, *p_desc, *author, *argv_donor; + char *name, *p_name, *desc, *p_desc, *author; float *argv_min, *argv_max, *argv_def, *result_min, *result_max; - int *argc, *year; - t_vector *data_format; - t_unit *data_unit, *argv_unit, *result_unit; - t_bool *is_scalar; - t_vector *result_format; + int *argc, *year, *argv_donor; + xtract_vector_t *data_format, *result_format; + xtract_unit_t *data_unit, *argv_unit, *result_unit; + xtract_bool_t *is_scalar; + xtract_function_descriptor_t *fd, *d; + xtract_type_t *argv_type; f = F = XTRACT_FEATURES; - fd = malloc(XTRACT_FEATURES * sizeof(t_function_descriptor)); + fd = malloc(XTRACT_FEATURES * sizeof(xtract_function_descriptor_t)); /* FIX - this file probably needs a rewrite for readability */ @@ -50,71 +50,71 @@ void *xtract_make_descriptors(){ switch(f){ - case VARIANCE: - case STANDARD_DEVIATION: - case AVERAGE_DEVIATION: - case SPECTRAL_VARIANCE: - case SPECTRAL_STANDARD_DEVIATION: - case SPECTRAL_AVERAGE_DEVIATION: - case SPECTRAL_INHARMONICITY: - case ODD_EVEN_RATIO: - case LOWEST_VALUE: - case F0: - case FAILSAFE_F0: - case TONALITY: + case XTRACT_VARIANCE: + case XTRACT_STANDARD_DEVIATION: + case XTRACT_AVERAGE_DEVIATION: + case XTRACT_SPECTRAL_VARIANCE: + case XTRACT_SPECTRAL_STANDARD_DEVIATION: + case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + case XTRACT_SPECTRAL_INHARMONICITY: + case XTRACT_ODD_EVEN_RATIO: + case XTRACT_LOWEST_VALUE: + case XTRACT_F0: + case XTRACT_FAILSAFE_F0: + case XTRACT_TONALITY: *argc = 1; - *argv_type = FLOAT; - break; - case SKEWNESS: - case KURTOSIS: - case SPECTRAL_SKEWNESS: - case SPECTRAL_KURTOSIS: - case SPECTRUM: - case PEAK_SPECTRUM: - case HARMONIC_SPECTRUM: - case NOISINESS: - case CREST: - case ROLLOFF: + *argv_type = XTRACT_FLOAT; + break; + case XTRACT_SKEWNESS: + case XTRACT_KURTOSIS: + case XTRACT_SPECTRAL_SKEWNESS: + case XTRACT_SPECTRAL_KURTOSIS: + case XTRACT_SPECTRUM: + case XTRACT_PEAK_SPECTRUM: + case XTRACT_HARMONIC_SPECTRUM: + case XTRACT_NOISINESS: + case XTRACT_CREST: + case XTRACT_ROLLOFF: *argc = 2; - *argv_type = FLOAT; + *argv_type = XTRACT_FLOAT; break; - case MFCC: + case XTRACT_MFCC: *argc = 1; - *argv_type = MEL_FILTER; - break; - case BARK_COEFFICIENTS: - *argc = BARK_BANDS; - *argv_type = INT; - break; - case MEAN: - case SPECTRAL_MEAN: - case SPECTRAL_CENTROID: - case IRREGULARITY_K: - case IRREGULARITY_J: - case TRISTIMULUS_1: - case TRISTIMULUS_2: - case TRISTIMULUS_3: - case SMOOTHNESS: - case FLATNESS: - case SPREAD: - case ZCR: - case LOUDNESS: - case HIGHEST_VALUE: - case SUM: - case RMS_AMPLITUDE: - case POWER: - case SHARPNESS: - case SPECTRAL_SLOPE: - case HPS: - case FLUX: - case ATTACK_TIME: - case DECAY_TIME: - case DELTA_FEATURE: - case AUTOCORRELATION_FFT: - case DCT: - case AUTOCORRELATION: - case AMDF: - case ASDF: + *argv_type = XTRACT_MEL_FILTER; + break; + case XTRACT_BARK_COEFFICIENTS: + *argc = XTRACT_BARK_BANDS; + *argv_type = XTRACT_INT; + break; + case XTRACT_MEAN: + case XTRACT_SPECTRAL_MEAN: + case XTRACT_SPECTRAL_CENTROID: + case XTRACT_IRREGULARITY_K: + case XTRACT_IRREGULARITY_J: + case XTRACT_TRISTIMULUS_1: + case XTRACT_TRISTIMULUS_2: + case XTRACT_TRISTIMULUS_3: + case XTRACT_SMOOTHNESS: + case XTRACT_FLATNESS: + case XTRACT_SPREAD: + case XTRACT_ZCR: + case XTRACT_LOUDNESS: + case XTRACT_HIGHEST_VALUE: + case XTRACT_SUM: + case XTRACT_RMS_AMPLITUDE: + case XTRACT_POWER: + case XTRACT_SHARPNESS: + case XTRACT_SPECTRAL_SLOPE: + case XTRACT_HPS: + case XTRACT_FLUX: + case XTRACT_ATTACK_TIME: + case XTRACT_DECAY_TIME: + case XTRACT_DELTA_FEATURE: + case XTRACT_AUTOCORRELATION_FFT: + case XTRACT_DCT: + case XTRACT_AUTOCORRELATION: + case XTRACT_AMDF: + case XTRACT_ASDF: default: *argc = 0; break; @@ -127,163 +127,163 @@ void *xtract_make_descriptors(){ switch (f) { /* argc = 1 */ - case VARIANCE: - case SPECTRAL_VARIANCE: - case STANDARD_DEVIATION: - case AVERAGE_DEVIATION: - case SPECTRAL_STANDARD_DEVIATION: - case SPECTRAL_AVERAGE_DEVIATION: - case LOWEST_VALUE: - case TONALITY: - case MFCC: - *argv_min = ANY; - *argv_max = ANY; - *argv_def = ANY; - *argv_unit = ANY; - case SPECTRAL_INHARMONICITY: - case ODD_EVEN_RATIO: + case XTRACT_VARIANCE: + case XTRACT_SPECTRAL_VARIANCE: + case XTRACT_STANDARD_DEVIATION: + case XTRACT_AVERAGE_DEVIATION: + case XTRACT_SPECTRAL_STANDARD_DEVIATION: + case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + case XTRACT_LOWEST_VALUE: + case XTRACT_TONALITY: + case XTRACT_MFCC: + *argv_min = XTRACT_ANY; + *argv_max = XTRACT_ANY; + *argv_def = XTRACT_ANY; + *argv_unit = XTRACT_ANY; + case XTRACT_SPECTRAL_INHARMONICITY: + case XTRACT_ODD_EVEN_RATIO: *argv_min = 0.f; - *argv_max = SR_UPPER_LIMIT / 2; - *argv_def = FUNDAMENTAL_DEFAULT; - *argv_unit = HERTZ; - case F0: - case FAILSAFE_F0: - *argv_min = SR_LOWER_LIMIT; - *argv_max = SR_UPPER_LIMIT; - *argv_def = SR_DEFAULT; - *argv_unit = HERTZ; + *argv_max = XTRACT_SR_UPPER_LIMIT / 2; + *argv_def = XTRACT_FUNDAMENTAL_DEFAULT; + *argv_unit = XTRACT_HERTZ; + case XTRACT_F0: + case XTRACT_FAILSAFE_F0: + *argv_min = XTRACT_SR_LOWER_LIMIT; + *argv_max = XTRACT_SR_UPPER_LIMIT; + *argv_def = XTRACT_SR_DEFAULT; + *argv_unit = XTRACT_HERTZ; /* argc = 2 */; - case ROLLOFF: - *argv_min = FFT_BANDS_MIN; - *argv_max = FFT_BANDS_MAX; - *argv_def = SPEC_BW_DEF ; - *argv_unit = HERTZ; + case XTRACT_ROLLOFF: + *argv_min = XTRACT_FFT_BANDS_MIN; + *argv_max = XTRACT_FFT_BANDS_MAX; + *argv_def = XTRACT_SPEC_BW_DEF ; + *argv_unit = XTRACT_HERTZ; *(argv_min + 1) = 0.f; *(argv_max + 1) = 100.f; *(argv_def + 1) = 95.f; - *(argv_unit + 1) = PERCENT; - case SPECTRUM: - *argv_min = SR_LOWER_LIMIT / 2; - *argv_max = SR_UPPER_LIMIT / 2; - *argv_def = SR_DEFAULT / 2; - *argv_unit = HERTZ; + *(argv_unit + 1) = XTRACT_PERCENT; + case XTRACT_SPECTRUM: + *argv_min = XTRACT_SR_LOWER_LIMIT / 2; + *argv_max = XTRACT_SR_UPPER_LIMIT / 2; + *argv_def = XTRACT_SR_DEFAULT / 2; + *argv_unit = XTRACT_HERTZ; *(argv_min + 1) = 0; *(argv_max + 1) = 3 ; *(argv_def + 1) = 0; - *(argv_unit + 1) = NONE; - case PEAK_SPECTRUM: - *argv_min = SR_LOWER_LIMIT / 2; - *argv_max = SR_UPPER_LIMIT / 2; - *argv_def = SR_DEFAULT / 2; - *argv_unit = HERTZ; + *(argv_unit + 1) = XTRACT_NONE; + case XTRACT_PEAK_SPECTRUM: + *argv_min = XTRACT_SR_LOWER_LIMIT / 2; + *argv_max = XTRACT_SR_UPPER_LIMIT / 2; + *argv_def = XTRACT_SR_DEFAULT / 2; + *argv_unit = XTRACT_HERTZ; *(argv_min + 1) = 0.f; *(argv_max + 1) = 100.f ; *(argv_def + 1) = 10.f ; - *(argv_unit + 1) = PERCENT; - case HARMONIC_SPECTRUM: + *(argv_unit + 1) = XTRACT_PERCENT; + case XTRACT_HARMONIC_SPECTRUM: *argv_min = 0.f; - *argv_max = SR_UPPER_LIMIT / 2; - *argv_def = FUNDAMENTAL_DEFAULT; - *argv_unit = HERTZ; + *argv_max = XTRACT_SR_UPPER_LIMIT / 2; + *argv_def = XTRACT_FUNDAMENTAL_DEFAULT; + *argv_unit = XTRACT_HERTZ; *(argv_min + 1) = 0.f; *(argv_max + 1) = 1.f ; *(argv_def + 1) = .1f ; - *(argv_unit + 1) = NONE; - case NOISINESS: - case SKEWNESS: - case KURTOSIS: - case SPECTRAL_SKEWNESS: - case SPECTRAL_KURTOSIS: - case CREST: - *argv_min = NONE; - *argv_max = NONE; - *argv_def = NONE; - *argv_unit = NONE; - *(argv_min + 1) = NONE; - *(argv_max + 1) = NONE; - *(argv_def + 1) = NONE; - *(argv_unit + 1) = NONE; - case BARK_COEFFICIENTS: + *(argv_unit + 1) = XTRACT_NONE; + case XTRACT_NOISINESS: + case XTRACT_SKEWNESS: + case XTRACT_KURTOSIS: + case XTRACT_SPECTRAL_SKEWNESS: + case XTRACT_SPECTRAL_KURTOSIS: + case XTRACT_CREST: + *argv_min = XTRACT_NONE; + *argv_max = XTRACT_NONE; + *argv_def = XTRACT_NONE; + *argv_unit = XTRACT_NONE; + *(argv_min + 1) = XTRACT_NONE; + *(argv_max + 1) = XTRACT_NONE; + *(argv_def + 1) = XTRACT_NONE; + *(argv_unit + 1) = XTRACT_NONE; + case XTRACT_BARK_COEFFICIENTS: /* BARK_COEFFICIENTS is special because argc = BARK_BANDS */ default: - *argv_min = NONE; - *argv_max = NONE; - *argv_def = NONE; - *argv_unit = NONE; + *argv_min = XTRACT_NONE; + *argv_max = XTRACT_NONE; + *argv_def = XTRACT_NONE; + *argv_unit = XTRACT_NONE; } argv_donor = &d->argv.donor[0]; switch (f) { /* argc = 1 */ - case VARIANCE: - *argv_donor = MEAN; + case XTRACT_VARIANCE: + *argv_donor = XTRACT_MEAN; break; - case SPECTRAL_VARIANCE: - *argv_donor = SPECTRAL_MEAN; + case XTRACT_SPECTRAL_VARIANCE: + *argv_donor = XTRACT_SPECTRAL_MEAN; break; - case STANDARD_DEVIATION: - *argv_donor = VARIANCE; + case XTRACT_STANDARD_DEVIATION: + *argv_donor = XTRACT_VARIANCE; break; - case AVERAGE_DEVIATION: - *argv_donor = MEAN; + case XTRACT_AVERAGE_DEVIATION: + *argv_donor = XTRACT_MEAN; break; - case SPECTRAL_STANDARD_DEVIATION: - *argv_donor = SPECTRAL_VARIANCE; + case XTRACT_SPECTRAL_STANDARD_DEVIATION: + *argv_donor = XTRACT_SPECTRAL_VARIANCE; break; - case SPECTRAL_AVERAGE_DEVIATION: - *argv_donor = SPECTRAL_MEAN; + case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + *argv_donor = XTRACT_SPECTRAL_MEAN; break; - case SPECTRAL_INHARMONICITY: - case ODD_EVEN_RATIO: - *argv_donor = FAILSAFE_F0; + case XTRACT_SPECTRAL_INHARMONICITY: + case XTRACT_ODD_EVEN_RATIO: + *argv_donor = XTRACT_FAILSAFE_F0; break; - case TONALITY: - *argv_donor = FLATNESS; + case XTRACT_TONALITY: + *argv_donor = XTRACT_FLATNESS; break; - case LOWEST_VALUE: - case F0: - case FAILSAFE_F0: - *argv_donor = ANY; + case XTRACT_LOWEST_VALUE: + case XTRACT_F0: + case XTRACT_FAILSAFE_F0: + *argv_donor = XTRACT_ANY; break; - case MFCC: - *argv_donor = INIT_MFCC; + case XTRACT_MFCC: + *argv_donor = XTRACT_INIT_MFCC; break; /* argc = 2 */; - case SPECTRUM: - case ROLLOFF: - case PEAK_SPECTRUM: - *argv_donor = ANY; - *(argv_donor + 1) = ANY; - break; - case SKEWNESS: - case KURTOSIS: - *argv_donor = MEAN; - *(argv_donor + 1) = STANDARD_DEVIATION; - break; - case SPECTRAL_SKEWNESS: - case SPECTRAL_KURTOSIS: - *argv_donor = SPECTRAL_MEAN; - *(argv_donor + 1) = SPECTRAL_STANDARD_DEVIATION; - break; - case HARMONIC_SPECTRUM: - *argv_donor = FAILSAFE_F0; - *(argv_donor + 1) = ANY; - break; - case NOISINESS: - *argv_donor = SUM; - *(argv_donor + 1) = SUM; - break; - case CREST: - *argv_donor = HIGHEST_VALUE; - *(argv_donor + 1) = SPECTRAL_MEAN; + case XTRACT_SPECTRUM: + case XTRACT_ROLLOFF: + case XTRACT_PEAK_SPECTRUM: + *argv_donor = XTRACT_ANY; + *(argv_donor + 1) = XTRACT_ANY; + break; + case XTRACT_SKEWNESS: + case XTRACT_KURTOSIS: + *argv_donor = XTRACT_MEAN; + *(argv_donor + 1) = XTRACT_STANDARD_DEVIATION; + break; + case XTRACT_SPECTRAL_SKEWNESS: + case XTRACT_SPECTRAL_KURTOSIS: + *argv_donor = XTRACT_SPECTRAL_MEAN; + *(argv_donor + 1) = XTRACT_SPECTRAL_STANDARD_DEVIATION; + break; + case XTRACT_HARMONIC_SPECTRUM: + *argv_donor = XTRACT_FAILSAFE_F0; + *(argv_donor + 1) = XTRACT_ANY; + break; + case XTRACT_NOISINESS: + *argv_donor = XTRACT_SUM; + *(argv_donor + 1) = XTRACT_SUM; + break; + case XTRACT_CREST: + *argv_donor = XTRACT_HIGHEST_VALUE; + *(argv_donor + 1) = XTRACT_SPECTRAL_MEAN; break; /* argc = BARK_BANDS */ - case BARK_COEFFICIENTS: - *argv_donor = INIT_BARK; + case XTRACT_BARK_COEFFICIENTS: + *argv_donor = XTRACT_INIT_BARK; break; default: - *argv_donor = ANY; + *argv_donor = XTRACT_ANY; break; } @@ -291,79 +291,79 @@ void *xtract_make_descriptors(){ switch(f){ - case MEAN: - case VARIANCE: - case STANDARD_DEVIATION: - case AVERAGE_DEVIATION: - case SKEWNESS: - case KURTOSIS: - case LOWEST_VALUE: - case HIGHEST_VALUE: - case SUM: - case ZCR: - *data_format = ARBITRARY_SERIES; - break; - case SPECTRAL_MEAN: - case SPECTRAL_VARIANCE: - case SPECTRAL_STANDARD_DEVIATION: - case SPECTRAL_AVERAGE_DEVIATION: - case SPECTRAL_SKEWNESS: - case SPECTRAL_KURTOSIS: - case SPECTRAL_CENTROID: - case SPECTRAL_SLOPE: - case PEAK_SPECTRUM: - case HARMONIC_SPECTRUM: - *data_format = SPECTRAL; - break; - case ROLLOFF: - case NOISINESS: - case BARK_COEFFICIENTS: - case CREST: - case IRREGULARITY_K: - case IRREGULARITY_J: - case SMOOTHNESS: - case FLATNESS: - case SPREAD: - case RMS_AMPLITUDE: - case POWER: - case SHARPNESS: - case HPS: - *data_format = SPECTRAL_MAGNITUDES; - break; - case SPECTRAL_INHARMONICITY: - *data_format = SPECTRAL_PEAKS; - break; - case ODD_EVEN_RATIO: - *data_format = SPECTRAL_HARMONICS_FREQUENCIES; - break; - case F0: - case FAILSAFE_F0: - case SPECTRUM: - case MFCC: - case AUTOCORRELATION: - case AUTOCORRELATION_FFT: - case DCT: - case AMDF: - case ASDF: - *data_format = AUDIO_SAMPLES; - break; - case TONALITY: - *data_format = NO_DATA; - break; - case TRISTIMULUS_1: - case TRISTIMULUS_2: - case TRISTIMULUS_3: - *data_format = SPECTRAL_HARMONICS_MAGNITUDES; - break; - case LOUDNESS: - *data_format = BARK_COEFFS; - break; - case FLUX: - case ATTACK_TIME: - case DECAY_TIME: - case DELTA_FEATURE: + case XTRACT_MEAN: + case XTRACT_VARIANCE: + case XTRACT_STANDARD_DEVIATION: + case XTRACT_AVERAGE_DEVIATION: + case XTRACT_SKEWNESS: + case XTRACT_KURTOSIS: + case XTRACT_LOWEST_VALUE: + case XTRACT_HIGHEST_VALUE: + case XTRACT_SUM: + case XTRACT_ZCR: + *data_format = XTRACT_ARBITRARY_SERIES; + break; + case XTRACT_SPECTRAL_MEAN: + case XTRACT_SPECTRAL_VARIANCE: + case XTRACT_SPECTRAL_STANDARD_DEVIATION: + case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + case XTRACT_SPECTRAL_SKEWNESS: + case XTRACT_SPECTRAL_KURTOSIS: + case XTRACT_SPECTRAL_CENTROID: + case XTRACT_SPECTRAL_SLOPE: + case XTRACT_PEAK_SPECTRUM: + case XTRACT_HARMONIC_SPECTRUM: + *data_format = XTRACT_SPECTRAL; + break; + case XTRACT_ROLLOFF: + case XTRACT_NOISINESS: + case XTRACT_BARK_COEFFICIENTS: + case XTRACT_CREST: + case XTRACT_IRREGULARITY_K: + case XTRACT_IRREGULARITY_J: + case XTRACT_SMOOTHNESS: + case XTRACT_FLATNESS: + case XTRACT_SPREAD: + case XTRACT_RMS_AMPLITUDE: + case XTRACT_POWER: + case XTRACT_SHARPNESS: + case XTRACT_HPS: + *data_format = XTRACT_SPECTRAL_MAGNITUDES; + break; + case XTRACT_SPECTRAL_INHARMONICITY: + *data_format = XTRACT_SPECTRAL_PEAKS; + break; + case XTRACT_ODD_EVEN_RATIO: + *data_format = XTRACT_SPECTRAL_HARMONICS_FREQUENCIES; + break; + case XTRACT_F0: + case XTRACT_FAILSAFE_F0: + case XTRACT_SPECTRUM: + case XTRACT_MFCC: + case XTRACT_AUTOCORRELATION: + case XTRACT_AUTOCORRELATION_FFT: + case XTRACT_DCT: + case XTRACT_AMDF: + case XTRACT_ASDF: + *data_format = XTRACT_AUDIO_SAMPLES; + break; + case XTRACT_TONALITY: + *data_format = XTRACT_NO_DATA; + break; + case XTRACT_TRISTIMULUS_1: + case XTRACT_TRISTIMULUS_2: + case XTRACT_TRISTIMULUS_3: + *data_format = XTRACT_SPECTRAL_HARMONICS_MAGNITUDES; + break; + case XTRACT_LOUDNESS: + *data_format = XTRACT_BARK_COEFFS; + break; + case XTRACT_FLUX: + case XTRACT_ATTACK_TIME: + case XTRACT_DECAY_TIME: + case XTRACT_DELTA_FEATURE: default: - *data_format = NO_DATA; + *data_format = XTRACT_NO_DATA; break; } @@ -371,64 +371,64 @@ void *xtract_make_descriptors(){ switch(f){ - case MEAN: - case VARIANCE: - case STANDARD_DEVIATION: - case AVERAGE_DEVIATION: - case SKEWNESS: - case KURTOSIS: - case LOWEST_VALUE: - case HIGHEST_VALUE: - case SUM: - case ZCR: - case PEAK_SPECTRUM: - case TRISTIMULUS_1: - case TRISTIMULUS_2: - case TRISTIMULUS_3: - case DCT: - case AMDF: - case ASDF: - case IRREGULARITY_K: - case IRREGULARITY_J: - case ATTACK_TIME: - case DECAY_TIME: - case DELTA_FEATURE: - case FLUX: - case F0: - case FAILSAFE_F0: - case MFCC: - case AUTOCORRELATION: - case AUTOCORRELATION_FFT: - case ROLLOFF: - case NOISINESS: - case CREST: - case FLATNESS: - case POWER: - case BARK_COEFFICIENTS: - case RMS_AMPLITUDE: - case SMOOTHNESS: - case SPREAD: - case SHARPNESS: - case HPS: - case SPECTRUM: - case TONALITY: - case LOUDNESS: - *data_unit = ANY; - break; - case SPECTRAL_MEAN: - case SPECTRAL_VARIANCE: - case SPECTRAL_STANDARD_DEVIATION: - case SPECTRAL_AVERAGE_DEVIATION: - case SPECTRAL_SKEWNESS: - case SPECTRAL_KURTOSIS: - case SPECTRAL_CENTROID: - case SPECTRAL_SLOPE: - case HARMONIC_SPECTRUM: - case SPECTRAL_INHARMONICITY: - *data_unit = ANY_AMPLITUDE_HERTZ; - break; - case ODD_EVEN_RATIO: - *data_unit = HERTZ; + case XTRACT_MEAN: + case XTRACT_VARIANCE: + case XTRACT_STANDARD_DEVIATION: + case XTRACT_AVERAGE_DEVIATION: + case XTRACT_SKEWNESS: + case XTRACT_KURTOSIS: + case XTRACT_LOWEST_VALUE: + case XTRACT_HIGHEST_VALUE: + case XTRACT_SUM: + case XTRACT_ZCR: + case XTRACT_PEAK_SPECTRUM: + case XTRACT_TRISTIMULUS_1: + case XTRACT_TRISTIMULUS_2: + case XTRACT_TRISTIMULUS_3: + case XTRACT_DCT: + case XTRACT_AMDF: + case XTRACT_ASDF: + case XTRACT_IRREGULARITY_K: + case XTRACT_IRREGULARITY_J: + case XTRACT_ATTACK_TIME: + case XTRACT_DECAY_TIME: + case XTRACT_DELTA_FEATURE: + case XTRACT_FLUX: + case XTRACT_F0: + case XTRACT_FAILSAFE_F0: + case XTRACT_MFCC: + case XTRACT_AUTOCORRELATION: + case XTRACT_AUTOCORRELATION_FFT: + case XTRACT_ROLLOFF: + case XTRACT_NOISINESS: + case XTRACT_CREST: + case XTRACT_FLATNESS: + case XTRACT_POWER: + case XTRACT_BARK_COEFFICIENTS: + case XTRACT_RMS_AMPLITUDE: + case XTRACT_SMOOTHNESS: + case XTRACT_SPREAD: + case XTRACT_SHARPNESS: + case XTRACT_HPS: + case XTRACT_SPECTRUM: + case XTRACT_TONALITY: + case XTRACT_LOUDNESS: + *data_unit = XTRACT_ANY; + break; + case XTRACT_SPECTRAL_MEAN: + case XTRACT_SPECTRAL_VARIANCE: + case XTRACT_SPECTRAL_STANDARD_DEVIATION: + case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + case XTRACT_SPECTRAL_SKEWNESS: + case XTRACT_SPECTRAL_KURTOSIS: + case XTRACT_SPECTRAL_CENTROID: + case XTRACT_SPECTRAL_SLOPE: + case XTRACT_HARMONIC_SPECTRUM: + case XTRACT_SPECTRAL_INHARMONICITY: + *data_unit = XTRACT_ANY_AMPLITUDE_HERTZ; + break; + case XTRACT_ODD_EVEN_RATIO: + *data_unit = XTRACT_HERTZ; break; } @@ -442,22 +442,22 @@ void *xtract_make_descriptors(){ *year = 0; switch(f){ - case MEAN: + case XTRACT_MEAN: strcpy(name, "mean"); strcpy(p_name, "Mean"); strcpy(desc, "Extract the mean of an input vector"); strcpy(p_desc, "Extract the mean of a range of values"); strcpy(author, ""); - d->argv.type = NONE; + d->argv.type = XTRACT_NONE; break; - case VARIANCE: + case XTRACT_VARIANCE: strcpy(name, "variance"); strcpy(p_name, "Variance"); strcpy(desc, "Extract the variance of an input vector"); strcpy(p_desc, "Extract the variance of a range of values"); strcpy(author, ""); break; - case STANDARD_DEVIATION: + case XTRACT_STANDARD_DEVIATION: strcpy(name, "standard_deviation"); strcpy(p_name, "Standard Deviation"); strcpy(desc, @@ -466,7 +466,7 @@ void *xtract_make_descriptors(){ "Extract the standard deviation of a range of values"); strcpy(author, ""); break; - case AVERAGE_DEVIATION: + case XTRACT_AVERAGE_DEVIATION: strcpy(name, "average_deviation"); strcpy(p_name, "Average Deviation"); strcpy(desc, @@ -475,21 +475,21 @@ void *xtract_make_descriptors(){ "Extract the average deviation of a range of values"); strcpy(author, ""); break; - case SPECTRAL_MEAN: + case XTRACT_SPECTRAL_MEAN: strcpy(name, "spectral_mean"); strcpy(p_name, "Spectral Mean"); strcpy(desc, "Extract the mean of an input spectrum"); strcpy(p_desc, "Extract the mean of an audio spectrum"); strcpy(author, ""); break; - case SPECTRAL_VARIANCE: + case XTRACT_SPECTRAL_VARIANCE: strcpy(name, "spectral_variance"); strcpy(p_name, "Spectral Variance"); strcpy(desc, "Extract the variance of an input spectrum"); strcpy(p_desc, "Extract the variance of an audio spectrum"); strcpy(author, ""); break; - case SPECTRAL_STANDARD_DEVIATION: + case XTRACT_SPECTRAL_STANDARD_DEVIATION: strcpy(name, "spectral_standard_deviation"); strcpy(p_name, "Spectral Standard Deviation"); strcpy(desc, @@ -498,7 +498,7 @@ void *xtract_make_descriptors(){ "Extract the standard deviation of an audio spectrum"); strcpy(author, ""); break; - case SPECTRAL_AVERAGE_DEVIATION: + case XTRACT_SPECTRAL_AVERAGE_DEVIATION: strcpy(name, "spectral_average_deviation"); strcpy(p_name, "Spectral Average Deviation"); strcpy(desc, @@ -507,7 +507,7 @@ void *xtract_make_descriptors(){ "Extract the average deviation of an audio spectrum"); strcpy(author, ""); break; - case ROLLOFF: + case XTRACT_ROLLOFF: strcpy(name, "spectral_rolloff"); strcpy(p_name, "Spectral Rolloff"); strcpy(desc, @@ -517,14 +517,14 @@ void *xtract_make_descriptors(){ strcpy(author, "Bee Suan Ong"); *year = 2005; break; - case SPECTRAL_INHARMONICITY: + case XTRACT_SPECTRAL_INHARMONICITY: strcpy(name, "spectral_inharmonicity"); strcpy(p_name, "Inharmonicity"); strcpy(desc, "Extract the inharmonicity of a spectrum"); strcpy(p_desc, "Extract the inharmonicity of an audio spectrum"); break; - case SPECTRUM: + case XTRACT_SPECTRUM: strcpy(name, "spectrum"); strcpy(p_name, "Spectrum"); strcpy(desc, @@ -533,7 +533,7 @@ void *xtract_make_descriptors(){ "Extract the spectrum of an audio signal"); strcpy(author, ""); break; - case ODD_EVEN_RATIO: + case XTRACT_ODD_EVEN_RATIO: strcpy(name, "odd_even_ratio"); strcpy(p_name, "Odd/Even Harmonic Ratio"); strcpy(desc, @@ -542,14 +542,14 @@ void *xtract_make_descriptors(){ "Extract the odd-to-even harmonic ratio of an audio spectrum"); strcpy(author, ""); break; - case LOWEST_VALUE: + case XTRACT_LOWEST_VALUE: strcpy(name, "lowest_value"); strcpy(p_name, "Lowest Value"); strcpy(desc, "Extract the lowest value from an input vector"); strcpy(p_desc, "Extract the lowest value from a given range"); strcpy(author, ""); break; - case F0: + case XTRACT_F0: strcpy(name, "f0"); strcpy(p_name, "Fundamental Frequency"); strcpy(desc, "Extract the fundamental frequency of a signal"); @@ -557,7 +557,7 @@ void *xtract_make_descriptors(){ "Extract the fundamental frequency of an audio signal"); strcpy(author, ""); break; - case FAILSAFE_F0: + case XTRACT_FAILSAFE_F0: strcpy(name, "failsafe_f0"); strcpy(p_name, "Fundamental Frequency (failsafe)"); strcpy(desc, "Extract the fundamental frequency of a signal"); @@ -565,7 +565,7 @@ void *xtract_make_descriptors(){ "Extract the fundamental frequency of an audio signal"); strcpy(author, ""); break; - case TONALITY: + case XTRACT_TONALITY: strcpy(name, "tonality"); strcpy(p_name, "Tonality"); strcpy(desc, "Extract the tonality of a spectrum"); @@ -573,21 +573,21 @@ void *xtract_make_descriptors(){ strcpy(author, "Tristan Jehan"); *year = 2005; break; - case SPECTRAL_SKEWNESS: + case XTRACT_SPECTRAL_SKEWNESS: strcpy(name, "spectral_skewness"); strcpy(p_name, "Spectral Skewness"); strcpy(desc, "Extract the skewness of an input spectrum"); strcpy(p_desc, "Extract the skewness of an audio spectrum"); strcpy(author, ""); break; - case SPECTRAL_KURTOSIS: + case XTRACT_SPECTRAL_KURTOSIS: strcpy(name, "spectral_kurtosis"); strcpy(p_name, "Spectral Kurtosis"); strcpy(desc, "Extract the kurtosis of an input spectrum"); strcpy(p_desc, "Extract the kurtosis of an audio spectrum"); strcpy(author, ""); break; - case PEAK_SPECTRUM: + case XTRACT_PEAK_SPECTRUM: strcpy(name, "peak_spectrum"); strcpy(p_name, "Peak Spectrum"); strcpy(desc, "Extract the spectral peaks from of a spectrum"); @@ -595,14 +595,14 @@ void *xtract_make_descriptors(){ "Extract the spectral peaks from an audio spectrum"); strcpy(author, ""); break; - case HARMONIC_SPECTRUM: + case XTRACT_HARMONIC_SPECTRUM: strcpy(p_name, "harmonic_spectrum"); strcpy(p_name, "Harmonic Spectrum"); strcpy(desc, "Extract the harmonics from a spectrum"); strcpy(p_desc, "Extract the harmonics from an audio spectrum"); strcpy(author, ""); break; - case NOISINESS: + case XTRACT_NOISINESS: strcpy(name, "noisiness"); strcpy(p_name, "Noisiness"); strcpy(desc, "Extract the noisiness of a spectrum"); @@ -610,7 +610,7 @@ void *xtract_make_descriptors(){ strcpy(author, "Tae Hong Park"); *year = 2000; break; - case CREST: + case XTRACT_CREST: strcpy(name, "crest"); strcpy(p_name, "Spectral Crest Measure"); strcpy(desc, @@ -620,14 +620,14 @@ void *xtract_make_descriptors(){ strcpy(author, "Peeters"); *year = 2003; break; - case MFCC: + case XTRACT_MFCC: strcpy(name, "mfcc"); strcpy(p_name, "Mel-Frequency Cepstral Coefficients"); strcpy(desc, "Extract MFCC from a spectrum"); strcpy(p_desc, "Extract MFCC from an audio spectrum"); strcpy(author, "Rabiner"); break; - case BARK_COEFFICIENTS: + case XTRACT_BARK_COEFFICIENTS: strcpy(name, "bark_coefficients"); strcpy(p_name, "Bark Coefficients"); strcpy(desc, "Extract bark coefficients from a spectrum"); @@ -635,7 +635,7 @@ void *xtract_make_descriptors(){ "Extract bark coefficients from an audio spectrum"); strcpy(author, ""); break; - case SPECTRAL_CENTROID: + case XTRACT_SPECTRAL_CENTROID: strcpy(name, "spectral_centroid"); strcpy(p_name, "Spectral Centroid"); strcpy(desc, "Extract the spectral centroid of a spectrum"); @@ -643,7 +643,7 @@ void *xtract_make_descriptors(){ "Extract the spectral centroid of an audio spectrum"); strcpy(author, ""); break; - case IRREGULARITY_K: + case XTRACT_IRREGULARITY_K: strcpy(name, "irregularity_k"); strcpy(p_name, "Irregularity I"); strcpy(desc, "Extract the irregularity of a spectrum"); @@ -652,7 +652,7 @@ void *xtract_make_descriptors(){ strcpy(author, "Krimphoff"); *year = 1994; break; - case IRREGULARITY_J: + case XTRACT_IRREGULARITY_J: strcpy(name, "irregularity_j"); strcpy(p_name, "Irregularity II"); strcpy(desc, "Extract the irregularity of a spectrum"); @@ -661,7 +661,7 @@ void *xtract_make_descriptors(){ strcpy(author, "Jensen"); *year = 1999; break; - case TRISTIMULUS_1: + case XTRACT_TRISTIMULUS_1: strcpy(name, "tristimulus_1"); strcpy(p_name, "Tristimulus I"); strcpy(desc, "Extract the tristimulus (type I) of a spectrum"); @@ -670,7 +670,7 @@ void *xtract_make_descriptors(){ strcpy(author, "Pollard and Jansson"); *year = 1982; break; - case TRISTIMULUS_2: + case XTRACT_TRISTIMULUS_2: strcpy(name, "tristimulus_2"); strcpy(p_name, "Tristimulus II"); strcpy(desc, "Extract the tristimulus (type II) of a spectrum"); @@ -679,7 +679,7 @@ void *xtract_make_descriptors(){ strcpy(author, "Pollard and Jansson"); *year = 1982; break; - case TRISTIMULUS_3: + case XTRACT_TRISTIMULUS_3: strcpy(name, "tristimulus_3"); strcpy(p_name, "Tristimulus III"); strcpy(desc, @@ -689,7 +689,7 @@ void *xtract_make_descriptors(){ strcpy(author, "Pollard and Jansson"); *year = 1982; break; - case SMOOTHNESS: + case XTRACT_SMOOTHNESS: strcpy(name, "smoothness"); strcpy(p_name, "Spectral Smoothness"); strcpy(desc, "Extract the spectral smoothness of a spectrum"); @@ -698,7 +698,7 @@ void *xtract_make_descriptors(){ strcpy(author, "McAdams"); *year = 1999; break; - case FLATNESS: + case XTRACT_FLATNESS: strcpy(name, "flatness"); strcpy(p_name, "Spectral Flatness"); strcpy(desc, "Extract the spectral flatness of a spectrum"); @@ -707,7 +707,7 @@ void *xtract_make_descriptors(){ strcpy(author, "Tristan Jehan"); *year = 2005; break; - case SPREAD: + case XTRACT_SPREAD: strcpy(name, "spread"); strcpy(p_name, "Spectral Spread"); strcpy(desc, "Extract the spectral spread of a spectrum"); @@ -716,7 +716,7 @@ void *xtract_make_descriptors(){ strcpy(author, "Norman Casagrande"); *year = 2005; break; - case ZCR: + case XTRACT_ZCR: strcpy(name, "zcr"); strcpy(p_name, "Zero Crossing Rate"); strcpy(desc, "Extract the zero crossing rate of a vector"); @@ -724,7 +724,7 @@ void *xtract_make_descriptors(){ "Extract the zero crossing rate of an audio signal"); strcpy(author, ""); break; - case LOUDNESS: + case XTRACT_LOUDNESS: strcpy(name, "loudness"); strcpy(p_name, "Loudness"); strcpy(desc, @@ -734,14 +734,14 @@ void *xtract_make_descriptors(){ strcpy(author, "Moore, Glasberg et al"); *year = 2005; break; - case HIGHEST_VALUE: + case XTRACT_HIGHEST_VALUE: strcpy(name, "highest_value"); strcpy(p_name, "Highest Value"); strcpy(desc, "Extract the highest value from an input vector"); strcpy(p_desc, "Extract the highest value from a given range"); strcpy(author, ""); break; - case SUM: + case XTRACT_SUM: strcpy(name, "sum"); strcpy(p_name, "Sum of Values"); strcpy(desc, @@ -750,14 +750,14 @@ void *xtract_make_descriptors(){ "Extract the sum of the values in a given range"); strcpy(author, ""); break; - case RMS_AMPLITUDE: + case XTRACT_RMS_AMPLITUDE: strcpy(name, "rms_amplitude"); strcpy(p_name, "RMS Amplitude"); strcpy(desc, "Extract the RMS amplitude of a signal"); strcpy(p_desc, "Extract the RMS amplitude of an audio signal"); strcpy(author, ""); break; - case POWER: + case XTRACT_POWER: strcpy(name, "power"); strcpy(p_name, "Spectral Power"); strcpy(desc, "Extract the spectral power of a spectrum"); @@ -766,7 +766,7 @@ void *xtract_make_descriptors(){ strcpy(author, "Bee Suan Ong"); *year = 2005; break; - case SHARPNESS: + case XTRACT_SHARPNESS: strcpy(name, "sharpness"); strcpy(p_name, "Spectral Sharpness"); strcpy(desc, "Extract the spectral sharpness of a spectrum"); @@ -774,7 +774,7 @@ void *xtract_make_descriptors(){ "Extract the spectral sharpness of an audio spectrum"); strcpy(author, ""); break; - case SPECTRAL_SLOPE: + case XTRACT_SPECTRAL_SLOPE: strcpy(name, "spectral_slope"); strcpy(p_name, "Spectral Slope"); strcpy(desc, "Extract the spectral slope of a spectrum"); @@ -782,7 +782,7 @@ void *xtract_make_descriptors(){ "Extract the spectral slope of an audio spectrum"); strcpy(author, ""); break; - case HPS: + case XTRACT_HPS: strcpy(name, "hps"); strcpy(p_name, "Harmonic Product Spectrum"); strcpy(desc, @@ -791,7 +791,7 @@ void *xtract_make_descriptors(){ "Extract the harmonic product spectrum of an audio spectrum"); strcpy(author, ""); break; - case FLUX: + case XTRACT_FLUX: strcpy(name, "flux"); strcpy(p_name, "Spectral Flux"); strcpy(desc, "Extract the spectral flux of a spectrum"); @@ -799,42 +799,42 @@ void *xtract_make_descriptors(){ "Extract the spectral flux of an audio spectrum"); strcpy(author, ""); break; - case ATTACK_TIME: + case XTRACT_ATTACK_TIME: strcpy(name, "attack_time"); strcpy(p_name, "Attack Time"); strcpy(desc, "Extract the attack time of a signal"); strcpy(p_desc, "Extract the attack time of an audio signal"); strcpy(author, ""); break; - case DECAY_TIME: + case XTRACT_DECAY_TIME: strcpy(name, "decay_time"); strcpy(p_name, "Decay Time"); strcpy(desc, "Extract the decay time of a signal"); strcpy(p_desc, "Extract the decay time of an audio signal"); strcpy(author, ""); break; - case DELTA_FEATURE: + case XTRACT_DELTA_FEATURE: strcpy(name, "delta_feature"); strcpy(p_name, "Delta Feature"); strcpy(desc, "Extract the time derivative of a feature"); strcpy(p_desc, "Extract the time derivative of a feature"); strcpy(author, ""); break; - case AUTOCORRELATION_FFT: + case XTRACT_AUTOCORRELATION_FFT: strcpy(name, "autocorrelation_fft"); strcpy(p_name, "Autocorrelation (FFT method)"); strcpy(desc, "Extract the autocorrelation of a signal"); strcpy(p_desc, "Extract the autocorrelation of an audio signal"); strcpy(author, ""); break; - case DCT: + case XTRACT_DCT: strcpy(name, "dct"); strcpy(p_name, "Discrete Cosine Transform"); strcpy(desc, "Extract the DCT of a signal"); strcpy(p_desc, "Extract the DCT of an audio signal"); strcpy(author, ""); break; - case AUTOCORRELATION: + case XTRACT_AUTOCORRELATION: strcpy(name, "autocorrelation"); strcpy(p_name, "Autocorrelation"); strcpy(desc, "Extract the autocorrelation of a signal"); @@ -842,14 +842,14 @@ void *xtract_make_descriptors(){ "Extract the autocorrelation of an audio signal"); strcpy(author, ""); break; - case AMDF: + case XTRACT_AMDF: strcpy(name, "amdf"); strcpy(p_name, "Average Magnitude Difference Function"); strcpy(desc, "Extract the AMDF of a signal"); strcpy(p_desc, "Extract the AMDF of an audio signal"); strcpy(author, ""); break; - case ASDF: + case XTRACT_ASDF: strcpy(name, "asdf"); strcpy(p_name, "Average Squared Difference Function"); strcpy(desc, "Extract the ASDF of a signal"); @@ -868,71 +868,71 @@ void *xtract_make_descriptors(){ switch(f){ - case VARIANCE: - case STANDARD_DEVIATION: - case AVERAGE_DEVIATION: - case SPECTRAL_VARIANCE: - case SPECTRAL_STANDARD_DEVIATION: - case SPECTRAL_AVERAGE_DEVIATION: - case SPECTRAL_INHARMONICITY: - case ODD_EVEN_RATIO: - case LOWEST_VALUE: - case F0: - case FAILSAFE_F0: - case TONALITY: + case XTRACT_VARIANCE: + case XTRACT_STANDARD_DEVIATION: + case XTRACT_AVERAGE_DEVIATION: + case XTRACT_SPECTRAL_VARIANCE: + case XTRACT_SPECTRAL_STANDARD_DEVIATION: + case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + case XTRACT_SPECTRAL_INHARMONICITY: + case XTRACT_ODD_EVEN_RATIO: + case XTRACT_LOWEST_VALUE: + case XTRACT_F0: + case XTRACT_FAILSAFE_F0: + case XTRACT_TONALITY: *argc = 1; - *argv_type = FLOAT; - break; - case SKEWNESS: - case KURTOSIS: - case SPECTRAL_SKEWNESS: - case SPECTRAL_KURTOSIS: - case SPECTRUM: - case PEAK_SPECTRUM: - case HARMONIC_SPECTRUM: - case NOISINESS: - case CREST: - case ROLLOFF: + *argv_type = XTRACT_FLOAT; + break; + case XTRACT_SKEWNESS: + case XTRACT_KURTOSIS: + case XTRACT_SPECTRAL_SKEWNESS: + case XTRACT_SPECTRAL_KURTOSIS: + case XTRACT_SPECTRUM: + case XTRACT_PEAK_SPECTRUM: + case XTRACT_HARMONIC_SPECTRUM: + case XTRACT_NOISINESS: + case XTRACT_CREST: + case XTRACT_ROLLOFF: *argc = 2; - *argv_type = FLOAT; + *argv_type = XTRACT_FLOAT; break; - case MFCC: + case XTRACT_MFCC: *argc = 1; - *argv_type = MEL_FILTER; - break; - case BARK_COEFFICIENTS: - *argc = BARK_BANDS; - *argv_type = INT; - break; - case MEAN: - case SPECTRAL_MEAN: - case SPECTRAL_CENTROID: - case IRREGULARITY_K: - case IRREGULARITY_J: - case TRISTIMULUS_1: - case TRISTIMULUS_2: - case TRISTIMULUS_3: - case SMOOTHNESS: - case FLATNESS: - case SPREAD: - case ZCR: - case LOUDNESS: - case HIGHEST_VALUE: - case SUM: - case RMS_AMPLITUDE: - case POWER: - case SHARPNESS: - case SPECTRAL_SLOPE: - case HPS: - case FLUX: - case ATTACK_TIME: - case DECAY_TIME: - case DELTA_FEATURE: - case AUTOCORRELATION_FFT: - case DCT: - case AUTOCORRELATION: - case AMDF: - case ASDF: + *argv_type = XTRACT_MEL_FILTER; + break; + case XTRACT_BARK_COEFFICIENTS: + *argc = XTRACT_BARK_BANDS; + *argv_type = XTRACT_INT; + break; + case XTRACT_MEAN: + case XTRACT_SPECTRAL_MEAN: + case XTRACT_SPECTRAL_CENTROID: + case XTRACT_IRREGULARITY_K: + case XTRACT_IRREGULARITY_J: + case XTRACT_TRISTIMULUS_1: + case XTRACT_TRISTIMULUS_2: + case XTRACT_TRISTIMULUS_3: + case XTRACT_SMOOTHNESS: + case XTRACT_FLATNESS: + case XTRACT_SPREAD: + case XTRACT_ZCR: + case XTRACT_LOUDNESS: + case XTRACT_HIGHEST_VALUE: + case XTRACT_SUM: + case XTRACT_RMS_AMPLITUDE: + case XTRACT_POWER: + case XTRACT_SHARPNESS: + case XTRACT_SPECTRAL_SLOPE: + case XTRACT_HPS: + case XTRACT_FLUX: + case XTRACT_ATTACK_TIME: + case XTRACT_DECAY_TIME: + case XTRACT_DELTA_FEATURE: + case XTRACT_AUTOCORRELATION_FFT: + case XTRACT_DCT: + case XTRACT_AUTOCORRELATION: + case XTRACT_AMDF: + case XTRACT_ASDF: default: *argc = 0; break; @@ -941,61 +941,61 @@ void *xtract_make_descriptors(){ is_scalar = &d->is_scalar; switch(f){ - case MEAN: - case VARIANCE: - case STANDARD_DEVIATION: - case AVERAGE_DEVIATION: - case SKEWNESS: - case KURTOSIS: - case SPECTRAL_MEAN: - case SPECTRAL_VARIANCE: - case SPECTRAL_STANDARD_DEVIATION: - case SPECTRAL_AVERAGE_DEVIATION: - case SPECTRAL_SKEWNESS: - case SPECTRAL_KURTOSIS: - case SPECTRAL_CENTROID: - case IRREGULARITY_K: - case IRREGULARITY_J: - case TRISTIMULUS_1: - case TRISTIMULUS_2: - case TRISTIMULUS_3: - case SMOOTHNESS: - case SPREAD: - case ZCR: - case ROLLOFF: - case LOUDNESS: - case FLATNESS: - case TONALITY: - case CREST: - case NOISINESS: - case RMS_AMPLITUDE: - case SPECTRAL_INHARMONICITY: - case POWER: - case ODD_EVEN_RATIO: - case SHARPNESS: - case SPECTRAL_SLOPE: - case LOWEST_VALUE: - case HIGHEST_VALUE: - case SUM: - case HPS: - case F0: - case FAILSAFE_F0: - *is_scalar = TRUE; - break; - case AUTOCORRELATION: - case AMDF: - case ASDF: - case BARK_COEFFICIENTS: - case PEAK_SPECTRUM: - case SPECTRUM: - case AUTOCORRELATION_FFT: - case MFCC: - case DCT: - case HARMONIC_SPECTRUM: - *is_scalar = FALSE; + case XTRACT_MEAN: + case XTRACT_VARIANCE: + case XTRACT_STANDARD_DEVIATION: + case XTRACT_AVERAGE_DEVIATION: + case XTRACT_SKEWNESS: + case XTRACT_KURTOSIS: + case XTRACT_SPECTRAL_MEAN: + case XTRACT_SPECTRAL_VARIANCE: + case XTRACT_SPECTRAL_STANDARD_DEVIATION: + case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + case XTRACT_SPECTRAL_SKEWNESS: + case XTRACT_SPECTRAL_KURTOSIS: + case XTRACT_SPECTRAL_CENTROID: + case XTRACT_IRREGULARITY_K: + case XTRACT_IRREGULARITY_J: + case XTRACT_TRISTIMULUS_1: + case XTRACT_TRISTIMULUS_2: + case XTRACT_TRISTIMULUS_3: + case XTRACT_SMOOTHNESS: + case XTRACT_SPREAD: + case XTRACT_ZCR: + case XTRACT_ROLLOFF: + case XTRACT_LOUDNESS: + case XTRACT_FLATNESS: + case XTRACT_TONALITY: + case XTRACT_CREST: + case XTRACT_NOISINESS: + case XTRACT_RMS_AMPLITUDE: + case XTRACT_SPECTRAL_INHARMONICITY: + case XTRACT_POWER: + case XTRACT_ODD_EVEN_RATIO: + case XTRACT_SHARPNESS: + case XTRACT_SPECTRAL_SLOPE: + case XTRACT_LOWEST_VALUE: + case XTRACT_HIGHEST_VALUE: + case XTRACT_SUM: + case XTRACT_HPS: + case XTRACT_F0: + case XTRACT_FAILSAFE_F0: + *is_scalar = XTRACT_TRUE; + break; + case XTRACT_AUTOCORRELATION: + case XTRACT_AMDF: + case XTRACT_ASDF: + case XTRACT_BARK_COEFFICIENTS: + case XTRACT_PEAK_SPECTRUM: + case XTRACT_SPECTRUM: + case XTRACT_AUTOCORRELATION_FFT: + case XTRACT_MFCC: + case XTRACT_DCT: + case XTRACT_HARMONIC_SPECTRUM: + *is_scalar = XTRACT_FALSE; break; default: - *is_scalar = TRUE; + *is_scalar = XTRACT_TRUE; break; } @@ -1007,66 +1007,66 @@ void *xtract_make_descriptors(){ result_max = &d->result.scalar.max; switch(f){ - case MEAN: - case VARIANCE: - case STANDARD_DEVIATION: - case AVERAGE_DEVIATION: - case SKEWNESS: - case KURTOSIS: - case RMS_AMPLITUDE: - case LOWEST_VALUE: - case HIGHEST_VALUE: - case SUM: - *result_unit = ANY; - *result_min = ANY; - *result_max = ANY; + case XTRACT_MEAN: + case XTRACT_VARIANCE: + case XTRACT_STANDARD_DEVIATION: + case XTRACT_AVERAGE_DEVIATION: + case XTRACT_SKEWNESS: + case XTRACT_KURTOSIS: + case XTRACT_RMS_AMPLITUDE: + case XTRACT_LOWEST_VALUE: + case XTRACT_HIGHEST_VALUE: + case XTRACT_SUM: + *result_unit = XTRACT_ANY; + *result_min = XTRACT_ANY; + *result_max = XTRACT_ANY; break; - case SPECTRAL_SKEWNESS: - case SPECTRAL_KURTOSIS: - case IRREGULARITY_K: - case IRREGULARITY_J: - case TRISTIMULUS_1: - case TRISTIMULUS_2: - case TRISTIMULUS_3: - case NOISINESS: - case SMOOTHNESS: - *result_unit = NONE; - *result_min = ANY; /* FIX: need to check these */ - *result_max = ANY; + case XTRACT_SPECTRAL_SKEWNESS: + case XTRACT_SPECTRAL_KURTOSIS: + case XTRACT_IRREGULARITY_K: + case XTRACT_IRREGULARITY_J: + case XTRACT_TRISTIMULUS_1: + case XTRACT_TRISTIMULUS_2: + case XTRACT_TRISTIMULUS_3: + case XTRACT_NOISINESS: + case XTRACT_SMOOTHNESS: + *result_unit = XTRACT_NONE; + *result_min = XTRACT_ANY; /* FIX: need to check these */ + *result_max = XTRACT_ANY; break; - case SPECTRAL_MEAN: - case SPECTRAL_VARIANCE: - case SPECTRAL_STANDARD_DEVIATION: - case SPECTRAL_AVERAGE_DEVIATION: - case SPECTRAL_CENTROID: - case SPREAD: - case F0: - case FAILSAFE_F0: - case HPS: - case ROLLOFF: - *result_unit = HERTZ; + case XTRACT_SPECTRAL_MEAN: + case XTRACT_SPECTRAL_VARIANCE: + case XTRACT_SPECTRAL_STANDARD_DEVIATION: + case XTRACT_SPECTRAL_AVERAGE_DEVIATION: + case XTRACT_SPECTRAL_CENTROID: + case XTRACT_SPREAD: + case XTRACT_F0: + case XTRACT_FAILSAFE_F0: + case XTRACT_HPS: + case XTRACT_ROLLOFF: + *result_unit = XTRACT_HERTZ; *result_min = 0.f; - *result_max = SR_UPPER_LIMIT / 2; - case ZCR: - *result_unit = HERTZ; + *result_max = XTRACT_SR_UPPER_LIMIT / 2; + case XTRACT_ZCR: + *result_unit = XTRACT_HERTZ; *result_min = 0.f; - *result_max = ANY; - case ODD_EVEN_RATIO: - *result_unit = NONE; + *result_max = XTRACT_ANY; + case XTRACT_ODD_EVEN_RATIO: + *result_unit = XTRACT_NONE; *result_min = 0.f; *result_max = 1.f; - case LOUDNESS: - case FLATNESS: - case TONALITY: - case CREST: - case SPECTRAL_INHARMONICITY: - case POWER: - case SHARPNESS: - case SPECTRAL_SLOPE: + case XTRACT_LOUDNESS: + case XTRACT_FLATNESS: + case XTRACT_TONALITY: + case XTRACT_CREST: + case XTRACT_SPECTRAL_INHARMONICITY: + case XTRACT_POWER: + case XTRACT_SHARPNESS: + case XTRACT_SPECTRAL_SLOPE: default: - *result_unit = UNKNOWN; - *result_min = UNKNOWN; - *result_max = UNKNOWN; + *result_unit = XTRACT_UNKNOWN; + *result_min = XTRACT_UNKNOWN; + *result_max = XTRACT_UNKNOWN; } } else { @@ -1077,24 +1077,24 @@ void *xtract_make_descriptors(){ result_format = &d->result.vector.format; switch(f) { - case AUTOCORRELATION: - case AMDF: - case ASDF: - case DCT: - *result_format = ARBITRARY_SERIES; - *result_unit = ANY; - case BARK_COEFFICIENTS: - *result_format = BARK_COEFFS; - *result_unit = UNKNOWN; /* FIX: check */ - case PEAK_SPECTRUM: - case SPECTRUM: - case HARMONIC_SPECTRUM: - *result_format = SPECTRAL; - *result_unit = ANY_AMPLITUDE_HERTZ; - case AUTOCORRELATION_FFT: - case MFCC: - *result_format = MEL_COEFFS; - *result_unit = UNKNOWN; /* FIX: check */ + case XTRACT_AUTOCORRELATION: + case XTRACT_AMDF: + case XTRACT_ASDF: + case XTRACT_DCT: + *result_format = XTRACT_ARBITRARY_SERIES; + *result_unit = XTRACT_ANY; + case XTRACT_BARK_COEFFICIENTS: + *result_format = XTRACT_BARK_COEFFS; + *result_unit = XTRACT_UNKNOWN; /* FIX: check */ + case XTRACT_PEAK_SPECTRUM: + case XTRACT_SPECTRUM: + case XTRACT_HARMONIC_SPECTRUM: + *result_format = XTRACT_SPECTRAL; + *result_unit = XTRACT_ANY_AMPLITUDE_HERTZ; + case XTRACT_AUTOCORRELATION_FFT: + case XTRACT_MFCC: + *result_format = XTRACT_MEL_COEFFS; + *result_unit = XTRACT_UNKNOWN; /* FIX: check */ default: break; } @@ -1110,7 +1110,7 @@ int xtract_free_descriptors(void *fd){ free(fd); } - return SUCCESS; + return XTRACT_SUCCESS; } @@ -46,7 +46,7 @@ int xtract_init_mfcc(int N, float nyquist, int style, float freq_min, float freq if(mel_peak == NULL || height_norm == NULL || lin_peak == NULL || fft_peak == NULL) - return MALLOC_FAILED; + return XTRACT_MALLOC_FAILED; M = N >> 1; @@ -64,7 +64,7 @@ int xtract_init_mfcc(int N, float nyquist, int style, float freq_min, float freq for (n = 0; n < freq_bands; n++){ /*roll out normalised gain of each peak*/ - if (style == EQUAL_GAIN){ + if (style == XTRACT_EQUAL_GAIN){ height = 1; norm_fact = norm; } @@ -118,7 +118,7 @@ int xtract_init_mfcc(int N, float nyquist, int style, float freq_min, float freq free(height_norm); free(fft_peak); - return SUCCESS; + return XTRACT_SUCCESS; } @@ -126,7 +126,7 @@ int xtract_init_bark(int N, float nyquist, int *band_limits){ float edges[] = {0, 100, 200, 300, 400, 510, 630, 770, 920, 1080, 1270, 1480, 1720, 2000, 2320, 2700, 3150, 3700, 4400, 5300, 6400, 7700, 9500, 12000, 15500, 20500, 27000}; /* Takes us up to sr = 54kHz (CCRMA: JOS)*/ - int M, bands = BARK_BANDS; + int M, bands = XTRACT_BARK_BANDS; M = N >> 1; @@ -134,5 +134,5 @@ int xtract_init_bark(int N, float nyquist, int *band_limits){ band_limits[bands] = edges[bands] / nyquist * M; /*FIX shohuld use rounding, but couldn't get it to work */ - return SUCCESS; + return XTRACT_SUCCESS; } diff --git a/src/libxtract.c b/src/libxtract.c index 48fc2ab..7028486 100644 --- a/src/libxtract.c +++ b/src/libxtract.c @@ -20,7 +20,7 @@ #include "xtract/libxtract.h" -#define XTRACT +#define XTRACT_H int(*xtract[])(const float *, const int, const void *, float *) = { /* xtract_scalar.h */ @@ -81,53 +81,3 @@ int(*xtract[])(const float *, const int, const void *, float *) = { xtract_harmonic_spectrum }; - -/*char *xtract_help_strings[] = { - "xtract_mean", - "xtract_variance", - "xtract_standard_deviation", - "xtract_average_deviation", - "xtract_skewness", - "xtract_kurtosis", - "xtract_centroid", - "xtract_irregularity_k", - "xtract_irregularity_j", - "xtract_tristimulus_1", - "xtract_tristimulus_2", - "xtract_tristimulus_3", - "xtract_smoothness", - "xtract_spread", - "xtract_zcr", - "xtract_rolloff", - "xtract_loudness", - "xtract_flatness", - "xtract_tonality", - "xtract_crest", - "xtract_noisiness", - "xtract_rms_amplitude", - "xtract_inharmonicity", - "xtract_power", - "xtract_odd_even_ratio", - "xtract_sharpness", - "xtract_slope", - "xtract_lowest_value", - "xtract_highest_value", - "xtract_sum", - "xtract_hps", - "xtract_f0", - "xtract_failsafe_f0", - "xtract_flux", - "xtract_attack_time", - "xtract_decay_time", - "xtract_delta_feature", - "xtract_autocorrelation", - "xtract_amdf", - "xtract_asdf", - "xtract_bark_coefficients", - "xtract_peaks", - "xtract_magnitude_spectrum", - "xtract_autocorrelation_fft", - "xtract_mfcc", - "xtract_dct", - "xtract_harmonics" - }; */ diff --git a/src/scalar.c b/src/scalar.c index 68b5b19..b34818f 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -22,6 +22,7 @@ /* xtract_scalar.c: defines functions that extract a feature as a single value from an input vector */ #include "xtract/libxtract.h" +#include "xtract_macros_private.h" #include "math.h" #include <stdlib.h> #include <string.h> @@ -35,7 +36,7 @@ int xtract_mean(const float *data, const int N, const void *argv, float *result) *result /= N; - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_variance(const float *data, const int N, const void *argv, float *result){ @@ -47,14 +48,14 @@ int xtract_variance(const float *data, const int N, const void *argv, float *res *result = *result / (N - 1); - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_standard_deviation(const float *data, const int N, const void *argv, float *result){ *result = sqrt(*(float *)argv); - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_average_deviation(const float *data, const int N, const void *argv, float *result){ @@ -66,7 +67,7 @@ int xtract_average_deviation(const float *data, const int N, const void *argv, f *result /= N; - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_skewness(const float *data, const int N, const void *argv, float *result){ @@ -82,7 +83,7 @@ int xtract_skewness(const float *data, const int N, const void *argv, float *re *result /= N; - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_kurtosis(const float *data, const int N, const void *argv, float *result){ @@ -99,7 +100,7 @@ int xtract_kurtosis(const float *data, const int N, const void *argv, float *re *result /= N; *result -= 3.0f; - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_spectral_centroid(const float *data, const int N, const void *argv, float *result){ @@ -119,7 +120,7 @@ int xtract_spectral_centroid(const float *data, const int N, const void *argv, *result = FA / A; - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_spectral_mean(const float *data, const int N, const void *argv, float *result){ @@ -146,14 +147,14 @@ int xtract_spectral_variance(const float *data, const int N, const void *argv, f *result = *result / (A - 1); - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_spectral_standard_deviation(const float *data, const int N, const void *argv, float *result){ *result = sqrt(*(float *)argv); - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_spectral_average_deviation(const float *data, const int N, const void *argv, float *result){ @@ -174,7 +175,7 @@ int xtract_spectral_average_deviation(const float *data, const int N, const void *result /= A; - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_spectral_skewness(const float *data, const int N, const void *argv, float *result){ @@ -197,7 +198,7 @@ int xtract_spectral_skewness(const float *data, const int N, const void *argv, *result /= A; - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_spectral_kurtosis(const float *data, const int N, const void *argv, float *result){ @@ -221,7 +222,7 @@ int xtract_spectral_kurtosis(const float *data, const int N, const void *argv, *result /= A; *result -= 3.0f; - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_irregularity_k(const float *data, const int N, const void *argv, float *result){ @@ -232,7 +233,7 @@ int xtract_irregularity_k(const float *data, const int N, const void *argv, floa for(n = 1; n < M; n++) *result += fabs(data[n] - (data[n-1] + data[n] + data[n+1]) / 3); - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_irregularity_j(const float *data, const int N, const void *argv, float *result){ @@ -248,7 +249,7 @@ int xtract_irregularity_j(const float *data, const int N, const void *argv, floa *result = num / den; - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_tristimulus_1(const float *data, const int N, const void *argv, float *result){ @@ -269,7 +270,7 @@ int xtract_tristimulus_1(const float *data, const int N, const void *argv, float *result = p1 / den; - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_tristimulus_2(const float *data, const int N, const void *argv, float *result){ @@ -294,7 +295,7 @@ int xtract_tristimulus_2(const float *data, const int N, const void *argv, float *result = (p2 + p3 + p4) / den; - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_tristimulus_3(const float *data, const int N, const void *argv, float *result){ @@ -316,7 +317,7 @@ int xtract_tristimulus_3(const float *data, const int N, const void *argv, float *result = num / den; - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_smoothness(const float *data, const int N, const void *argv, float *result){ @@ -339,7 +340,7 @@ int xtract_smoothness(const float *data, const int N, const void *argv, float *r free(input); - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_spread(const float *data, const int N, const void *argv, float *result){ @@ -350,13 +351,13 @@ int xtract_spread(const float *data, const int N, const void *argv, float *resul while(n--){ temp = n - *(float *)argv; - num += SQ(temp) * data[n]; + num += XTRACT_SQ(temp) * data[n]; den += data[n]; } *result = sqrt(num / den); - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_zcr(const float *data, const int N, const void *argv, float *result){ @@ -368,7 +369,7 @@ int xtract_zcr(const float *data, const int N, const void *argv, float *result){ *result /= N; - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_rolloff(const float *data, const int N, const void *argv, float *result){ @@ -389,17 +390,17 @@ int xtract_rolloff(const float *data, const int N, const void *argv, float *resu *result = n * ((float *)argv)[0]; /* *result = (n / (float)N) * (((float *)argv)[1] * .5); */ - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_loudness(const float *data, const int N, const void *argv, float *result){ int n = N, rv; - if(n > BARK_BANDS) - rv = BAD_VECTOR_SIZE; + if(n > XTRACT_BARK_BANDS) + rv = XTRACT_BAD_VECTOR_SIZE; else - rv = SUCCESS; + rv = XTRACT_SUCCESS; while(n--) *result += pow(data[n], 0.23); @@ -426,15 +427,15 @@ int xtract_flatness(const float *data, const int N, const void *argv, float *res num = pow(num, 1.f / N); den /= N; - if(num < VERY_SMALL_NUMBER) - num = VERY_SMALL_NUMBER; + if(num < XTRACT_VERY_SMALL_NUMBER) + num = XTRACT_VERY_SMALL_NUMBER; - if(den < VERY_SMALL_NUMBER) - den = VERY_SMALL_NUMBER; + if(den < XTRACT_VERY_SMALL_NUMBER) + den = XTRACT_VERY_SMALL_NUMBER; *result = num / den; - return SUCCESS; + return XTRACT_SUCCESS; } @@ -446,9 +447,9 @@ int xtract_tonality(const float *data, const int N, const void *argv, float *res sfmdb = (sfm > 0 ? ((10 * log10(sfm)) / -60) : 0); - *result = MIN(sfmdb, 1); + *result = XTRACT_MIN(sfmdb, 1); - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_crest(const float *data, const int N, const void *argv, float *result){ @@ -462,7 +463,7 @@ int xtract_crest(const float *data, const int N, const void *argv, float *result *result = max / mean; - return SUCCESS; + return XTRACT_SUCCESS; } @@ -479,7 +480,7 @@ int xtract_noisiness(const float *data, const int N, const void *argv, float *re *result = i / p; - return SUCCESS; + return XTRACT_SUCCESS; } @@ -487,11 +488,11 @@ int xtract_rms_amplitude(const float *data, const int N, const void *argv, float int n = N; - while(n--) *result += SQ(data[n]); + while(n--) *result += XTRACT_SQ(data[n]); *result = sqrt(*result / N); - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_spectral_inharmonicity(const float *data, const int N, const void *argv, float *result){ @@ -505,19 +506,19 @@ int xtract_spectral_inharmonicity(const float *data, const int N, const void *ar freqs = data + n; while(n--){ - num += abs(freqs[n] - n * fund) * SQ(amps[n]); - den += SQ(amps[n]); + num += abs(freqs[n] - n * fund) * XTRACT_SQ(amps[n]); + den += XTRACT_SQ(amps[n]); } *result = (2 * num) / (fund * den); - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_power(const float *data, const int N, const void *argv, float *result){ - return FEATURE_NOT_IMPLEMENTED; + return XTRACT_FEATURE_NOT_IMPLEMENTED; } @@ -542,7 +543,7 @@ int xtract_odd_even_ratio(const float *data, const int N, const void *argv, floa *result = num / den; - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_sharpness(const float *data, const int N, const void *argv, float *result){ @@ -552,10 +553,10 @@ int xtract_sharpness(const float *data, const int N, const void *argv, float *re sl = g = temp = 0.f; - if(n > BARK_BANDS) - rv = BAD_VECTOR_SIZE; + if(n > XTRACT_BARK_BANDS) + rv = XTRACT_BAD_VECTOR_SIZE; else - rv = SUCCESS; + rv = XTRACT_SUCCESS; while(n--){ @@ -574,10 +575,10 @@ int xtract_spectral_slope(const float *data, const int N, const void *argv, floa const float *freqs, *amps; float f, a, - F, A, FA, FSQ; /* sums of freqs, amps, freq * amps, freq squared */ + F, A, FA, FXTRACT_SQ; /* sums of freqs, amps, freq * amps, freq squared */ int n, M; - F = A = FA = FSQ = 0.f; + F = A = FA = FXTRACT_SQ = 0.f; n = M = N >> 1; amps = data; @@ -589,12 +590,12 @@ int xtract_spectral_slope(const float *data, const int N, const void *argv, floa F += f; A += a; FA += f * a; - FSQ += f * f; + FXTRACT_SQ += f * f; } - *result = (1.f / A) * (M * FA - F * A) / (M * FSQ - F * F); + *result = (1.f / A) * (M * FA - F * A) / (M * FXTRACT_SQ - F * F); - return SUCCESS; + return XTRACT_SUCCESS; } @@ -607,10 +608,10 @@ int xtract_lowest_value(const float *data, const int N, const void *argv, float while(n--){ if((temp = data[n]) > *(float *)argv) - *result = MIN(*result, data[n]); + *result = XTRACT_MIN(*result, data[n]); } - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_highest_value(const float *data, const int N, const void *argv, float *result){ @@ -620,9 +621,9 @@ int xtract_highest_value(const float *data, const int N, const void *argv, float *result = data[--n]; while(n--) - *result = MAX(*result, data[n]); + *result = XTRACT_MAX(*result, data[n]); - return SUCCESS; + return XTRACT_SUCCESS; } @@ -633,7 +634,7 @@ int xtract_sum(const float *data, const int N, const void *argv, float *result){ while(n--) *result += *data++; - return SUCCESS; + return XTRACT_SUCCESS; } @@ -695,7 +696,7 @@ int xtract_hps(const float *data, const int N, const void *argv, float *result){ free(coeffs3); free(product); - return SUCCESS; + return XTRACT_SUCCESS; } @@ -762,12 +763,12 @@ int xtract_f0(const float *data, const int N, const void *argv, float *result){ f0 = sr / (tau + (err_tau_x / err_tau_1)); *result = f0; free(input); - return SUCCESS; + return XTRACT_SUCCESS; } } *result = -0; free(input); - return NO_RESULT; + return XTRACT_NO_RESULT; } int xtract_failsafe_f0(const float *data, const int N, const void *argv, float *result){ @@ -776,7 +777,7 @@ int xtract_failsafe_f0(const float *data, const int N, const void *argv, float * return_code = xtract_f0(data, N, argv, result); - if(return_code == NO_RESULT){ + if(return_code == XTRACT_NO_RESULT){ magnitudes = (float *)malloc(N * sizeof(float)); peaks = (float *)malloc(N * sizeof(float)); @@ -791,7 +792,7 @@ int xtract_failsafe_f0(const float *data, const int N, const void *argv, float * free(peaks); } - return SUCCESS; + return XTRACT_SUCCESS; } diff --git a/src/vector.c b/src/vector.c index e7cd759..1602da3 100644 --- a/src/vector.c +++ b/src/vector.c @@ -22,6 +22,7 @@ /* xtract_vector.c: defines functions that extract a feature as a single value from an input vector */ #include "xtract/libxtract.h" +#include "xtract_macros_private.h" #include <math.h> #include <string.h> #include <stdlib.h> @@ -32,78 +33,78 @@ int xtract_spectrum(const float *data, const int N, const void *argv, float *result){ - float *input, *rfft, nyquist, temp; + float *input, *rfft, q, temp; size_t bytes; int n , NxN, M, vector; fftwf_plan plan; M = N >> 1; - NxN = SQ(N); + NxN = XTRACT_SQ(N); rfft = (float *)fftwf_malloc(N * sizeof(float)); input = (float *)malloc(bytes = N * sizeof(float)); input = memcpy(input, data, bytes); - nyquist = *(float *)argv; + q = *(float *)argv; vector = (int)*((float *)argv+1); - CHECK_nyquist; + XTRACT_CHECK_q; plan = fftwf_plan_r2r_1d(N, input, rfft, FFTW_R2HC, FFTW_ESTIMATE); fftwf_execute(plan); switch(vector){ - case MAGNITUDE_SPECTRUM: + case XTRACT_MAGNITUDE_SPECTRUM: for(n = 0; n < M; n++){ - result[n] = sqrt(SQ(rfft[n]) + SQ(rfft[N - n])) / N; - result[M + n] = n * nyquist; + result[n] = sqrt(XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) / N; + result[M + n] = n * q; } break; - case LOG_MAGNITUDE_SPECTRUM: + case XTRACT_LOG_MAGNITUDE_SPECTRUM: for(n = 0; n < M; n++){ - if ((temp = SQ(rfft[n]) + SQ(rfft[N - n])) > LOG_LIMIT) + if ((temp = XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) > XTRACT_LOG_LIMIT) temp = log(sqrt(temp) / N); else - temp = LOG_LIMIT_DB; + temp = XTRACT_LOG_LIMIT_DB; /*Normalise*/ - result[n] = (temp + DB_SCALE_OFFSET) / DB_SCALE_OFFSET; - result[M + n] = n * nyquist; + result[n] = (temp + XTRACT_DB_SCALE_OFFSET) / XTRACT_DB_SCALE_OFFSET; + result[M + n] = n * q; } break; - case POWER_SPECTRUM: + case XTRACT_POWER_SPECTRUM: for(n = 0; n < M; n++){ - result[n] = (SQ(rfft[n]) + SQ(rfft[N - n])) / NxN; - result[M + n] = n * nyquist; + result[n] = (XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) / NxN; + result[M + n] = n * q; } break; - case LOG_POWER_SPECTRUM: + case XTRACT_LOG_POWER_SPECTRUM: for(n = 0; n < M; n++){ - if ((temp = SQ(rfft[n]) + SQ(rfft[N - n])) > LOG_LIMIT) + if ((temp = XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) > XTRACT_LOG_LIMIT) temp = log(temp / NxN); else - temp = LOG_LIMIT_DB; - result[n] = (temp + DB_SCALE_OFFSET) / DB_SCALE_OFFSET; - result[M + n] = n * nyquist; + temp = XTRACT_LOG_LIMIT_DB; + result[n] = (temp + XTRACT_DB_SCALE_OFFSET) / XTRACT_DB_SCALE_OFFSET; + result[M + n] = n * q; } break; default: /* MAGNITUDE_SPECTRUM */ for(n = 0; n < M; n++){ - result[n] = sqrt(SQ(rfft[n]) + SQ(rfft[N - n])) / N; - result[M + n] = n * nyquist; + result[n] = sqrt(XTRACT_SQ(rfft[n]) + XTRACT_SQ(rfft[N - n])) / N; + result[M + n] = n * q; } break; } /* result[0] = fabs(temp[0]) / N */ - result[M] = nyquist * .5; + result[N] = q * M; fftwf_destroy_plan(plan); fftwf_free(rfft); free(input); - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_autocorrelation_fft(const float *data, const int N, const void *argv, float *result){ @@ -128,7 +129,7 @@ int xtract_autocorrelation_fft(const float *data, const int N, const void *argv, fftwf_free(temp); free(input); - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_mfcc(const float *data, const int N, const void *argv, float *result){ @@ -147,7 +148,7 @@ int xtract_mfcc(const float *data, const int N, const void *argv, float *result) for(n = 0; n < N; n++){ result[filter] += input[n] * f->filters[filter][n]; } - if(result[filter] < LOG_LIMIT) result[filter] = LOG_LIMIT; + if(result[filter] < XTRACT_LOG_LIMIT) result[filter] = XTRACT_LOG_LIMIT; result[filter] = log(result[filter]); } @@ -157,7 +158,7 @@ int xtract_mfcc(const float *data, const int N, const void *argv, float *result) free(input); - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_dct(const float *data, const int N, const void *argv, float *result){ @@ -176,7 +177,7 @@ int xtract_dct(const float *data, const int N, const void *argv, float *result){ fftwf_destroy_plan(plan); free(input); - return SUCCESS; + return XTRACT_SUCCESS; } #else @@ -223,7 +224,7 @@ int xtract_autocorrelation(const float *data, const int N, const void *argv, flo result[n] = corr / N; } - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_amdf(const float *data, const int N, const void *argv, float *result){ @@ -242,7 +243,7 @@ int xtract_amdf(const float *data, const int N, const void *argv, float *result) result[n] = md / N; } - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_asdf(const float *data, const int N, const void *argv, float *result){ @@ -255,12 +256,12 @@ int xtract_asdf(const float *data, const int N, const void *argv, float *result) sd = 0; for(i = 0; i < N - n; i++){ /*sd = 1;*/ - sd += SQ(data[i] - data[i + n]); + sd += XTRACT_SQ(data[i] - data[i + n]); } result[n] = sd / N; } - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_bark_coefficients(const float *data, const int N, const void *argv, float *result){ @@ -269,47 +270,47 @@ int xtract_bark_coefficients(const float *data, const int N, const void *argv, f limits = (int *)argv; - for(band = 0; band < BARK_BANDS; band++){ + for(band = 0; band < XTRACT_BARK_BANDS; band++){ for(n = limits[band]; n < limits[band + 1]; n++) result[band] += data[n]; } - return SUCCESS; + return XTRACT_SUCCESS; } int xtract_peak_spectrum(const float *data, const int N, const void *argv, float *result){ - float threshold, max, y, y2, y3, p, nyquist, *input = NULL; + float threshold, max, y, y2, y3, p, q, *input = NULL; size_t bytes; - int n = N, M, rv = SUCCESS; + int n = N, M, rv = XTRACT_SUCCESS; - threshold = max = y = y2 = y3 = p = nyquist = 0.f; + threshold = max = y = y2 = y3 = p = q = 0.f; if(argv != NULL){ - nyquist = ((float *)argv)[0]; + q = ((float *)argv)[0]; threshold = ((float *)argv)[1]; } else - rv = BAD_ARGV; + rv = XTRACT_BAD_ARGV; if(threshold < 0 || threshold > 100){ threshold = 0; - rv = BAD_ARGV; + rv = XTRACT_BAD_ARGV; } - CHECK_nyquist; + XTRACT_CHECK_q; input = (float *)malloc(bytes = N * sizeof(float)); if(input != NULL) input = memcpy(input, data, bytes); else - return MALLOC_FAILED; + return XTRACT_MALLOC_FAILED; M = N >> 1; while(n--) - max = MAX(max, input[n]); + max = XTRACT_MAX(max, input[n]); threshold *= .01 * max; @@ -319,7 +320,7 @@ int xtract_peak_spectrum(const float *data, const int N, const void *argv, float for(n = 1; n < M; n++){ if(input[n] >= threshold){ if(input[n] > input[n - 1] && input[n] > input[n + 1]){ - result[M + n] = nyquist * (n + (p = .5 * (y = input[n-1] - + result[M + n] = q * (n + (p = .5 * (y = input[n-1] - (y3 = input[n+1])) / (input[n - 1] - 2 * (y2 = input[n]) + input[n + 1]))); result[n] = y2 - .25 * (y - y3) * p; @@ -336,7 +337,7 @@ int xtract_peak_spectrum(const float *data, const int N, const void *argv, float } free(input); - return (rv ? rv : SUCCESS); + return (rv ? rv : XTRACT_SUCCESS); } int xtract_harmonic_spectrum(const float *data, const int N, const void *argv, float *result){ @@ -368,6 +369,6 @@ int xtract_harmonic_spectrum(const float *data, const int N, const void *argv, f else result[n] = result[M + n] = 0.f; } - return SUCCESS; + return XTRACT_SUCCESS; } diff --git a/xtract/libxtract.h b/xtract/libxtract.h index a78e239..7249a94 100644 --- a/xtract/libxtract.h +++ b/xtract/libxtract.h @@ -56,178 +56,178 @@ extern "C" { #define XTRACT_FEATURES 53 /** \brief Enumeration of features, elements are used as indixes to an array of pointers to feature extracton functions */ -enum features_ { - MEAN, - VARIANCE, - STANDARD_DEVIATION, - AVERAGE_DEVIATION, - SKEWNESS, - KURTOSIS, - SPECTRAL_MEAN, - SPECTRAL_VARIANCE, - SPECTRAL_STANDARD_DEVIATION, - SPECTRAL_AVERAGE_DEVIATION, - SPECTRAL_SKEWNESS, - SPECTRAL_KURTOSIS, - SPECTRAL_CENTROID, - IRREGULARITY_K, - IRREGULARITY_J, - TRISTIMULUS_1, - TRISTIMULUS_2, - TRISTIMULUS_3, - SMOOTHNESS, - SPREAD, - ZCR, - ROLLOFF, - LOUDNESS, - FLATNESS, - TONALITY, - CREST, - NOISINESS, - RMS_AMPLITUDE, - SPECTRAL_INHARMONICITY, - POWER, - ODD_EVEN_RATIO, - SHARPNESS, - SPECTRAL_SLOPE, - LOWEST_VALUE, - HIGHEST_VALUE, - SUM, - HPS, - F0, - FAILSAFE_F0, - FLUX, - ATTACK_TIME, - DECAY_TIME, - DELTA_FEATURE, - AUTOCORRELATION, - AMDF, - ASDF, - BARK_COEFFICIENTS, - PEAK_SPECTRUM, - SPECTRUM, - AUTOCORRELATION_FFT, - MFCC, - DCT, - HARMONIC_SPECTRUM +enum xtract_features_ { + XTRACT_MEAN, + XTRACT_VARIANCE, + XTRACT_STANDARD_DEVIATION, + XTRACT_AVERAGE_DEVIATION, + XTRACT_SKEWNESS, + XTRACT_KURTOSIS, + XTRACT_SPECTRAL_MEAN, + XTRACT_SPECTRAL_VARIANCE, + XTRACT_SPECTRAL_STANDARD_DEVIATION, + XTRACT_SPECTRAL_AVERAGE_DEVIATION, + XTRACT_SPECTRAL_SKEWNESS, + XTRACT_SPECTRAL_KURTOSIS, + XTRACT_SPECTRAL_CENTROID, + XTRACT_IRREGULARITY_K, + XTRACT_IRREGULARITY_J, + XTRACT_TRISTIMULUS_1, + XTRACT_TRISTIMULUS_2, + XTRACT_TRISTIMULUS_3, + XTRACT_SMOOTHNESS, + XTRACT_SPREAD, + XTRACT_ZCR, + XTRACT_ROLLOFF, + XTRACT_LOUDNESS, + XTRACT_FLATNESS, + XTRACT_TONALITY, + XTRACT_CREST, + XTRACT_NOISINESS, + XTRACT_RMS_AMPLITUDE, + XTRACT_SPECTRAL_INHARMONICITY, + XTRACT_POWER, + XTRACT_ODD_EVEN_RATIO, + XTRACT_SHARPNESS, + XTRACT_SPECTRAL_SLOPE, + XTRACT_LOWEST_VALUE, + XTRACT_HIGHEST_VALUE, + XTRACT_SUM, + XTRACT_HPS, + XTRACT_F0, + XTRACT_FAILSAFE_F0, + XTRACT_FLUX, + XTRACT_ATTACK_TIME, + XTRACT_DECAY_TIME, + XTRACT_DELTA_FEATURE, + XTRACT_AUTOCORRELATION, + XTRACT_AMDF, + XTRACT_ASDF, + XTRACT_BARK_COEFFICIENTS, + XTRACT_PEAK_SPECTRUM, + XTRACT_SPECTRUM, + XTRACT_AUTOCORRELATION_FFT, + XTRACT_MFCC, + XTRACT_DCT, + XTRACT_HARMONIC_SPECTRUM }; /** \brief Enumeration of feature initialisation functions */ -enum feature_init_ { - INIT_MFCC = 100, - INIT_BARK +enum xtract_feature_init_ { + XTRACT_INIT_MFCC = 100, + XTRACT_INIT_BARK }; /** \brief Enumeration of feature types */ -enum feature_types_ { - SCALAR, - VECTOR, - DELTA +enum xtract_feature_types_ { + XTRACT_SCALAR, + XTRACT_VECTOR, + XTRACT_DELTA }; /** \brief Enumeration of mfcc types */ -enum mfcc_types_ { - EQUAL_GAIN, - EQUAL_AREA +enum xtract_mfcc_types_ { + XTRACT_EQUAL_GAIN, + XTRACT_EQUAL_AREA }; /** \brief Enumeration of return codes */ -enum return_codes_ { - SUCCESS, - MALLOC_FAILED, - BAD_ARGV, - BAD_VECTOR_SIZE, - NO_RESULT, - FEATURE_NOT_IMPLEMENTED +enum xtract_return_codes_ { + XTRACT_SUCCESS, + XTRACT_MALLOC_FAILED, + XTRACT_BAD_ARGV, + XTRACT_BAD_VECTOR_SIZE, + XTRACT_NO_RESULT, + XTRACT_FEATURE_NOT_IMPLEMENTED }; /** \brief Enumeration of spectrum types */ -enum spectrum_ { - MAGNITUDE_SPECTRUM, - LOG_MAGNITUDE_SPECTRUM, - POWER_SPECTRUM, - LOG_POWER_SPECTRUM +enum xtract_spectrum_ { + XTRACT_MAGNITUDE_SPECTRUM, + XTRACT_LOG_MAGNITUDE_SPECTRUM, + XTRACT_POWER_SPECTRUM, + XTRACT_LOG_POWER_SPECTRUM }; /** \brief Enumeration of data types*/ typedef enum type_ { - FLOAT, - FLOATARRAY, - INT, - MEL_FILTER -} t_type; + XTRACT_FLOAT, + XTRACT_FLOATARRAY, + XTRACT_INT, + XTRACT_MEL_FILTER +} xtract_type_t; /** \brief Enumeration of units*/ typedef enum unit_ { /* NONE, ANY */ - HERTZ = 2, - ANY_AMPLITUDE_HERTZ, - DBFS, - DBFS_HERTZ, - PERCENT, - SONE -} t_unit; + XTRACT_HERTZ = 2, + XTRACT_ANY_AMPLITUDE_HERTZ, + XTRACT_DBFS, + XTRACT_DBFS_HERTZ, + XTRACT_PERCENT, + XTRACT_SONE +} xtract_unit_t; /** \brief Boolean */ typedef enum { - FALSE, - TRUE -} t_bool; + XTRACT_FALSE, + XTRACT_TRUE +} xtract_bool_t; /** \brief Enumeration of vector format types*/ -typedef enum vector_ { +typedef enum xtract_vector_ { /* N/2 magnitude/log-magnitude/power/log-power coeffs and N/2 frequencies */ - SPECTRAL, + XTRACT_SPECTRAL, /* N spectral amplitudes */ - SPECTRAL_MAGNITUDES, + XTRACT_SPECTRAL_MAGNITUDES, /* N/2 magnitude/log-magnitude/power/log-power peak coeffs and N/2 * frequencies */ - SPECTRAL_PEAKS, + XTRACT_SPECTRAL_PEAKS, /* N spectral peak amplitudes */ - SPECTRAL_PEAK_MAGNITUDES, + XTRACT_SPECTRAL_PEAK_MAGNITUDES, /* N/2 magnitude/log-magnitude/power/log-power harmonic peak coeffs and N/2 * frequencies */ - SPECTRAL_HARMONICS, + XTRACT_SPECTRAL_HARMONICS, /* N spectral harmonic amplitudes */ - SPECTRAL_HARMONICS_MAGNITUDES, + XTRACT_SPECTRAL_HARMONICS_MAGNITUDES, /* N spectral harmonic frequencies */ - SPECTRAL_HARMONICS_FREQUENCIES, - ARBITRARY_SERIES, - AUDIO_SAMPLES, - MEL_COEFFS, - BARK_COEFFS, - NO_DATA -} t_vector; + XTRACT_SPECTRAL_HARMONICS_FREQUENCIES, + XTRACT_ARBITRARY_SERIES, + XTRACT_AUDIO_SAMPLES, + XTRACT_MEL_COEFFS, + XTRACT_BARK_COEFFS, + XTRACT_NO_DATA +} xtract_vector_t; /** \brief Data structure containing useful information about functions provided by LibXtract. */ -typedef struct _function_descriptor { +typedef struct _xtract_function_descriptor { struct { - char name[MAX_NAME_LENGTH]; - char p_name[MAX_NAME_LENGTH]; /* pretty name */ - char desc[MAX_DESC_LENGTH]; - char p_desc[MAX_DESC_LENGTH]; /* pretty description */ - char author[MAX_AUTHOR_LENGTH]; + char name[XTRACT_MAX_NAME_LENGTH]; + char p_name[XTRACT_MAX_NAME_LENGTH]; /* pretty name */ + char desc[XTRACT_MAX_DESC_LENGTH]; + char p_desc[XTRACT_MAX_DESC_LENGTH]; /* pretty description */ + char author[XTRACT_MAX_AUTHOR_LENGTH]; int year; } algo; struct { - t_vector format; - t_unit unit; + xtract_vector_t format; + xtract_unit_t unit; } data; int argc; struct { - t_type type; /* type of the array/value pointed to by argv */ - float min[MAXARGS]; - float max[MAXARGS]; - float def[MAXARGS]; /* defaults */ - t_unit unit[MAXARGS]; - char donor[MAXARGS]; /* suggested donor functions for argv */ + xtract_type_t type; /* type of the array/value pointed to by argv */ + float min[XTRACT_MAXARGS]; + float max[XTRACT_MAXARGS]; + float def[XTRACT_MAXARGS]; /* defaults */ + xtract_unit_t unit[XTRACT_MAXARGS]; + int donor[XTRACT_MAXARGS]; /* suggested donor functions for argv */ } argv; - t_bool is_scalar; + xtract_bool_t is_scalar; /* The result.<> entries in descritors.c need to be checked */ union { @@ -235,17 +235,17 @@ typedef struct _function_descriptor { struct { float min; float max; - t_unit unit; + xtract_unit_t unit; } scalar; struct { - t_vector format; - t_unit unit; + xtract_vector_t format; + xtract_unit_t unit; } vector; } result; -} t_function_descriptor; +} xtract_function_descriptor_t; /** * @@ -293,15 +293,9 @@ printf("Mean = %.2f\n", mean); * The calling function may additionally make some tests against the value returned by xtract * */ -#ifdef XTRACT +#ifdef XTRACT_H extern int(*xtract[XTRACT_FEATURES])(const float *data, const int N, const void *argv, float *result); -/** \brief An array of pointers to function descriptors - * - * Defined in libxtract.c. This is an array of pointers to function descriptors designed to be queried for useful information such as the expected input and output units of a function, or the number of arguments it takes. - */ -//extern t_function_descriptor *xtract_help[XTRACT_FEATURES]; - #endif /** \brief A structure to store a set of n_filters Mel filters */ @@ -314,7 +308,7 @@ typedef struct xtract_mel_filter_ { * * 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 */ -int xtract_init_mfcc(int N, float nyquist, int style, float freq_max, float freq_min, int freq_bands, float **fft_tables); +int xtract_init_mfcc(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, float **fft_tables); /** \brief A function to initialise bark filter bounds * diff --git a/xtract/xtract_delta.h b/xtract/xtract_delta.h index 461ced6..9c6910a 100644 --- a/xtract/xtract_delta.h +++ b/xtract/xtract_delta.h @@ -20,8 +20,8 @@ /** \file xtract_delta.h: declares functions that extract a feature as a single value or vector from more than one input vector */ -#ifndef XTRACT_DELTA -#define XTRACT_DELTA +#ifndef XTRACT_DELTA_H +#define XTRACT_DELTA_H #ifdef __cplusplus extern "C" { diff --git a/xtract/xtract_macros.h b/xtract/xtract_macros.h index 19983d3..bd01ab7 100644 --- a/xtract/xtract_macros.h +++ b/xtract/xtract_macros.h @@ -20,48 +20,23 @@ -/** \file xtract_delta.h: defines useful macros */ +/** \file xtract_macros.h: defines useful public macros */ -#ifndef XTRACT_MACROS -#define XTRACT_MACROS +#ifndef XTRACT_MACROS_H +#define XTRACT_MACROS_H #ifdef __cplusplus extern "C" { #endif -#include <stdio.h> - -#define SQ(a) ((a) * (a)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define NEEDS_FFTW printf("LibXtract must be compiled with fftw support to use this function.\n") - -#define VERY_SMALL_NUMBER 2e-42 -#define LOG_LIMIT VERY_SMALL_NUMBER -#define LOG_LIMIT_DB -96 -#define DB_SCALE_OFFSET 96 -#define VERY_BIG_NUMBER 2e42 -#define SR_UPPER_LIMIT 192000 -#define SR_LOWER_LIMIT 22050 -#define SR_DEFAULT 44100 -#define FUNDAMENTAL_DEFAULT 440 -#define CHECK_nyquist if(!nyquist) nyquist = SR_DEFAULT / N -#define SR_LIMIT SR_UPPER_LIMIT -#define FFT_BANDS_MIN 16 -#define FFT_BANDS_MAX 65536 -#define FFT_BANDS_DEF 1024 -#define SPEC_BW_MIN 0.168 /* Minimum spectral bandwidth (= SR_LOWER_LIMIT / \ - FFT_BANDS_MAX*/ -#define SPEC_BW_MAX 12000 /* SR_UPPER_LIMIT / FFT_BANDS_MIN */ -#define SPEC_BW_DEF 43.066 /* SR_DEFAULT / FFT_BANDS_DEF */ -#define BARK_BANDS 26 -#define NONE 0 -#define ANY -1 -#define UNKNOWN -2 -#define MAXARGS 4 -#define MAX_NAME_LENGTH 64 -#define MAX_AUTHOR_LENGTH 128 -#define MAX_DESC_LENGTH 256 +#define XTRACT_BARK_BANDS 26 +#define XTRACT_NONE 0 +#define XTRACT_ANY -1 +#define XTRACT_UNKNOWN -2 +#define XTRACT_MAXARGS 4 +#define XTRACT_MAX_NAME_LENGTH 64 +#define XTRACT_MAX_AUTHOR_LENGTH 128 +#define XTRACT_MAX_DESC_LENGTH 256 #ifdef __cplusplus } diff --git a/xtract/xtract_scalar.h b/xtract/xtract_scalar.h index c3dbfc7..ee4323b 100644 --- a/xtract/xtract_scalar.h +++ b/xtract/xtract_scalar.h @@ -20,8 +20,8 @@ /** \file xtract_scalar.h: declares functions that extract a feature as a single value from an input vector */ -#ifndef XTRACT_SCALAR -#define XTRACT_SCALAR +#ifndef XTRACT_SCALAR_H +#define XTRACT_SCALAR_H #ifdef __cplusplus extern "C" { diff --git a/xtract/xtract_types.h b/xtract/xtract_types.h index f679a27..d305f54 100644 --- a/xtract/xtract_types.h +++ b/xtract/xtract_types.h @@ -20,8 +20,8 @@ /* \file xtract_types.h: declares specialised variable types used by libxtract */ -#ifndef XTRACT_TYPES -#define XTRACT_TYPES +#ifndef XTRACT_TYPES_H +#define XTRACT_TYPES_H #ifdef __cplusplus extern "C" { diff --git a/xtract/xtract_vector.h b/xtract/xtract_vector.h index 4be7e45..a66e840 100644 --- a/xtract/xtract_vector.h +++ b/xtract/xtract_vector.h @@ -20,8 +20,8 @@ /* xtract_scalar.h: declares functions that extract a feature as a vector from an input vector */ -#ifndef XTRACT_VECTOR -#define XTRACT_VECTOR +#ifndef XTRACT_VECTOR_H +#define XTRACT_VECTOR_H #ifdef __cplusplus extern "C" { |