diff options
Diffstat (limited to 'apps/plugins/pdbox/PDa/intern/vsnapshot~.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/intern/vsnapshot~.c | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/apps/plugins/pdbox/PDa/intern/vsnapshot~.c b/apps/plugins/pdbox/PDa/intern/vsnapshot~.c index afa9417248..282a6f21f8 100644 --- a/apps/plugins/pdbox/PDa/intern/vsnapshot~.c +++ b/apps/plugins/pdbox/PDa/intern/vsnapshot~.c | |||
@@ -86,91 +86,3 @@ void vsnapshot_tilde_setup(void) | |||
86 | class_addbang(vsnapshot_tilde_class, vsnapshot_tilde_bang); | 86 | class_addbang(vsnapshot_tilde_class, vsnapshot_tilde_bang); |
87 | } | 87 | } |
88 | 88 | ||
89 | #include <m_pd.h> | ||
90 | #include <m_fixed.h> | ||
91 | |||
92 | |||
93 | static t_class *vsnapshot_tilde_class; | ||
94 | |||
95 | typedef struct _vsnapshot | ||
96 | { | ||
97 | t_object x_obj; | ||
98 | int x_n; | ||
99 | int x_gotone; | ||
100 | t_sample *x_vec; | ||
101 | float x_f; | ||
102 | float x_sampspermsec; | ||
103 | double x_time; | ||
104 | } t_vsnapshot; | ||
105 | |||
106 | static void *vsnapshot_tilde_new(void) | ||
107 | { | ||
108 | t_vsnapshot *x = (t_vsnapshot *)pd_new(vsnapshot_tilde_class); | ||
109 | outlet_new(&x->x_obj, &s_float); | ||
110 | x->x_f = 0; | ||
111 | x->x_n = 0; | ||
112 | x->x_vec = 0; | ||
113 | x->x_gotone = 0; | ||
114 | return (x); | ||
115 | } | ||
116 | |||
117 | static t_int *vsnapshot_tilde_perform(t_int *w) | ||
118 | { | ||
119 | t_sample *in = (t_sample *)(w[1]); | ||
120 | t_vsnapshot *x = (t_vsnapshot *)(w[2]); | ||
121 | t_sample *out = x->x_vec; | ||
122 | int n = x->x_n, i; | ||
123 | for (i = 0; i < n; i++) | ||
124 | out[i] = in[i]; | ||
125 | x->x_time = clock_getlogicaltime(); | ||
126 | x->x_gotone = 1; | ||
127 | return (w+3); | ||
128 | } | ||
129 | |||
130 | static void vsnapshot_tilde_dsp(t_vsnapshot *x, t_signal **sp) | ||
131 | { | ||
132 | int n = sp[0]->s_n; | ||
133 | if (n != x->x_n) | ||
134 | { | ||
135 | if (x->x_vec) | ||
136 | t_freebytes(x->x_vec, x->x_n * sizeof(t_sample)); | ||
137 | x->x_vec = (t_sample *)getbytes(n * sizeof(t_sample)); | ||
138 | x->x_gotone = 0; | ||
139 | x->x_n = n; | ||
140 | } | ||
141 | x->x_sampspermsec = sp[0]->s_sr / 1000; | ||
142 | dsp_add(vsnapshot_tilde_perform, 2, sp[0]->s_vec, x); | ||
143 | } | ||
144 | |||
145 | static void vsnapshot_tilde_bang(t_vsnapshot *x) | ||
146 | { | ||
147 | float val; | ||
148 | if (x->x_gotone) | ||
149 | { | ||
150 | int indx = clock_gettimesince(x->x_time) * x->x_sampspermsec; | ||
151 | if (indx < 0) | ||
152 | indx = 0; | ||
153 | else if (indx >= x->x_n) | ||
154 | indx = x->x_n - 1; | ||
155 | val = x->x_vec[indx]; | ||
156 | } | ||
157 | else val = 0; | ||
158 | outlet_float(x->x_obj.ob_outlet, val); | ||
159 | } | ||
160 | |||
161 | static void vsnapshot_tilde_ff(t_vsnapshot *x) | ||
162 | { | ||
163 | if (x->x_vec) | ||
164 | t_freebytes(x->x_vec, x->x_n * sizeof(t_sample)); | ||
165 | } | ||
166 | |||
167 | void vsnapshot_tilde_setup(void) | ||
168 | { | ||
169 | vsnapshot_tilde_class = class_new(gensym("vsnapshot~"), | ||
170 | vsnapshot_tilde_new, (t_method)vsnapshot_tilde_ff, | ||
171 | sizeof(t_vsnapshot), 0, 0); | ||
172 | CLASS_MAINSIGNALIN(vsnapshot_tilde_class, t_vsnapshot, x_f); | ||
173 | class_addmethod(vsnapshot_tilde_class, (t_method)vsnapshot_tilde_dsp, gensym("dsp"), 0); | ||
174 | class_addbang(vsnapshot_tilde_class, vsnapshot_tilde_bang); | ||
175 | } | ||
176 | |||