Fix pdbox makefile to actually take part in dependency generation
[kugel-rb.git] / apps / plugins / pdbox / PDa / intern / print~.c
blob04f85ed8b9290ec9aedacb6a51c5a024abeb3ccd
1 #include "../src/m_pd.h"
2 #include <../src/m_fixed.h>
4 static t_class *print_class;
6 typedef struct _print
8 t_object x_obj;
9 float x_f;
10 t_symbol *x_sym;
11 int x_count;
12 } t_print;
14 static t_int *print_perform(t_int *w)
16 t_print *x = (t_print *)(w[1]);
17 t_sample *in = (t_sample *)(w[2]);
18 int n = (int)(w[3]);
19 if (x->x_count)
21 post("%s:", x->x_sym->s_name);
22 if (n == 1) post("%8g", in[0]);
23 else if (n == 2) post("%8g %8g", in[0], in[1]);
24 else if (n == 4) post("%8g %8g %8g %8g",
25 in[0], in[1], in[2], in[3]);
26 else while (n > 0)
28 post("%-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g",
29 fixtof(in[0]),
30 fixtof(in[1]),
31 fixtof(in[2]),
32 fixtof(in[3]),
33 fixtof(in[4]),
34 fixtof(in[5]),
35 fixtof(in[6]),
36 fixtof(in[7]));
37 n -= 8;
38 in += 8;
40 x->x_count--;
42 return (w+4);
45 static void print_dsp(t_print *x, t_signal **sp)
47 dsp_add(print_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
50 static void print_float(t_print *x, t_float f)
52 if (f < 0) f = 0;
53 x->x_count = f;
56 static void print_bang(t_print *x)
58 x->x_count = 1;
61 static void *print_new(t_symbol *s)
63 t_print *x = (t_print *)pd_new(print_class);
64 x->x_sym = (s->s_name[0]? s : gensym("print~"));
65 x->x_count = 0;
66 x->x_f = 0;
67 return (x);
70 void print_tilde_setup(void)
72 print_class = class_new(gensym("print~"), (t_newmethod)print_new, 0,
73 sizeof(t_print), 0, A_DEFSYM, 0);
74 CLASS_MAINSIGNALIN(print_class, t_print, x_f);
75 class_addmethod(print_class, (t_method)print_dsp, gensym("dsp"), 0);
76 class_addbang(print_class, print_bang);
77 class_addfloat(print_class, print_float);