Mercurial > hg > libxtract
comparison examples/puredata/xtract~.c @ 115:6c5ece9cba3a
- 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
author | Jamie Bullock <jamie@postlude.co.uk> |
---|---|
date | Sat, 16 Feb 2008 20:13:05 +0000 |
parents | 72a9a393d5bd |
children | e4f704649c50 |
comparison
equal
deleted
inserted
replaced
114:f5040ed4e555 | 115:6c5ece9cba3a |
---|---|
48 t_float f; | 48 t_float f; |
49 t_float *window; | 49 t_float *window; |
50 t_int feature, | 50 t_int feature, |
51 is_scalar, | 51 is_scalar, |
52 is_subframe, | 52 is_subframe, |
53 argv_type, | |
53 init_blocksize, | 54 init_blocksize, |
54 done_init; | 55 done_init; |
55 t_symbol *feature_name; | 56 t_symbol *feature_name; |
56 tracked_memory memory; | 57 tracked_memory memory; |
57 void *argv; | 58 void *argv; |
121 return (w+5); | 122 return (w+5); |
122 } | 123 } |
123 | 124 |
124 static void xtract_dsp(t_xtract_tilde *x, t_signal **sp) { | 125 static void xtract_dsp(t_xtract_tilde *x, t_signal **sp) { |
125 | 126 |
126 if(!x->is_scalar) | 127 if(!x->is_scalar){ |
127 dsp_add(xtract_perform_vector, 4, | 128 dsp_add(xtract_perform_vector, 4, |
128 sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); | 129 sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); |
130 } | |
129 | 131 |
130 else dsp_add(xtract_perform, 3, sp[0]->s_vec, x, sp[0]->s_n); | 132 else |
133 dsp_add(xtract_perform, 3, sp[0]->s_vec, x, sp[0]->s_n); | |
131 | 134 |
132 } | 135 } |
133 | 136 |
134 static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) { | 137 static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) { |
135 | 138 |
153 f = F = XTRACT_FEATURES; | 156 f = F = XTRACT_FEATURES; |
154 | 157 |
155 N = BLOCKSIZE; | 158 N = BLOCKSIZE; |
156 | 159 |
157 x->argv = NULL; | 160 x->argv = NULL; |
161 x->argv_type = 0; | |
158 x->done_init = 0; | 162 x->done_init = 0; |
159 x->is_scalar = 0; | 163 x->is_scalar = 0; |
160 x->is_subframe = 0; | 164 x->is_subframe = 0; |
161 x->feature = -1; | 165 x->feature = -1; |
162 | 166 |
200 post("xtract~: feature not found: %s", x->feature_name->s_name); | 204 post("xtract~: feature not found: %s", x->feature_name->s_name); |
201 | 205 |
202 /* allocate memory for feature arguments */ | 206 /* allocate memory for feature arguments */ |
203 n_args = fd[f].argc; | 207 n_args = fd[f].argc; |
204 type = fd[f].argv.type; | 208 type = fd[f].argv.type; |
209 | |
210 x->argv_type = type; | |
205 | 211 |
206 if(n_args){ | 212 if(n_args){ |
207 for(n = 0; n < n_args; n++){ | 213 for(n = 0; n < n_args; n++){ |
208 argv_max = &fd[f].argv.max[n]; | 214 argv_max = &fd[f].argv.max[n]; |
209 /*post("Argument %d, max: %.2f", n, *argv_max); */ | 215 /*post("Argument %d, max: %.2f", n, *argv_max); */ |
333 post("Too many parameters to right inlet"); | 339 post("Too many parameters to right inlet"); |
334 else{*/ | 340 else{*/ |
335 | 341 |
336 x->argv = getbytes(argc * sizeof(float)); | 342 x->argv = getbytes(argc * sizeof(float)); |
337 | 343 |
338 while(argc--) | 344 while(argc--){ |
339 ((t_float *)x->argv)[argc] = atom_getfloat(&argv[argc]); | 345 switch(x->argv_type){ |
346 case XTRACT_INT: | |
347 ((t_int *)x->argv)[argc] = (int)atom_getfloat(&argv[argc]); | |
348 break; | |
349 case XTRACT_FLOAT: | |
350 default: | |
351 ((t_float *)x->argv)[argc] = atom_getfloat(&argv[argc]); | |
352 break; | |
353 } | |
354 } | |
340 /* }*/ | 355 /* }*/ |
341 } | 356 } |
342 | 357 |
343 static void xtract_tilde_show_help(t_xtract_tilde *x, t_symbol *s){ | 358 static void xtract_tilde_show_help(t_xtract_tilde *x, t_symbol *s){ |
344 | 359 |