From e420e83534daf42568eba431d3b994ef585dabf9 Mon Sep 17 00:00:00 2001 From: Thomas O Fredericks Date: Tue, 29 Sep 2009 21:39:24 +0000 Subject: Added a place to store my old externals svn path=/trunk/externals/tof/; revision=12494 --- help/param-abs.pd | 34 ++--- help/param-help.pd | 96 +++++++------- help/param2-abs.pd | 14 +- help/wrapper-help.pd | 27 ---- old/wrapper-help.pd | 27 ++++ old/wrapper.c | 81 ++++++++++++ test/pak.c | 357 +++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 542 insertions(+), 94 deletions(-) delete mode 100644 help/wrapper-help.pd create mode 100644 old/wrapper-help.pd create mode 100644 old/wrapper.c create mode 100644 test/pak.c diff --git a/help/param-abs.pd b/help/param-abs.pd index b0b38a9..65d28c9 100644 --- a/help/param-abs.pd +++ b/help/param-abs.pd @@ -1,7 +1,6 @@ -#N canvas 1024 0 1018 716 10; +#N canvas 6 0 1018 692 10; #X obj 225 477 outlet~; #X obj 55 21 inlet; -#X obj 55 66 paramRoute; #X text 179 26 This abstraction is an example for the param external. ; #X floatatom 223 247 0 0 0 0 - - -; @@ -15,19 +14,20 @@ #X obj 315 400 line~; #X msg 316 376 \$1 100; #X obj 317 325 loadbang; -#X obj 317 349 param /volume 0 /gui slider 0 1; -#X obj 223 202 param /carrier 800 /gui slider 200 2000; #X obj 321 300 param2-abs /id modulation; -#X connect 1 0 2 0; -#X connect 2 0 9 0; -#X connect 4 0 5 0; -#X connect 5 0 8 0; -#X connect 8 0 11 0; -#X connect 10 0 16 0; -#X connect 11 0 0 0; -#X connect 12 0 11 1; -#X connect 13 0 12 0; -#X connect 14 0 15 0; -#X connect 15 0 13 0; -#X connect 16 0 4 0; -#X connect 17 0 5 1; +#X obj 317 349 tof/param /volume 0 /g slider 0 1; +#X obj 223 202 tof/param /carrier 800 /g slider 200 2000; +#X obj 55 66 tof/paramRoute; +#X connect 1 0 17 0; +#X connect 3 0 4 0; +#X connect 4 0 7 0; +#X connect 7 0 10 0; +#X connect 9 0 16 0; +#X connect 10 0 0 0; +#X connect 11 0 10 1; +#X connect 12 0 11 0; +#X connect 13 0 15 0; +#X connect 14 0 4 1; +#X connect 15 0 12 0; +#X connect 16 0 3 0; +#X connect 17 0 8 0; diff --git a/help/param-help.pd b/help/param-help.pd index b1938a7..ea41f91 100644 --- a/help/param-help.pd +++ b/help/param-help.pd @@ -1,4 +1,4 @@ -#N canvas 1024 0 1018 688 10; +#N canvas 6 80 1018 688 10; #X floatatom 477 321 5 0 0 0 - - -; #X obj -23 2 cnv 15 400 100 empty empty empty 20 12 0 14 -249661 -66577 0; @@ -7,21 +7,15 @@ system.; #X text -19 75 version: 2009-09-19 (localized release); #X text -19 33 tags: state routing param; -#X obj 33 546 paramFile; -#X obj 555 541 paramDump; -#X obj 557 620 paramGui; -#X obj 32 592 paramRoute; #X text 3 389 /id keyword:; -#X obj 14 127 param /my_name my_value; -#X text 169 122 argument 1: param name (must start with a slash); -#X text 169 139 argument 2...: param value (can be a list); -#X obj 525 126 param /number 30 /gui nbx; -#X text 578 181 nbx: creates a numberbox; -#X text 577 200 slider min max: creates a slider with the indicated +#X text 179 122 argument 1: param name (must start with a slash); +#X text 179 139 argument 2...: param value (can be a list); +#X text 585 115 nbx: creates a numberbox; +#X text 584 134 slider min max: creates a slider with the indicated minimum and maximum; -#X text 577 229 bng: creates a bang; -#X text 577 247 tgl: creates a toggle; -#X text 579 265 symbolatom: creates a symbol box; +#X text 584 163 bng: creates a bang; +#X text 584 181 tgl: creates a toggle; +#X text 586 199 symbolatom: creates a symbol box; #X text 68 355 (\$0)/abstraction's name/.../param's name; #X text 5 210 If the param object is created directly in the root patch (as the my_name example above) \, its path is as follows:; @@ -32,11 +26,7 @@ data can be accessed through a unique symbolic path.; contained inside another abstraction an so forth) \, the path starts at the root and follows every child patch (abstraction) until it reaches the param object \, at which point the param's name is appended:; -#X text 100 590 Sends values to params using a relative path.; -#X obj 34 620 OSCToParam; -#X text 515 166 /gui options:; -#X text 526 81 When you create a param \, you can optinally use the -"/gui" keyword to flag the param with gui options.; +#X text 128 592 Sends values to params using a relative path.; #X text 40 414 If an abstraction's arguments contains the "/id" keyword \, the symbol following the "/id" keyword \, instead of the abstraction's name \, will be used to build the path. See an example to the right. @@ -47,7 +37,7 @@ name \, will be used to build the path. See an example to the right. -1; #X obj 99 518 bng 15 250 50 0 empty empty load 17 7 0 10 -262144 -1 -1; -#X floatatom 525 146 5 0 0 0 - - -; +#X floatatom 529 84 5 0 0 0 - - -; #X obj 555 519 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 555 569 print DUMP; @@ -55,35 +45,55 @@ name \, will be used to build the path. See an example to the right. ; #X obj 472 448 dac~; #X obj 690 364 hsl 100 15 0 1 0 0 \$0/FM_MOD/volume \$0/FM_MOD/volume_ -/FM_MOD/volume 105 7 0 10 -262144 -1 -1 0 1; +/FM_MOD/volume 105 7 0 10 -262144 -1 -1 4131 1; #X obj 690 384 hsl 100 15 200 2000 0 0 \$0/FM_MOD/carrier \$0/FM_MOD/carrier_ -/FM_MOD/carrier 105 7 0 10 -262144 -1 -1 3300 1; +/FM_MOD/carrier 105 7 0 10 -262144 -1 -1 2200 1; #X obj 688 423 nbx 5 14 -1e+37 1e+37 0 0 \$0/FM_MOD/modulation/index \$0/FM_MOD/modulation/index_ /FM_MOD/modulation/index 57 7 0 10 -262144 --1 -1 20 256; +-1 -1 85 256; #X obj 688 404 nbx 5 14 -1e+37 1e+37 0 0 \$0/FM_MOD/modulation/freq \$0/FM_MOD/modulation/freq_ /FM_MOD/modulation/freq 57 7 0 10 -262144 -1 -1 3 256; -#X msg 477 343 modulation/index \$1; #X obj 517 367 hsl 128 15 0 1 0 0 empty empty empty -2 -8 0 10 -262144 --1 -1 0 1; -#X msg 514 389 volume \$1; -#X obj 477 414 param-abs /id FM_MOD; -#X text 624 538 Outputs all children params of the root patch.; -#X text 99 541 Saves and restores all chilren params of the root patch +-1 -1 5300 1; +#X text 650 542 Outputs all children params of the root patch.; +#X text 121 539 Saves and restores all chilren params of the root patch to/from a file with optionnal presets.; -#X text 623 617 Build a PD gui for all children params that have values +#X text 636 617 Build a PD gui for all children params that have values for the "/gui" keyword.; -#X text 107 620 Routes OSC messages to matching children params; -#X connect 0 0 42 0; -#X connect 7 0 35 0; -#X connect 14 0 33 0; -#X connect 30 0 8 0; -#X connect 31 0 6 0; -#X connect 32 0 6 1; -#X connect 34 0 7 0; -#X connect 42 0 45 0; -#X connect 43 0 44 0; -#X connect 44 0 45 0; -#X connect 45 0 37 0; -#X connect 45 0 37 1; +#X text 124 617 Routes OSC messages to matching children params; +#X obj 529 58 tof/param /number 30 /g nbx; +#X obj 33 546 tof/paramFile; +#X obj 32 592 tof/paramRoute; +#X obj 30 619 tof/OSCToParam; +#X obj 555 541 tof/paramDump; +#X obj 557 620 tof/paramGui; +#X obj -10 149 print loadbang; +#X obj -10 125 tof/param /my_name my_value; +#X text 526 100 /g options:; +#X text 529 13 When you create a param \, you can optinally use the +"/g" keyword to flag the param with gui options.; +#X text 484 1 /g keyword:; +#X text 500 224 /nlb keyword:; +#X obj 477 414 param-abs /id FM_MOD /carrier 600; +#X floatatom 644 312 5 0 0 0 - - -; +#X obj 644 289 tof/param /test 50 /nlb; +#X text 531 246 A param automatically ouputs its value when it is created. +You can disable this behavior with the "/nlb" (no loadbang) keyword. +; +#X msg 477 343 modulation/index \$1; +#X msg 514 389 volume \$1; +#X connect 0 0 54 0; +#X connect 21 0 43 0; +#X connect 22 0 39 0; +#X connect 23 0 39 1; +#X connect 25 0 42 0; +#X connect 33 0 55 0; +#X connect 38 0 24 0; +#X connect 42 0 26 0; +#X connect 45 0 44 0; +#X connect 50 0 28 0; +#X connect 50 0 28 1; +#X connect 52 0 51 0; +#X connect 54 0 50 0; +#X connect 55 0 50 0; diff --git a/help/param2-abs.pd b/help/param2-abs.pd index f793907..867a6e9 100644 --- a/help/param2-abs.pd +++ b/help/param2-abs.pd @@ -1,4 +1,4 @@ -#N canvas 1228 134 711 410 10; +#N canvas 290 157 711 410 10; #X text 84 2 This abstraction is an example for the param external. ; #X obj 175 232 *~; @@ -10,15 +10,15 @@ #X text 280 197 modulation; #X obj 175 172 osc~; #X obj 163 341 outlet~; -#X obj 237 172 param /index 20 /gui nbx; -#X obj 174 122 param /freq 3 /gui nbx; #X obj 172 99 loadbang; #X obj 238 148 loadbang; +#X obj 174 122 tof/param /freq 3 /g nbx; +#X obj 237 172 tof/param /index 20 /g nbx; #X connect 1 0 9 0; #X connect 2 0 8 0; #X connect 3 0 1 1; #X connect 8 0 1 0; -#X connect 10 0 3 0; -#X connect 11 0 2 0; -#X connect 12 0 11 0; -#X connect 13 0 10 0; +#X connect 10 0 12 0; +#X connect 11 0 13 0; +#X connect 12 0 2 0; +#X connect 13 0 3 0; diff --git a/help/wrapper-help.pd b/help/wrapper-help.pd deleted file mode 100644 index 06abf4d..0000000 --- a/help/wrapper-help.pd +++ /dev/null @@ -1,27 +0,0 @@ -#N canvas 226 243 486 349 10; -#X text 114 176 Wraps between 0 and 1 by default; -#X text 137 276 This instance wraps the input between 2 and 8; -#X floatatom 52 205 5 0 0 0 - - -; -#X floatatom 50 138 5 0 0 0 - - -; -#X floatatom 91 138 5 0 0 0 - - -; -#X floatatom 134 140 5 0 0 0 - - -; -#X floatatom 50 242 5 0 0 0 - - -; -#X floatatom 92 243 5 0 0 0 - - -; -#X floatatom 136 242 5 0 0 0 - - -; -#X floatatom 50 306 5 0 0 0 - - -; -#X obj 52 177 wrapper; -#X obj 50 277 wrapper 2 8; -#X obj 42 2 cnv 15 400 100 empty empty empty 20 12 0 14 -249661 -66577 -0; -#X text 47 36 author: mrtoftrash@gmail.com; -#X text 48 2 description: wraps a number around a range; -#X text 47 47 version: 2009-06-07 (initial release); -#X text 47 25 tags: math range tof; -#X connect 3 0 10 0; -#X connect 4 0 10 1; -#X connect 5 0 10 2; -#X connect 6 0 11 0; -#X connect 7 0 11 1; -#X connect 8 0 11 2; -#X connect 10 0 2 0; -#X connect 11 0 9 0; diff --git a/old/wrapper-help.pd b/old/wrapper-help.pd new file mode 100644 index 0000000..06abf4d --- /dev/null +++ b/old/wrapper-help.pd @@ -0,0 +1,27 @@ +#N canvas 226 243 486 349 10; +#X text 114 176 Wraps between 0 and 1 by default; +#X text 137 276 This instance wraps the input between 2 and 8; +#X floatatom 52 205 5 0 0 0 - - -; +#X floatatom 50 138 5 0 0 0 - - -; +#X floatatom 91 138 5 0 0 0 - - -; +#X floatatom 134 140 5 0 0 0 - - -; +#X floatatom 50 242 5 0 0 0 - - -; +#X floatatom 92 243 5 0 0 0 - - -; +#X floatatom 136 242 5 0 0 0 - - -; +#X floatatom 50 306 5 0 0 0 - - -; +#X obj 52 177 wrapper; +#X obj 50 277 wrapper 2 8; +#X obj 42 2 cnv 15 400 100 empty empty empty 20 12 0 14 -249661 -66577 +0; +#X text 47 36 author: mrtoftrash@gmail.com; +#X text 48 2 description: wraps a number around a range; +#X text 47 47 version: 2009-06-07 (initial release); +#X text 47 25 tags: math range tof; +#X connect 3 0 10 0; +#X connect 4 0 10 1; +#X connect 5 0 10 2; +#X connect 6 0 11 0; +#X connect 7 0 11 1; +#X connect 8 0 11 2; +#X connect 10 0 2 0; +#X connect 11 0 9 0; diff --git a/old/wrapper.c b/old/wrapper.c new file mode 100644 index 0000000..8d0ec5e --- /dev/null +++ b/old/wrapper.c @@ -0,0 +1,81 @@ +#include "m_pd.h" +#include + +static t_class *wrapper_class; + +typedef struct _wrapper { + t_object x_obj; + + t_float min; + t_float max; + //t_int iterating; + t_outlet* outlet1; + //t_outlet* outlet2; +} t_wrapper; + +/* +void wrapper_bang(t_wrapper *x) +{ + //x->i_count = x->i_down; + x->iterating = 0; + +} +*/ + +void wrapper_float(t_wrapper *x, t_float f) +{ + + t_float value = fmod(f - x->min ,x->max - x->min); + if ( value < 0 ) value = value + x->max; + else value = value + x->min; + + outlet_float(x->outlet1, value); + + +} + + + +static void wrapper_free(t_wrapper *x) +{ + + +} + +void *wrapper_new(t_symbol *s, int argc, t_atom *argv) +{ + t_wrapper *x = (t_wrapper *)pd_new(wrapper_class); + + + if ( argc >= 2) { + x->min = atom_getfloat(argv); + x->max = atom_getfloat(argv+1); + } else if ( argc == 1) { + x->min = 0; + x->max = atom_getfloat(argv); + } else { + x->min = 0; + x->max = 1; + } + + floatinlet_new(&x->x_obj, &x->min); + floatinlet_new(&x->x_obj, &x->max); + x->outlet1 = outlet_new(&x->x_obj, &s_float); + + + + return (void *)x; +} + +void wrapper_setup(void) { + wrapper_class = class_new(gensym("wrapper"), + (t_newmethod)wrapper_new, + (t_method)wrapper_free, sizeof(t_wrapper), + CLASS_DEFAULT, + A_GIMME, 0); + + //class_addbang (wrapper_class, wrapper_bang); + class_addfloat (wrapper_class, wrapper_float); + //class_addlist (wrapper_class, wrapper_list); + +} diff --git a/test/pak.c b/test/pak.c new file mode 100644 index 0000000..8d004c1 --- /dev/null +++ b/test/pak.c @@ -0,0 +1,357 @@ + +static t_class *pak_class; +static t_class *pak_inlet_class; +struct _param_inlet2; + +#define PAK_MAX_INLETS 100 + +typedef struct _pak +{ + t_object x_obj; + struct _pak_inlet inlets[PAK_MAX_INLETS]; + int number; +} t_pak; + +typedef struct _pak_inlet +{ + t_object x_obj; + t_pak *p_owner; +} t_pak_inlet; + + + + + +// CONSTRUCTOR +static void *param_new(t_symbol *s, int ac, t_atom *av) +{ + t_param *x = (t_param *)pd_new(param_class); + t_param_inlet2 *p = (t_param_inlet2 *)pd_new(param_inlet2_class); + + // Stuff + x->s_set = gensym("set"); + x->s_PARAM = gensym("PARAM"); + + // Set up second inlet proxy + x->x_param_inlet2 = p; + p->p_owner = x; + + + + + return (x); +} + + +void pak_setup(void) +{ + pak_class = class_new(gensym("pak"), + (t_newmethod)pak_new, (t_method)pak_free, + sizeof(t_param), 0, A_GIMME, 0); + + + //class_addanything(param_class, param_anything); + //class_addbang(param_class, param_bang); + + //class_addmethod(param_class, (t_method)param_loadbang, gensym("loadbang"), 0); + + pak_inlet_class = class_new(gensym("_pak_inlet"), + 0, 0, sizeof(t_pak_inlet), CLASS_PD | CLASS_NOINLET, 0); + + //class_addanything(pak_inlet_class, pak_inlet_anything); + +} + + +///////////////// PACK /////////////// + +/* +static t_class *pack_class; + +typedef struct _pack +{ + t_object x_obj; + t_int x_n; // number of args + t_atom *x_vec; // input values + t_int x_nptr; // number of pointers + t_gpointer *x_gpointer; // the pointers + t_atom *x_outvec; // space for output values +} t_pack; + +static void *pack_new(t_symbol *s, int argc, t_atom *argv) +{ + t_pack *x = (t_pack *)pd_new(pack_class); + t_atom defarg[2], *ap, *vec, *vp; + t_gpointer *gp; + int nptr = 0; + int i; + if (!argc) + { + argv = defarg; + argc = 2; + SETFLOAT(&defarg[0], 0); + SETFLOAT(&defarg[1], 0); + } + + x->x_n = argc; + vec = x->x_vec = (t_atom *)getbytes(argc * sizeof(*x->x_vec)); + x->x_outvec = (t_atom *)getbytes(argc * sizeof(*x->x_outvec)); + + for (i = argc, ap = argv; i--; ap++) + if (ap->a_type == A_SYMBOL && *ap->a_w.w_symbol->s_name == 'p') + nptr++; + + gp = x->x_gpointer = (t_gpointer *)t_getbytes(nptr * sizeof (*gp)); + x->x_nptr = nptr; + + for (i = 0, vp = x->x_vec, ap = argv; i < argc; i++, ap++, vp++) + { + if (ap->a_type == A_FLOAT) + { + *vp = *ap; + if (i) floatinlet_new(&x->x_obj, &vp->a_w.w_float); + } + else if (ap->a_type == A_SYMBOL) + { + char c = *ap->a_w.w_symbol->s_name; + if (c == 's') + { + SETSYMBOL(vp, &s_symbol); + if (i) symbolinlet_new(&x->x_obj, &vp->a_w.w_symbol); + } + else if (c == 'p') + { + vp->a_type = A_POINTER; + vp->a_w.w_gpointer = gp; + gpointer_init(gp); + if (i) pointerinlet_new(&x->x_obj, gp); + gp++; + } + else + { + if (c != 'f') pd_error(x, "pack: %s: bad type", + ap->a_w.w_symbol->s_name); + SETFLOAT(vp, 0); + if (i) floatinlet_new(&x->x_obj, &vp->a_w.w_float); + } + } + } + outlet_new(&x->x_obj, &s_list); + return (x); +} + +static void pack_bang(t_pack *x) +{ + int i, reentered = 0, size = x->x_n * sizeof (t_atom); + t_gpointer *gp; + t_atom *outvec; + for (i = x->x_nptr, gp = x->x_gpointer; i--; gp++) + if (!gpointer_check(gp, 1)) + { + pd_error(x, "pack: stale pointer"); + return; + } + // reentrancy protection. The first time through use the pre-allocated + // x_outvec; if we're reentered we have to allocate new memory. + if (!x->x_outvec) + { + // LATER figure out how to deal with reentrancy and pointers... + if (x->x_nptr) + post("pack_bang: warning: reentry with pointers unprotected"); + outvec = t_getbytes(size); + reentered = 1; + } + else + { + outvec = x->x_outvec; + x->x_outvec = 0; + } + memcpy(outvec, x->x_vec, size); + outlet_list(x->x_obj.ob_outlet, &s_list, x->x_n, outvec); + if (reentered) + t_freebytes(outvec, size); + else x->x_outvec = outvec; +} + +static void pack_pointer(t_pack *x, t_gpointer *gp) +{ + if (x->x_vec->a_type == A_POINTER) + { + gpointer_unset(x->x_gpointer); + *x->x_gpointer = *gp; + if (gp->gp_stub) gp->gp_stub->gs_refcount++; + pack_bang(x); + } + else pd_error(x, "pack_pointer: wrong type"); +} + +static void pack_float(t_pack *x, t_float f) +{ + if (x->x_vec->a_type == A_FLOAT) + { + x->x_vec->a_w.w_float = f; + pack_bang(x); + } + else pd_error(x, "pack_float: wrong type"); +} + +static void pack_symbol(t_pack *x, t_symbol *s) +{ + if (x->x_vec->a_type == A_SYMBOL) + { + x->x_vec->a_w.w_symbol = s; + pack_bang(x); + } + else pd_error(x, "pack_symbol: wrong type"); +} + +static void pack_list(t_pack *x, t_symbol *s, int ac, t_atom *av) +{ + obj_list(&x->x_obj, 0, ac, av); +} + +static void pack_anything(t_pack *x, t_symbol *s, int ac, t_atom *av) +{ + t_atom *av2 = (t_atom *)getbytes((ac + 1) * sizeof(t_atom)); + int i; + for (i = 0; i < ac; i++) + av2[i + 1] = av[i]; + SETSYMBOL(av2, s); + obj_list(&x->x_obj, 0, ac+1, av2); + freebytes(av2, (ac + 1) * sizeof(t_atom)); +} + +static void pack_free(t_pack *x) +{ + t_gpointer *gp; + int i; + for (gp = x->x_gpointer, i = x->x_nptr; i--; gp++) + gpointer_unset(gp); + freebytes(x->x_vec, x->x_n * sizeof(*x->x_vec)); + freebytes(x->x_outvec, x->x_n * sizeof(*x->x_outvec)); + freebytes(x->x_gpointer, x->x_nptr * sizeof(*x->x_gpointer)); +} + +static void pack_setup(void) +{ + pack_class = class_new(gensym("pack"), (t_newmethod)pack_new, + (t_method)pack_free, sizeof(t_pack), 0, A_GIMME, 0); + class_addbang(pack_class, pack_bang); + class_addpointer(pack_class, pack_pointer); + class_addfloat(pack_class, pack_float); + class_addsymbol(pack_class, pack_symbol); + class_addlist(pack_class, pack_list); + class_addanything(pack_class, pack_anything); +} +*/ + +//////////////// MULTIPLEX ////////////// + + +/* + + + +static t_class *mux_class; +static t_class *muxproxy_class; + +typedef struct _mux +{ + t_object x_obj; + struct _muxproxy **x_proxy; + + int i_count; + int i_selected; + t_inlet **in; +} t_mux; + + +typedef struct _muxproxy +{ + t_pd p_pd; + t_mux *p_master; + int id; +} t_muxproxy; + +static void mux_select(t_mux *x, t_float f) +{ + x->i_selected=f; +} + +static void mux_anything(t_muxproxy *y, t_symbol *s, int argc, t_atom *argv) +{ + t_mux*x=y->p_master; + if(y->id==x->i_selected) + outlet_anything(x->x_obj.ob_outlet, s, argc, argv); +} + +static void *mux_new(t_symbol *s, int argc, t_atom *argv) +{ + int n = (argc < 2)?2:argc; + t_mux *x = (t_mux *)pd_new(mux_class); + + x->i_selected=0; + x->i_count = n; + x->in = (t_inlet **)getbytes(x->i_count * sizeof(t_inlet *)); + x->x_proxy = (t_muxproxy**)getbytes(x->i_count * sizeof(t_muxproxy*)); + + for (n = 0; ni_count; n++) { + x->x_proxy[n]=(t_muxproxy*)pd_new(muxproxy_class); + x->x_proxy[n]->p_master = x; + x->x_proxy[n]->id=n; + x->in[n] = inlet_new ((t_object*)x, (t_pd*)x->x_proxy[n], 0,0); + } + + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("")); + + outlet_new(&x->x_obj, 0); + return (x); +} + +static void mux_free(t_mux*x){ + const int count = x->i_count; + + if(x->in && x->x_proxy){ + int n=0; + for(n=0; nin[n]){ + inlet_free(x->in[n]); + } + x->in[n]=0; + if(x->x_proxy[n]){ + t_muxproxy *y=x->x_proxy[n]; + y->p_master=0; + y->id=0; + pd_free(&y->p_pd); + } + x->x_proxy[n]=0; + } + freebytes(x->in, x->i_count * sizeof(t_inlet *)); + freebytes(x->x_proxy, x->i_count * sizeof(t_muxproxy*)); + } + + // pd_free(&y->p_pd); +} + +void multiplex_setup(void) +{ + mux_class = class_new(gensym("multiplex"), (t_newmethod)mux_new, + (t_method)mux_free, sizeof(t_mux), CLASS_NOINLET, A_GIMME, 0); + class_addcreator((t_newmethod)mux_new, gensym("mux"), A_GIMME, 0); + + class_addmethod (mux_class, (t_method)mux_select, gensym(""), A_DEFFLOAT, 0); + + muxproxy_class = class_new(0, 0, 0, + sizeof(t_muxproxy), + CLASS_PD | CLASS_NOINLET, 0); + class_addanything(muxproxy_class, mux_anything); + + + zexy_register("multiplex"); +} + +void mux_setup(void) +{ + multiplex_setup(); +} +*/ -- cgit v1.2.1