From 2c6ac1a052c8db5a45e01a1a40c89eea18431a0e Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 27 Jan 2012 03:40:23 +0000 Subject: fixed [constant] to actually work svn path=/trunk/externals/ggee/; revision=15892 --- control/constant-help.pd | 46 +++++++++++++++++++++++++++++++++++++++++++--- control/constant.c | 36 ++++++++++++++++++++++-------------- 2 files changed, 65 insertions(+), 17 deletions(-) diff --git a/control/constant-help.pd b/control/constant-help.pd index af67427..73a7408 100644 --- a/control/constant-help.pd +++ b/control/constant-help.pd @@ -1,3 +1,43 @@ -#N canvas 1 52 450 300 10; -#X obj 140 126 constant; -#X text 54 47 placeholder help patch; +#N canvas 295 289 450 300 10; +#N canvas 952 360 494 344 META 0; +#X text 12 125 HELP_PATCH_AUTHORS "pd meta" information added by Jonathan +Wilkes for Pd version 0.42.; +#X text 12 25 LICENSE Tcl/Tk; +#X text 12 105 AUTHOR Guenter Geiger; +#X text 12 65 INLET_0 bang; +#X text 12 85 OUTLET_0 float; +#X text 12 5 KEYWORDS control; +#X text 12 45 DESCRIPTION get the value of the constants pi \, 2pi +\, or e; +#X restore 392 272 pd META; +#X text 22 22 get the value of the constants pi \, 2pi \, or e; +#X obj 28 63 loadbang; +#X floatatom 195 141 10 0 0 0 - - -; +#X obj 195 119 constant pi; +#X floatatom 275 141 10 0 0 0 - - -; +#X obj 275 119 constant 2pi; +#X floatatom 355 141 10 0 0 0 - - -; +#X obj 355 119 constant e; +#X floatatom 48 199 10 0 0 0 - - -; +#X floatatom 128 199 10 0 0 0 - - -; +#X floatatom 218 199 10 0 0 0 - - -; +#X obj 48 177 constant PI; +#X obj 128 177 constant M_PI; +#X obj 218 177 constant TWOPI; +#X floatatom 28 265 10 0 0 0 - - -; +#X obj 28 243 constant; +#X text 34 220 It defaults to the value of pi:; +#X connect 2 0 4 0; +#X connect 2 0 6 0; +#X connect 2 0 12 0; +#X connect 2 0 13 0; +#X connect 2 0 14 0; +#X connect 2 0 8 0; +#X connect 2 0 16 0; +#X connect 4 0 3 0; +#X connect 6 0 5 0; +#X connect 8 0 7 0; +#X connect 12 0 9 0; +#X connect 13 0 10 0; +#X connect 14 0 11 0; +#X connect 16 0 15 0; diff --git a/control/constant.c b/control/constant.c index 877326b..0584344 100644 --- a/control/constant.c +++ b/control/constant.c @@ -34,18 +34,21 @@ static void *constant_new(t_symbol* s) t_constant *x = (t_constant *)pd_new(constant_class); if (s == &s_) - x->x_constant = M_PI; - - if (!strcmp(s->s_name,"PI")) - x->x_constant = M_PI; - - if (!strcmp(s->s_name,"TWOPI")) - x->x_constant = 2*M_PI; - - if (!strcmp(s->s_name,"e")) - x->x_constant = exp(1.0); - - + x->x_constant = M_PI; + else if (!strcmp(s->s_name,"pi")) + x->x_constant = M_PI; + else if (!strcmp(s->s_name,"2pi")) + x->x_constant = 2*M_PI; + else if (!strcmp(s->s_name,"e")) + x->x_constant = exp(1.0); + else if (!strcmp(s->s_name,"M_PI")) + x->x_constant = M_PI; + else if (!strcmp(s->s_name,"PI")) + x->x_constant = M_PI; + else if (!strcmp(s->s_name,"TWOPI")) + x->x_constant = 2*M_PI; + else + pd_error(x, "Unsupported constant '%s'", s->s_name); outlet_new(&x->x_obj, &s_float); return (x); @@ -53,8 +56,13 @@ static void *constant_new(t_symbol* s) void constant_setup(void) { - constant_class = class_new(gensym("constant"), (t_newmethod)constant_new, 0, - sizeof(t_constant), 0,0); + constant_class = class_new(gensym("constant"), + (t_newmethod)constant_new, + 0, + sizeof(t_constant), + 0, + A_DEFSYMBOL, + 0); class_addbang(constant_class,constant_bang); } -- cgit v1.2.1