comparison examples/puredata/xtract~.c @ 26:6417baefffc8

Added help string support, minor fixes.
author Jamie Bullock <jamie@postlude.co.uk>
date Wed, 18 Oct 2006 18:33:09 +0000
parents 1aec087ddfca
children 7c0f84f9874d
comparison
equal deleted inserted replaced
25:82c7b834a055 26:6417baefffc8
122 else if(tmp == gensym("odd_even_ratio")) x->feature = ODD_EVEN_RATIO; 122 else if(tmp == gensym("odd_even_ratio")) x->feature = ODD_EVEN_RATIO;
123 else if(tmp == gensym("sharpness")) x->feature = SHARPNESS; 123 else if(tmp == gensym("sharpness")) x->feature = SHARPNESS;
124 else if(tmp == gensym("slope")) x->feature = SLOPE; 124 else if(tmp == gensym("slope")) x->feature = SLOPE;
125 else if(tmp == gensym("f0")){ 125 else if(tmp == gensym("f0")){
126 x->feature = F0; 126 x->feature = F0;
127 x->argv = getbytes(sizeof(t_float)); 127 x->argv = getbytes(3 * sizeof(t_float));
128 } 128 }
129 else if(tmp == gensym("hps"))x->feature = HPS; 129 else if(tmp == gensym("hps"))x->feature = HPS;
130 else if(tmp == gensym("lowest_match")){ 130 else if(tmp == gensym("lowest_match")){
131 x->feature = LOWEST_MATCH; 131 x->feature = LOWEST_MATCH;
132 x->argv = getbytes(sizeof(t_float)); 132 x->argv = getbytes(sizeof(t_float));
179 else if (x->feature == FLUX || x->feature == ATTACK_TIME || 179 else if (x->feature == FLUX || x->feature == ATTACK_TIME ||
180 x->feature == DECAY_TIME || x->feature == DELTA) 180 x->feature == DECAY_TIME || x->feature == DELTA)
181 x->feature_type = DELTA; 181 x->feature_type = DELTA;
182 182
183 else x->feature_type = SCALAR; 183 else x->feature_type = SCALAR;
184
185 post("Type: %d", x->feature);
186 184
187 /* argv through right inlet */ 185 /* argv through right inlet */
188 inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("list")); 186 inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("list"));
189 187
190 188
210 while(argc--) 208 while(argc--)
211 ((t_float *)x->argv)[argc] = atom_getfloat(&argv[argc]); 209 ((t_float *)x->argv)[argc] = atom_getfloat(&argv[argc]);
212 /* }*/ 210 /* }*/
213 } 211 }
214 212
213 static void xtract_tilde_show_help(t_xtract_tilde *x, t_symbol *s){
214
215 int i;
216
217 i = XTRACT_FEATURES;
218
219 post("\n\txtract~: Feature List\n");
220
221 while(i--){
222 post("\t%s", xtract_help_strings[i]+7);
223 }
224 }
225
215 static void xtract_tilde_free(t_xtract_tilde *x) { 226 static void xtract_tilde_free(t_xtract_tilde *x) {
216 /*FIX */ 227 /*FIX */
217 if(x->argv != NULL) 228 if(x->argv != NULL)
218 freebytes(x->argv, 0); 229 freebytes(x->argv, 0);
219 } 230 }
225 sizeof(t_xtract_tilde), 236 sizeof(t_xtract_tilde),
226 CLASS_DEFAULT, 237 CLASS_DEFAULT,
227 A_GIMME, 0); 238 A_GIMME, 0);
228 239
229 class_addmethod(xtract_class, 240 class_addmethod(xtract_class,
230 (t_method)xtract_dsp, gensym("dsp"), 0); 241 (t_method)xtract_dsp, gensym("dsp"), 0);
231 class_addmethod(xtract_class, 242 class_addmethod(xtract_class,
232 (t_method)xtract_tilde_get_args, gensym("list"), A_GIMME, 0); 243 (t_method)xtract_tilde_get_args, gensym("list"), A_GIMME, 0);
244 class_addmethod(xtract_class,
245 (t_method)xtract_tilde_show_help, gensym("help"), A_DEFSYMBOL, 0);
233 CLASS_MAINSIGNALIN(xtract_class, t_xtract_tilde, f); 246 CLASS_MAINSIGNALIN(xtract_class, t_xtract_tilde, f);
234 class_sethelpsymbol(xtract_class, gensym("help-flib")); 247 class_sethelpsymbol(xtract_class, gensym("help-flib"));
235 } 248 }