Revision: 10448 http://pure-data.svn.sourceforge.net/pure-data/?rev=10448&view=rev Author: tmusil Date: 2008-12-11 19:52:38 +0000 (Thu, 11 Dec 2008)
Log Message: ----------- speedlim for anything
Modified Paths: -------------- trunk/externals/iemlib/iemlib2/speedlim-help.pd trunk/externals/iemlib/iemlib2/src/iemlib2.c trunk/externals/iemlib/iemlib2/src/speedlim.c
Added Paths: ----------- trunk/externals/iemlib/iemlib2/aspeedlim-help.pd trunk/externals/iemlib/iemlib2/src/aspeedlim.c
Added: trunk/externals/iemlib/iemlib2/aspeedlim-help.pd =================================================================== --- trunk/externals/iemlib/iemlib2/aspeedlim-help.pd (rev 0) +++ trunk/externals/iemlib/iemlib2/aspeedlim-help.pd 2008-12-11 19:52:38 UTC (rev 10448) @@ -0,0 +1,47 @@ +#N canvas 465 200 609 471 10; +#X msg 204 251 1000; +#X msg 207 273 200; +#X floatatom 116 149 4 0 0 0 - - -; +#X obj 178 384 timer; +#X msg 210 294 20; +#X text 197 317 1.arg: lock-time in ms; +#X obj 77 375 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 348 392 IEM KUG; +#X text 328 380 musil; +#X text 362 380 @; +#X text 370 380 iem.at; +#X text 331 402 Graz , Austria; +#X text 6 6 aspeedlim : speedlimit for anything-message; +#X obj 104 318 aspeedlim 20; +#X msg 116 169 do_this 11 22 33 $1 abc xyz; +#X obj 77 355 t b; +#X text 283 369 (c) Thomas Musil 2000 - 2008; +#X msg 138 200 a b c d e f g h i j k l m n o p; +#X obj 24 33 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 +-1; +#X msg 63 79 symbol jfk; +#X obj 105 408 print out; +#X obj 178 408 print time; +#X obj 178 359 t b b; +#X msg 41 54 3.14159; +#X floatatom 93 103 4 0 0 0 - - -; +#X msg 93 123 $1 91 92 93 94 95; +#X connect 0 0 13 1; +#X connect 1 0 13 1; +#X connect 2 0 14 0; +#X connect 3 0 21 0; +#X connect 4 0 13 1; +#X connect 13 0 15 0; +#X connect 13 0 20 0; +#X connect 13 0 22 0; +#X connect 14 0 13 0; +#X connect 15 0 6 0; +#X connect 17 0 13 0; +#X connect 18 0 13 0; +#X connect 19 0 13 0; +#X connect 22 0 3 0; +#X connect 22 1 3 1; +#X connect 23 0 13 0; +#X connect 24 0 25 0; +#X connect 25 0 13 0;
Modified: trunk/externals/iemlib/iemlib2/speedlim-help.pd =================================================================== --- trunk/externals/iemlib/iemlib2/speedlim-help.pd 2008-12-11 19:47:25 UTC (rev 10447) +++ trunk/externals/iemlib/iemlib2/speedlim-help.pd 2008-12-11 19:52:38 UTC (rev 10448) @@ -1,33 +1,33 @@ -#N canvas 465 200 400 313 10; -#X msg 173 43 1000; -#X msg 176 65 200; -#X floatatom 67 86 4 0 0 0 - - -; -#X floatatom 46 152 4 0 0 0 - - -; -#X obj 95 150 t f b b; -#X obj 117 174 timer; -#X obj 95 200 pack 0 0; -#X obj 95 225 print; -#X msg 179 86 20; -#X obj 67 115 speedlim 20; -#X text 6 7 speedlim : speedlimit for float-message; -#X text 153 115 1.arg: lock-time in ms; -#X obj 46 171 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X text 235 248 IEM KUG; -#X text 219 236 musil; -#X text 249 236 @; -#X text 255 236 iem.at; -#X text 170 225 (c) Thomas Musil 2000 - 2005; -#X text 218 258 Graz , Austria; -#X connect 0 0 9 1; -#X connect 1 0 9 1; -#X connect 2 0 9 0; -#X connect 3 0 12 0; -#X connect 4 0 6 0; -#X connect 4 1 5 0; -#X connect 4 2 5 1; -#X connect 5 0 6 1; -#X connect 6 0 7 0; -#X connect 8 0 9 1; -#X connect 9 0 3 0; -#X connect 9 0 4 0; +#N canvas 465 200 404 317 10; +#X msg 173 43 1000; +#X msg 176 65 200; +#X floatatom 67 86 4 0 0 0 - - -; +#X floatatom 46 152 4 0 0 0 - - -; +#X obj 95 150 t f b b; +#X obj 117 174 timer; +#X obj 95 200 pack 0 0; +#X obj 95 225 print; +#X msg 179 86 20; +#X obj 67 115 speedlim 20; +#X text 6 7 speedlim : speedlimit for float-message; +#X text 153 115 1.arg: lock-time in ms; +#X obj 46 171 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 235 248 IEM KUG; +#X text 219 236 musil; +#X text 249 236 @; +#X text 255 236 iem.at; +#X text 170 225 (c) Thomas Musil 2000 - 2005; +#X text 218 258 Graz , Austria; +#X connect 0 0 9 1; +#X connect 1 0 9 1; +#X connect 2 0 9 0; +#X connect 3 0 12 0; +#X connect 4 0 6 0; +#X connect 4 1 5 0; +#X connect 4 2 5 1; +#X connect 5 0 6 1; +#X connect 6 0 7 0; +#X connect 8 0 9 1; +#X connect 9 0 3 0; +#X connect 9 0 4 0;
Added: trunk/externals/iemlib/iemlib2/src/aspeedlim.c =================================================================== --- trunk/externals/iemlib/iemlib2/src/aspeedlim.c (rev 0) +++ trunk/externals/iemlib/iemlib2/src/aspeedlim.c 2008-12-11 19:52:38 UTC (rev 10448) @@ -0,0 +1,140 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2008 */ + + +#include "m_pd.h" +#include "iemlib.h" + +/* ------------------------ aspeedlim --------------------------- */ +/* -- reduces the flow of anything-messages to one message per -- */ +/* -------------------- time interval in ms --------------------- */ + +struct _aspeedlim_proxy; + +static t_class *aspeedlim_class; +static t_class *aspeedlim_proxy_class; + +typedef struct _aspeedlim +{ + t_object x_obj; + struct _aspeedlim_proxy *x_proxy_inlet; + t_clock *x_clock; + float x_delay; + int x_output_is_locked; + int x_there_was_n_event; + int x_size; + int x_ac; + t_atom *x_at; + t_symbol *x_selector_sym; +} t_aspeedlim; + +typedef struct _aspeedlim_proxy +{ + t_object p_obj; + t_aspeedlim *p_owner; +} t_aspeedlim_proxy; + +static void aspeedlim_atcopy(t_atom *src, t_atom *dst, int n) +{ + while(n--) + *dst++ = *src++; +} + +static void aspeedlim_proxy_stop(t_aspeedlim_proxy *p) +{ + t_aspeedlim *x = p->p_owner; + + x->x_output_is_locked = 0; + x->x_there_was_n_event = 0; + clock_unset(x->x_clock); +} + +static void aspeedlim_proxy_delay(t_aspeedlim_proxy *p, t_floatarg delay) +{ + t_aspeedlim *x = p->p_owner; + + if(delay < 0.0) + delay = 0.0; + x->x_delay = delay; +} + +static void aspeedlim_tick(t_aspeedlim *x) +{ + if(x->x_there_was_n_event) + { + x->x_output_is_locked = 1; + x->x_there_was_n_event = 0; + outlet_anything(x->x_obj.ob_outlet, x->x_selector_sym, x->x_ac, x->x_at); + clock_delay(x->x_clock, x->x_delay); + } + else + { + x->x_output_is_locked = 0; + x->x_there_was_n_event = 0; + } +} + +static void aspeedlim_anything(t_aspeedlim *x, t_symbol *s, int ac, t_atom *av) +{ + if(ac > x->x_size) + { + x->x_at = (t_atom *)resizebytes(x->x_at, x->x_size*sizeof(t_atom), (10 + ac)*sizeof(t_atom)); + x->x_size = 10 + ac; + } + x->x_ac = ac; + x->x_selector_sym = s; + aspeedlim_atcopy(av, x->x_at, ac); + if(!x->x_output_is_locked) + { + x->x_output_is_locked = 1; + x->x_there_was_n_event = 0; + outlet_anything(x->x_obj.ob_outlet, x->x_selector_sym, x->x_ac, x->x_at); + clock_delay(x->x_clock, x->x_delay); + } + else + x->x_there_was_n_event = 1; +} + +static void aspeedlim_free(t_aspeedlim *x) +{ + clock_free(x->x_clock); + if(x->x_at) + freebytes(x->x_at, x->x_size * sizeof(t_atom)); + if(x->x_proxy_inlet) + pd_free((t_pd *)x->x_proxy_inlet); +} + +static void *aspeedlim_new(t_floatarg delay) +{ + t_aspeedlim *x = (t_aspeedlim *)pd_new(aspeedlim_class); + t_aspeedlim_proxy *p = (t_aspeedlim_proxy *)pd_new(aspeedlim_proxy_class); + + x->x_proxy_inlet = p; + p->p_owner = x; + x->x_size = 10; + x->x_at = (t_atom *)getbytes(x->x_size * sizeof(t_atom)); + x->x_ac = 0; + x->x_selector_sym = &s_bang; + if(delay < 0.0) + delay = 0.0; + x->x_delay = delay; + x->x_output_is_locked = 0; + x->x_there_was_n_event = 0; + x->x_clock = clock_new(x, (t_method)aspeedlim_tick); + inlet_new((t_object *)x, (t_pd *)p, 0, 0); + outlet_new(&x->x_obj, &s_list); + return (x); +} + +void aspeedlim_setup(void) +{ + aspeedlim_class = class_new(gensym("aspeedlim"), (t_newmethod)aspeedlim_new, + (t_method)aspeedlim_free, sizeof(t_aspeedlim), 0, A_DEFFLOAT, 0); + class_addanything(aspeedlim_class, aspeedlim_anything); + + aspeedlim_proxy_class = class_new(gensym("_aspeedlim_proxy"), 0, 0, sizeof(t_aspeedlim_proxy), CLASS_PD | CLASS_NOINLET, 0); + class_addmethod(aspeedlim_proxy_class, (t_method)aspeedlim_proxy_stop, gensym("stop"), 0); + class_addfloat(aspeedlim_proxy_class, (t_method)aspeedlim_proxy_delay); +}
Modified: trunk/externals/iemlib/iemlib2/src/iemlib2.c =================================================================== --- trunk/externals/iemlib/iemlib2/src/iemlib2.c 2008-12-11 19:47:25 UTC (rev 10447) +++ trunk/externals/iemlib/iemlib2/src/iemlib2.c 2008-12-11 19:52:38 UTC (rev 10448) @@ -17,11 +17,13 @@ }
void add2_comma_setup(void); +void aspeedlim_setup(void); void bpe_setup(void); void dollarg_setup(void); void exp_inc_setup(void); void fade_tilde_setup(void); void float24_setup(void); +void iem_alisttosym_setup(void); void iem_anything_setup(void); void iem_append_setup(void); void iem_blocksize_tilde_setup(void); @@ -33,6 +35,7 @@ void iem_samplerate_tilde_setup(void); void iem_sel_any_setup(void); void iem_send_setup(void); +void iem_symtoalist_setup(void); void init_setup(void); void LFO_noise_tilde_setup(void); void list2send_setup(void); @@ -61,11 +64,13 @@ iemlib2_class = class_new(gensym("iemlib2"), iemlib2_new, 0, sizeof(t_object), CLASS_NOINLET, 0);
add2_comma_setup(); + aspeedlim_setup(); bpe_setup(); dollarg_setup(); exp_inc_setup(); fade_tilde_setup(); float24_setup(); + iem_alisttosym_setup(); iem_anything_setup(); iem_append_setup(); iem_blocksize_tilde_setup(); @@ -77,6 +82,7 @@ iem_samplerate_tilde_setup(); iem_sel_any_setup(); iem_send_setup(); + iem_symtoalist_setup(); init_setup(); LFO_noise_tilde_setup(); list2send_setup(); @@ -98,6 +104,6 @@ unsymbol_setup(); wrap_setup();
- post("iemlib2 (R-1.17) library loaded! (c) Thomas Musil 11.2006"); + post("iemlib2 (R-1.17) library loaded! (c) Thomas Musil 11.2008"); post(" musil%ciem.at iem KUG Graz Austria", '@'); }
Modified: trunk/externals/iemlib/iemlib2/src/speedlim.c =================================================================== --- trunk/externals/iemlib/iemlib2/src/speedlim.c 2008-12-11 19:47:25 UTC (rev 10447) +++ trunk/externals/iemlib/iemlib2/src/speedlim.c 2008-12-11 19:52:38 UTC (rev 10448) @@ -1,7 +1,7 @@ /* For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ +iemlib2 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2008 */
#include "m_pd.h" @@ -21,7 +21,6 @@ int x_output_is_locked; int x_there_was_n_event; t_float x_curval; - t_float x_lastout; } t_speedlim;
static void speedlim_stop(t_speedlim *x)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.