diff options
Diffstat (limited to 'apps/plugins/pdbox/PDa/intern/line~.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/intern/line~.c | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/apps/plugins/pdbox/PDa/intern/line~.c b/apps/plugins/pdbox/PDa/intern/line~.c index ac7af8721e..f37f23c19d 100644 --- a/apps/plugins/pdbox/PDa/intern/line~.c +++ b/apps/plugins/pdbox/PDa/intern/line~.c | |||
@@ -98,105 +98,3 @@ void line_tilde_setup(void) | |||
98 | class_addmethod(line_class, (t_method)line_stop, gensym("stop"), 0); | 98 | class_addmethod(line_class, (t_method)line_stop, gensym("stop"), 0); |
99 | } | 99 | } |
100 | 100 | ||
101 | |||
102 | #include <m_pd.h> | ||
103 | #include <m_fixed.h> | ||
104 | |||
105 | static t_class *line_class; | ||
106 | |||
107 | typedef struct _line | ||
108 | { | ||
109 | t_object x_obj; | ||
110 | t_sample x_target; | ||
111 | t_sample x_value; | ||
112 | t_sample x_biginc; | ||
113 | t_sample x_inc; | ||
114 | t_sample x_1overn; | ||
115 | t_sample x_msectodsptick; | ||
116 | t_floatarg x_inletvalue; | ||
117 | t_floatarg x_inletwas; | ||
118 | int x_ticksleft; | ||
119 | int x_retarget; | ||
120 | } t_line; | ||
121 | |||
122 | static t_int *line_perform(t_int *w) | ||
123 | { | ||
124 | t_line *x = (t_line *)(w[1]); | ||
125 | t_sample *out = (t_sample *)(w[2]); | ||
126 | int n = (int)(w[3]); | ||
127 | t_sample f = x->x_value; | ||
128 | |||
129 | if (x->x_retarget) | ||
130 | { | ||
131 | int nticks = mult(ftofix(x->x_inletwas),x->x_msectodsptick); | ||
132 | if (!nticks) nticks = itofix(1); | ||
133 | x->x_ticksleft = fixtoi(nticks); | ||
134 | x->x_biginc = (x->x_target - x->x_value); | ||
135 | x->x_biginc = idiv(x->x_biginc,nticks); | ||
136 | x->x_inc = mult(x->x_1overn, x->x_biginc); | ||
137 | x->x_retarget = 0; | ||
138 | } | ||
139 | if (x->x_ticksleft) | ||
140 | { | ||
141 | t_sample f = x->x_value; | ||
142 | while (n--) *out++ = f, f += x->x_inc; | ||
143 | x->x_value += x->x_biginc; | ||
144 | x->x_ticksleft--; | ||
145 | } | ||
146 | else | ||
147 | { | ||
148 | x->x_value = x->x_target; | ||
149 | while (n--) *out++ = x->x_value; | ||
150 | } | ||
151 | return (w+4); | ||
152 | } | ||
153 | |||
154 | static void line_float(t_line *x, t_float f) | ||
155 | { | ||
156 | if (x->x_inletvalue <= 0) | ||
157 | { | ||
158 | x->x_target = x->x_value = ftofix(f); | ||
159 | x->x_ticksleft = x->x_retarget = 0; | ||
160 | } | ||
161 | else | ||
162 | { | ||
163 | x->x_target = ftofix(f); | ||
164 | x->x_retarget = 1; | ||
165 | x->x_inletwas = x->x_inletvalue; | ||
166 | x->x_inletvalue = 0; | ||
167 | } | ||
168 | } | ||
169 | |||
170 | static void line_stop(t_line *x) | ||
171 | { | ||
172 | x->x_target = x->x_value; | ||
173 | x->x_ticksleft = x->x_retarget = 0; | ||
174 | } | ||
175 | |||
176 | static void line_dsp(t_line *x, t_signal **sp) | ||
177 | { | ||
178 | dsp_add(line_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); | ||
179 | x->x_1overn = ftofix(1)/sp[0]->s_n; | ||
180 | x->x_msectodsptick = idiv(sp[0]->s_sr, (1000 * sp[0]->s_n)); | ||
181 | } | ||
182 | |||
183 | static void *line_new(void) | ||
184 | { | ||
185 | t_line *x = (t_line *)pd_new(line_class); | ||
186 | outlet_new(&x->x_obj, gensym("signal")); | ||
187 | floatinlet_new(&x->x_obj, &x->x_inletvalue); | ||
188 | x->x_ticksleft = x->x_retarget = 0; | ||
189 | x->x_value = x->x_target = x->x_inletvalue = x->x_inletwas = 0; | ||
190 | return (x); | ||
191 | } | ||
192 | |||
193 | void line_tilde_setup(void) | ||
194 | { | ||
195 | line_class = class_new(gensym("line~"), line_new, 0, | ||
196 | sizeof(t_line), 0, 0); | ||
197 | class_addfloat(line_class, (t_method)line_float); | ||
198 | class_addmethod(line_class, (t_method)line_dsp, gensym("dsp"), 0); | ||
199 | class_addmethod(line_class, (t_method)line_stop, gensym("stop"), 0); | ||
200 | } | ||
201 | |||
202 | |||