diff options
Diffstat (limited to 'apps/plugins/pdbox/PDa/intern/sig~.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/intern/sig~.c | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/apps/plugins/pdbox/PDa/intern/sig~.c b/apps/plugins/pdbox/PDa/intern/sig~.c new file mode 100644 index 0000000000..70a616ce23 --- /dev/null +++ b/apps/plugins/pdbox/PDa/intern/sig~.c | |||
@@ -0,0 +1,134 @@ | |||
1 | #include <m_pd.h> | ||
2 | #include <m_fixed.h> | ||
3 | |||
4 | static t_class *sig_tilde_class; | ||
5 | |||
6 | typedef struct _sig | ||
7 | { | ||
8 | t_object x_obj; | ||
9 | t_sample x_f; | ||
10 | } t_sig; | ||
11 | |||
12 | static t_int *sig_tilde_perform(t_int *w) | ||
13 | { | ||
14 | t_sample f = *(t_sample *)(w[1]); | ||
15 | t_sample *out = (t_sample *)(w[2]); | ||
16 | int n = (int)(w[3]); | ||
17 | while (n--) | ||
18 | *out++ = f; | ||
19 | return (w+4); | ||
20 | } | ||
21 | |||
22 | static t_int *sig_tilde_perf8(t_int *w) | ||
23 | { | ||
24 | t_sample f = *(t_sample *)(w[1]); | ||
25 | t_sample *out = (t_sample *)(w[2]); | ||
26 | int n = (int)(w[3]); | ||
27 | |||
28 | for (; n; n -= 8, out += 8) | ||
29 | { | ||
30 | out[0] = f; | ||
31 | out[1] = f; | ||
32 | out[2] = f; | ||
33 | out[3] = f; | ||
34 | out[4] = f; | ||
35 | out[5] = f; | ||
36 | out[6] = f; | ||
37 | out[7] = f; | ||
38 | } | ||
39 | return (w+4); | ||
40 | } | ||
41 | |||
42 | |||
43 | static void sig_tilde_float(t_sig *x, t_float f) | ||
44 | { | ||
45 | x->x_f = ftofix(f); | ||
46 | } | ||
47 | |||
48 | static void sig_tilde_dsp(t_sig *x, t_signal **sp) | ||
49 | { | ||
50 | dsp_add(sig_tilde_perform, 3, &x->x_f, sp[0]->s_vec, sp[0]->s_n); | ||
51 | } | ||
52 | |||
53 | static void *sig_tilde_new(t_floatarg f) | ||
54 | { | ||
55 | t_sig *x = (t_sig *)pd_new(sig_tilde_class); | ||
56 | x->x_f = ftofix(f); | ||
57 | outlet_new(&x->x_obj, gensym("signal")); | ||
58 | return (x); | ||
59 | } | ||
60 | |||
61 | void sig_tilde_setup(void) | ||
62 | { | ||
63 | sig_tilde_class = class_new(gensym("sig~"), (t_newmethod)sig_tilde_new, 0, | ||
64 | sizeof(t_sig), 0, A_DEFFLOAT, 0); | ||
65 | class_addfloat(sig_tilde_class, (t_method)sig_tilde_float); | ||
66 | class_addmethod(sig_tilde_class, (t_method)sig_tilde_dsp, gensym("dsp"), 0); | ||
67 | } | ||
68 | #include <m_pd.h> | ||
69 | #include <m_fixed.h> | ||
70 | |||
71 | static t_class *sig_tilde_class; | ||
72 | |||
73 | typedef struct _sig | ||
74 | { | ||
75 | t_object x_obj; | ||
76 | t_sample x_f; | ||
77 | } t_sig; | ||
78 | |||
79 | static t_int *sig_tilde_perform(t_int *w) | ||
80 | { | ||
81 | t_sample f = *(t_sample *)(w[1]); | ||
82 | t_sample *out = (t_sample *)(w[2]); | ||
83 | int n = (int)(w[3]); | ||
84 | while (n--) | ||
85 | *out++ = f; | ||
86 | return (w+4); | ||
87 | } | ||
88 | |||
89 | static t_int *sig_tilde_perf8(t_int *w) | ||
90 | { | ||
91 | t_sample f = *(t_sample *)(w[1]); | ||
92 | t_sample *out = (t_sample *)(w[2]); | ||
93 | int n = (int)(w[3]); | ||
94 | |||
95 | for (; n; n -= 8, out += 8) | ||
96 | { | ||
97 | out[0] = f; | ||
98 | out[1] = f; | ||
99 | out[2] = f; | ||
100 | out[3] = f; | ||
101 | out[4] = f; | ||
102 | out[5] = f; | ||
103 | out[6] = f; | ||
104 | out[7] = f; | ||
105 | } | ||
106 | return (w+4); | ||
107 | } | ||
108 | |||
109 | |||
110 | static void sig_tilde_float(t_sig *x, t_float f) | ||
111 | { | ||
112 | x->x_f = ftofix(f); | ||
113 | } | ||
114 | |||
115 | static void sig_tilde_dsp(t_sig *x, t_signal **sp) | ||
116 | { | ||
117 | dsp_add(sig_tilde_perform, 3, &x->x_f, sp[0]->s_vec, sp[0]->s_n); | ||
118 | } | ||
119 | |||
120 | static void *sig_tilde_new(t_floatarg f) | ||
121 | { | ||
122 | t_sig *x = (t_sig *)pd_new(sig_tilde_class); | ||
123 | x->x_f = ftofix(f); | ||
124 | outlet_new(&x->x_obj, gensym("signal")); | ||
125 | return (x); | ||
126 | } | ||
127 | |||
128 | void sig_tilde_setup(void) | ||
129 | { | ||
130 | sig_tilde_class = class_new(gensym("sig~"), (t_newmethod)sig_tilde_new, 0, | ||
131 | sizeof(t_sig), 0, A_DEFFLOAT, 0); | ||
132 | class_addfloat(sig_tilde_class, (t_method)sig_tilde_float); | ||
133 | class_addmethod(sig_tilde_class, (t_method)sig_tilde_dsp, gensym("dsp"), 0); | ||
134 | } | ||