diff options
author | Jamie Bullock <jamie@postlude.co.uk> | 2008-02-16 20:13:05 +0000 |
---|---|---|
committer | Jamie Bullock <jamie@postlude.co.uk> | 2008-02-16 20:13:05 +0000 |
commit | 398afce1d37bad97d50a20aa5406a4dc6327912d (patch) | |
tree | 6b4bbeeaadc14e1e4ef3567565aae7023a6c2161 /examples/puredata/xtract~.c | |
parent | 26fa6beab516a699ead017f4a2d68b1d861b9561 (diff) | |
download | LibXtract-398afce1d37bad97d50a20aa5406a4dc6327912d.tar.gz LibXtract-398afce1d37bad97d50a20aa5406a4dc6327912d.tar.bz2 LibXtract-398afce1d37bad97d50a20aa5406a4dc6327912d.zip |
- Added to pd example the ability to differentiate between different
argv types (XTRACT_FLOAT, XTRACT_INT) and pass the correct data type
to the xtract[]() function
- Added xtract_flatness_db() details to descriptors.c
- Fixes to tonality and xtract_subbands descriptors
- Added Pd examples for 'subband mean' and tonality calculated using subbands
Diffstat (limited to 'examples/puredata/xtract~.c')
-rw-r--r-- | examples/puredata/xtract~.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/examples/puredata/xtract~.c b/examples/puredata/xtract~.c index 69595fe..5059a76 100644 --- a/examples/puredata/xtract~.c +++ b/examples/puredata/xtract~.c @@ -50,6 +50,7 @@ typedef struct _xtract { t_int feature, is_scalar, is_subframe, + argv_type, init_blocksize, done_init; t_symbol *feature_name; @@ -123,11 +124,13 @@ static t_int *xtract_perform_vector(t_int *w) { static void xtract_dsp(t_xtract_tilde *x, t_signal **sp) { - if(!x->is_scalar) + if(!x->is_scalar){ dsp_add(xtract_perform_vector, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); + } - else dsp_add(xtract_perform, 3, sp[0]->s_vec, x, sp[0]->s_n); + else + dsp_add(xtract_perform, 3, sp[0]->s_vec, x, sp[0]->s_n); } @@ -155,6 +158,7 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) { N = BLOCKSIZE; x->argv = NULL; + x->argv_type = 0; x->done_init = 0; x->is_scalar = 0; x->is_subframe = 0; @@ -203,6 +207,8 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) { n_args = fd[f].argc; type = fd[f].argv.type; + x->argv_type = type; + if(n_args){ for(n = 0; n < n_args; n++){ argv_max = &fd[f].argv.max[n]; @@ -335,8 +341,17 @@ t_int argc, t_atom *argv) { x->argv = getbytes(argc * sizeof(float)); - while(argc--) - ((t_float *)x->argv)[argc] = atom_getfloat(&argv[argc]); + while(argc--){ + switch(x->argv_type){ + case XTRACT_INT: + ((t_int *)x->argv)[argc] = (int)atom_getfloat(&argv[argc]); + break; + case XTRACT_FLOAT: + default: + ((t_float *)x->argv)[argc] = atom_getfloat(&argv[argc]); + break; + } + } /* }*/ } |