[PD] [announce] extention patch to "gate" of iemlib1

Orm Finnendahl finnendahl at folkwang-hochschule.de
Sun May 5 19:31:46 CEST 2002


Hi,

here is an extention of the gate external of iemlib1 (it's a patch
file for gate.c). It basically adds the functionality of Max/MSP's
gate enabling to route to more than 1 outlet. Except for the (still)
swapped inlets I think it's now compatible to the Max/MSP object.

The object is fully backwards compatible to the old gate object,
adding an optional second argument to specify an initialization for
the route. Compared to the original object, efficiency is exactly the
same for the left inlet, and slightly less efficient for the right
inlet, due to error processing. I also updated the help patch and
think it'd be nice, if it got integrated into the iemlib1 (is that
possible, Thomas?).

Enjoy,

Orm

-------------- next part --------------
6c6,8
<     float     x_state;
---
>     int       num_outlets;
>     void      *x_curr_outlet;
>     void      *x_outlet[10];
13,14c15,16
<     if(x->x_state != 0)
< 	outlet_bang(x->x_obj.ob_outlet);
---
>     if(x->x_curr_outlet)
> 	outlet_bang(x->x_curr_outlet);
19,20c21,22
<     if(x->x_state != 0)
< 	outlet_pointer(x->x_obj.ob_outlet, gp);
---
>     if(x->x_curr_outlet)
> 	outlet_pointer(x->x_curr_outlet, gp);
25,26c27,28
<     if(x->x_state != 0)
< 	outlet_float(x->x_obj.ob_outlet, f);
---
>     if(x->x_curr_outlet)
> 	outlet_float(x->x_curr_outlet, f);
31,32c33,34
<     if(x->x_state != 0)
< 	outlet_symbol(x->x_obj.ob_outlet, s);
---
>     if(x->x_curr_outlet)
> 	outlet_symbol(x->x_curr_outlet, s);
37,38c39,40
<     if(x->x_state != 0)
< 	outlet_list(x->x_obj.ob_outlet, s, argc, argv);
---
>     if(x->x_curr_outlet)
> 	outlet_list(x->x_curr_outlet, s, argc, argv);
43,44c45,46
<     if(x->x_state != 0)
< 	outlet_anything(x->x_obj.ob_outlet, s, argc, argv);
---
>     if(x->x_curr_outlet)
> 	outlet_anything(x->x_curr_outlet, s, argc, argv);
47c49
< static void *gate_new(t_floatarg f)
---
> static void gate_state(t_gate *x, t_floatarg f)
48a51,57
>   x->x_curr_outlet = (f < 1) ? 0 : (f >= x->num_outlets) ? x->x_outlet[x->num_outlets-1] : x->x_outlet[(int) f-1];
> }
> 
> static void *gate_new(t_floatarg f1, t_floatarg f2)
> {
>     int i;
> 
50,52c59,81
<     floatinlet_new(&x->x_obj, &x->x_state);
<     outlet_new(&x->x_obj, 0);
<     x->x_state = (f==0.0)?0:1;
---
>     inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym(""));
>     x->num_outlets = (f1<=1) ? 1 : (f1>=10) ? 10 : (int) f1;
>     for (i = 0; i < x->num_outlets; i++)
>       x->x_outlet[i] = outlet_new(&x->x_obj, 0);
>     
>       if (f2 < 0) {
>         x->x_curr_outlet = 0;
>       }
>       else {
>         if (f2 == 0) {
>           if (f1 < 1)
>             x->x_curr_outlet = 0;
>           else
>             x->x_curr_outlet = x->x_outlet[x->num_outlets-1];
>         }
>         else {
>           if (f2 >= x->num_outlets)
>             x->x_curr_outlet = x->x_outlet[x->num_outlets-1];
>           else 
>             x->x_curr_outlet = x->x_outlet[(int)f2 - 1];
>         }
>       }
>     post("gate_new: %d %d", (int)f1, (int)f2);
59c88
<     	sizeof(t_gate), 0, A_DEFFLOAT, 0);
---
>     	sizeof(t_gate), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
65a95
>     class_addmethod  (gate_class, (t_method)gate_state, gensym(""), A_FLOAT, 0);
-------------- next part --------------
#N canvas 337 183 650 395 10;
#X text 11 301 (c) musil at iem.kug.ac.at;
#X text 53 314 IEM KUG;
#X text 28 326 graz \, austria 2001;
#X obj 9 37 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144 -1
-1;
#X msg 34 36 33;
#X msg 51 58 -3.14;
#X msg 74 100 11 22 33.33;
#X msg 64 78 open xxx;
#X msg 94 122 funny;
#X text 7 8 gate;
#X text 12 266 the original object spigot;
#X obj 19 227 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144 -1
-1;
#X text 18 276 (c) miller puckette;
#X text 13 350 extention for multiple outlets;
#X text 11 366 (c) Orm Finnendahl 2002;
#X obj 90 227 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144 -1
-1;
#X obj 9 245 print left;
#X text 213 197 1.arg: number of outlets of gate (<= 10) (opt. \, default
= 1);
#X text 263 229 < 0 : gate is closed;
#X text 462 257 to rightmost outlet;
#X text 263 245 == 0 or >= number of outlets : inlet gets routed;
#X text 263 272 else : inlet gets routed to <arg-2> outlet (from left)
\,;
#X text 213 215 2.arg: control-state of gate (opt \, default = 0):
;
#X text 92 157 gate: select outlet;
#X msg 66 176 0;
#X msg 97 176 1;
#X msg 128 176 2;
#X msg 158 176 3;
#X obj 9 206 gate 3 1;
#X obj 176 245 print right;
#X obj 87 245 print middle;
#X obj 180 226 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144
-1 -1;
#X text 44 8 : route a stream of messages to different outlets (or
none);
#X connect 3 0 28 0;
#X connect 4 0 28 0;
#X connect 5 0 28 0;
#X connect 6 0 28 0;
#X connect 7 0 28 0;
#X connect 8 0 28 0;
#X connect 24 0 28 1;
#X connect 25 0 28 1;
#X connect 26 0 28 1;
#X connect 27 0 28 1;
#X connect 28 0 11 0;
#X connect 28 0 16 0;
#X connect 28 1 30 0;
#X connect 28 1 15 0;
#X connect 28 2 31 0;
#X connect 28 2 29 0;


More information about the Pd-list mailing list