aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--reference/pack~-help.pd7
-rw-r--r--src/pack~.c27
2 files changed, 26 insertions, 8 deletions
diff --git a/reference/pack~-help.pd b/reference/pack~-help.pd
index 297e005..ac13977 100644
--- a/reference/pack~-help.pd
+++ b/reference/pack~-help.pd
@@ -2,7 +2,7 @@
#X floatatom 83 92 0 0 0 0 - - -;
#X obj 83 111 osc~ 689.062;
#X obj 83 320 unpack 0 0 0;
-#X obj 240 302 print;
+#X obj 240 322 print;
#X floatatom 83 359 0 0 0 0 - - -;
#X floatatom 150 339 0 0 0 0 - - -;
#X obj 83 230 t l l;
@@ -19,16 +19,19 @@
#X obj 369 208 unpack~;
#X text 98 379 1st and 3rd sample of each signal-vector;
#X text 434 36 part of zexy;
+#X obj 240 302 t l b;
#X connect 0 0 1 0;
#X connect 1 0 13 0;
#X connect 2 0 4 0;
#X connect 2 2 5 0;
#X connect 6 0 10 0;
#X connect 6 1 7 0;
-#X connect 7 0 3 0;
+#X connect 7 0 20 0;
#X connect 8 0 7 1;
#X connect 9 0 7 1;
#X connect 10 0 2 0;
#X connect 11 0 10 1;
#X connect 12 0 10 1;
#X connect 13 0 6 0;
+#X connect 20 0 3 0;
+#X connect 20 1 9 0;
diff --git a/src/pack~.c b/src/pack~.c
index e195573..8cdd03f 100644
--- a/src/pack~.c
+++ b/src/pack~.c
@@ -28,9 +28,15 @@ typedef struct _sigpack
int vector_length;
t_atom *buffer;
-
+ t_clock*x_clock;
+ int x_outputindsp;
} t_sigpack;
+static void *sigpack_tick(t_sigpack*x)
+{
+ outlet_list(x->x_obj.ob_outlet, &s_list, x->vector_length, x->buffer);
+}
+
static t_int *sigpack_perform(t_int *w)
{
t_sample *in = (t_sample *)(w[1]);
@@ -43,10 +49,11 @@ static t_int *sigpack_perform(t_int *w)
SETFLOAT(&buf[i], f);
i++;
}
-#ifdef __GNUC__
-# warning defer list-output to next block with a clock!
-#endif
- outlet_list(x->x_obj.ob_outlet, &s_list, x->vector_length, x->buffer);
+ if(x->x_outputindsp) {
+ sigpack_tick(x);
+ } else {
+ clock_delay(x->x_clock, 0);
+ }
return (w+4);
}
@@ -61,12 +68,20 @@ static void sigpack_dsp(t_sigpack *x, t_signal **sp)
dsp_add(sigpack_perform, 3, sp[0]->s_vec, x, sp[0]->s_n);
}
+static void *sigpack_free(t_sigpack*x)
+{
+ clock_free(x->x_clock);
+}
+
static void *sigpack_new(void)
{
t_sigpack *x = (t_sigpack *)pd_new(sigpack_class);
x->vector_length = 0;
x->buffer = 0;
outlet_new(&x->x_obj, gensym("list"));
+ x->x_clock=clock_new(x, (t_method)sigpack_tick);
+
+ x->x_outputindsp=0;
return (x);
}
@@ -78,7 +93,7 @@ static void sigpack_help(void)
void pack_tilde_setup(void)
{
- sigpack_class = class_new(gensym("pack~"), (t_newmethod)sigpack_new, 0,
+ sigpack_class = class_new(gensym("pack~"), (t_newmethod)sigpack_new, (t_method)sigpack_free,
sizeof(t_sigpack), 0, A_DEFFLOAT, 0);
class_addmethod(sigpack_class, nullfn, gensym("signal"), 0);
class_addmethod(sigpack_class, (t_method)sigpack_dsp, gensym("dsp"), 0);