aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/help-pdp_canvas.pd7
-rw-r--r--modules/pdp_canvas.c21
2 files changed, 28 insertions, 0 deletions
diff --git a/doc/help-pdp_canvas.pd b/doc/help-pdp_canvas.pd
index 0e61f56..36a2f76 100644
--- a/doc/help-pdp_canvas.pd
+++ b/doc/help-pdp_canvas.pd
@@ -89,6 +89,11 @@
#X msg 83 393 dim 640 480;
#X obj 234 432 pdp_canvas 640 480 3;
#X obj 234 497 route press drag release;
+#X msg 546 428 average \$1;
+#X obj 629 429 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X text 544 451 Average sources at intersections;
+#X text 544 463 ( default = 0 );
#X connect 0 0 74 0;
#X connect 1 0 8 0;
#X connect 2 0 9 0;
@@ -160,3 +165,5 @@
#X connect 74 0 63 0;
#X connect 74 1 64 0;
#X connect 74 2 65 0;
+#X connect 75 0 73 0;
+#X connect 76 0 75 0;
diff --git a/modules/pdp_canvas.c b/modules/pdp_canvas.c
index 80ce63e..1099fe8 100644
--- a/modules/pdp_canvas.c
+++ b/modules/pdp_canvas.c
@@ -46,6 +46,8 @@ typedef struct pdp_canvas_struct
t_float x_xmouse;
t_float x_ymouse;
+ t_int x_average;
+
t_int *x_packets;
t_int *x_widths;
t_int *x_heights;
@@ -114,6 +116,15 @@ static void pdp_canvas_process_yv12(t_pdp_canvas *x)
}
}
}
+ if ( ( nbs != 0 ) && x->x_average )
+ {
+ *(pY+py*x->x_owidth+px) /= nbs;
+ if ( (px%2==0) && (py%2==0) )
+ {
+ *(pU+(py>>1)*(x->x_owidth>>1)+(px>>1)) /= nbs;
+ *(pV+(py>>1)*(x->x_owidth>>1)+(px>>1)) /= nbs;
+ }
+ }
}
}
@@ -207,6 +218,14 @@ static void pdp_canvas_unselect(t_pdp_canvas *x)
x->x_current = -1;
}
+static void pdp_canvas_average(t_pdp_canvas *x, t_floatarg bvalue)
+{
+ if ( ( bvalue == 0.0 ) || ( bvalue == 1.0 ) )
+ {
+ x->x_average = (int) bvalue;
+ }
+}
+
static void pdp_canvas_input(t_pdp_canvas *x, t_symbol *s, t_floatarg f, t_int ni)
{
t_pdp *header;
@@ -374,6 +393,7 @@ void *pdp_canvas_new(t_symbol *s, int argc, t_atom *argv)
x->x_yoffsets[ii] = 0.;
}
x->x_current = -1;
+ x->x_average = 0;
x->x_outlet0 = outlet_new(&x->x_obj, &s_anything);
return (void *)x;
@@ -409,6 +429,7 @@ void pdp_canvas_setup(void)
class_addmethod(pdp_canvas_class, (t_method)pdp_canvas_select, gensym("select"), A_DEFFLOAT, A_DEFFLOAT, A_NULL);
class_addmethod(pdp_canvas_class, (t_method)pdp_canvas_drag, gensym("drag"), A_DEFFLOAT, A_DEFFLOAT, A_NULL);
class_addmethod(pdp_canvas_class, (t_method)pdp_canvas_unselect, gensym("unselect"), A_NULL);
+ class_addmethod(pdp_canvas_class, (t_method)pdp_canvas_average, gensym("average"), A_DEFFLOAT, A_NULL);
}