From 592c723d7fe2dc8794182d6270a127e63f6e2973 Mon Sep 17 00:00:00 2001 From: Jamie Bullock Date: Mon, 29 Jan 2007 11:30:11 +0000 Subject: Added namespacing to enumerations and defines. Made most macros private. --- examples/puredata/xtract~.c | 48 ++++++++++++++++++++-------------------- examples/simpletest/simpletest.c | 3 +-- 2 files changed, 25 insertions(+), 26 deletions(-) (limited to 'examples') 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 #include -#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 @@ -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); -- cgit v1.2.3