summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/src/g_vumeter.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2009-05-22 21:58:48 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2009-05-22 21:58:48 +0000
commit513389b4c1bc8afe4b2dc9947c534bfeb105e3da (patch)
tree10e673b35651ac567fed2eda0c679c7ade64cbc6 /apps/plugins/pdbox/PDa/src/g_vumeter.c
parent95fa7f6a2ef466444fbe3fe87efc6d5db6b77b36 (diff)
downloadrockbox-513389b4c1bc8afe4b2dc9947c534bfeb105e3da.tar.gz
rockbox-513389b4c1bc8afe4b2dc9947c534bfeb105e3da.zip
Add FS #10214. Initial commit of the original PDa code for the GSoC Pure Data plugin project of Wincent Balin. Stripped some non-sourcefiles and added a rockbox readme that needs a bit more info from Wincent. Is added to CATEGORIES and viewers, but not yet to SUBDIRS (ie doesn't build yet)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21044 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/g_vumeter.c')
-rw-r--r--apps/plugins/pdbox/PDa/src/g_vumeter.c1426
1 files changed, 1426 insertions, 0 deletions
diff --git a/apps/plugins/pdbox/PDa/src/g_vumeter.c b/apps/plugins/pdbox/PDa/src/g_vumeter.c
new file mode 100644
index 0000000000..c7b3f1f209
--- /dev/null
+++ b/apps/plugins/pdbox/PDa/src/g_vumeter.c
@@ -0,0 +1,1426 @@
1/* Copyright (c) 1997-1999 Miller Puckette.
2 * For information on usage and redistribution, and for a DISCLAIMER OF ALL
3 * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
4
5/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
6/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
7
8
9#include <stdlib.h>
10#include <string.h>
11#include <stdio.h>
12#include <ctype.h>
13#include "m_pd.h"
14#include "g_canvas.h"
15#include "t_tk.h"
16#include "g_all_guis.h"
17#include <math.h>
18
19#ifdef MSW
20#include <io.h>
21#else
22#include <unistd.h>
23#endif
24
25/* ----- vu gui-peak- & rms- vu-meter-display ---------- */
26
27t_widgetbehavior vu_widgetbehavior;
28static t_class *vu_class;
29
30/* widget helper functions */
31
32static void vu_update_rms(t_vu *x, t_glist *glist)
33{
34 if(glist_isvisible(glist))
35 {
36 int w4=x->x_gui.x_w/4, off=text_ypix(&x->x_gui.x_obj, glist)-1;
37 int xpos=text_xpix(&x->x_gui.x_obj, glist), quad1=xpos+w4+1, quad3=xpos+x->x_gui.x_w-w4-1;
38
39 sys_vgui(".x%x.c coords %xRCOVER %d %d %d %d\n",
40 glist_getcanvas(glist), x, quad1, off, quad3,
41 off + (x->x_led_size+1)*(IEM_VU_STEPS-x->x_rms));
42 }
43}
44
45static void vu_update_peak(t_vu *x, t_glist *glist)
46{
47 t_canvas *canvas=glist_getcanvas(glist);
48
49 if(glist_isvisible(glist))
50 {
51 int xpos=text_xpix(&x->x_gui.x_obj, glist);
52 int ypos=text_ypix(&x->x_gui.x_obj, glist);
53
54 if(x->x_peak)
55 {
56 int i=iemgui_vu_col[x->x_peak];
57 int j=ypos + (x->x_led_size+1)*(IEM_VU_STEPS+1-x->x_peak)
58 - (x->x_led_size+1)/2;
59
60 sys_vgui(".x%x.c coords %xPLED %d %d %d %d\n", canvas, x,
61 xpos, j,
62 xpos+x->x_gui.x_w+1, j);
63 sys_vgui(".x%x.c itemconfigure %xPLED -fill #%6.6x\n", canvas, x,
64 iemgui_color_hex[i]);
65 }
66 else
67 {
68 int mid=xpos+x->x_gui.x_w/2;
69
70 sys_vgui(".x%x.c itemconfigure %xPLED -fill #%6.6x\n",
71 canvas, x, x->x_gui.x_bcol);
72 sys_vgui(".x%x.c coords %xPLED %d %d %d %d\n",
73 canvas, x, mid, ypos+20,
74 mid, ypos+20);
75 }
76 }
77}
78
79static void vu_draw_new(t_vu *x, t_glist *glist)
80{
81 t_canvas *canvas=glist_getcanvas(glist);
82
83 int xpos=text_xpix(&x->x_gui.x_obj, glist);
84 int ypos=text_ypix(&x->x_gui.x_obj, glist);
85 int w4=x->x_gui.x_w/4, mid=xpos+x->x_gui.x_w/2,
86 quad1=xpos+w4+1;
87 int quad3=xpos+x->x_gui.x_w-w4,
88 end=xpos+x->x_gui.x_w+4;
89 int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2;
90 int led_col, yyy, i, k4=ypos-k3;
91
92 sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE\n",
93 canvas, xpos-1, ypos-2,
94 xpos+x->x_gui.x_w+1,
95 ypos+x->x_gui.x_h+2, x->x_gui.x_bcol, x);
96 for(i=1; i<=IEM_VU_STEPS; i++)
97 {
98 led_col = iemgui_vu_col[i];
99 yyy = k4 + k1*(k2-i);
100 sys_vgui(".x%x.c create line %d %d %d %d -width %d -fill #%6.6x -tags %xRLED%d\n",
101 canvas, quad1, yyy, quad3, yyy, x->x_led_size, iemgui_color_hex[led_col], x, i);
102 if(((i+2)&3) && (x->x_scale))
103 sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
104 -font {%s %d bold} -fill #%6.6x -tags %xSCALE%d\n",
105 canvas, end, yyy+k3, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
106 x->x_gui.x_lcol, x, i);
107 }
108 if(x->x_scale)
109 {
110 i=IEM_VU_STEPS+1;
111 yyy = k4 + k1*(k2-i);
112 sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
113 -font {%s %d bold} -fill #%6.6x -tags %xSCALE%d\n",
114 canvas, end, yyy+k3, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
115 x->x_gui.x_lcol, x, i);
116 }
117 sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags %xRCOVER\n",
118 canvas, quad1, ypos-1, quad3-1,
119 ypos-1 + k1*IEM_VU_STEPS, x->x_gui.x_bcol, x->x_gui.x_bcol, x);
120 sys_vgui(".x%x.c create line %d %d %d %d -width %d -fill #%6.6x -tags %xPLED\n",
121 canvas, mid, ypos+10,
122 mid, ypos+10, x->x_led_size, x->x_gui.x_bcol, x);
123 sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
124 -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
125 canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy,
126 strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
127 x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
128 if(!x->x_gui.x_fsf.x_snd_able)
129 {
130 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
131 canvas,
132 xpos-1, ypos + x->x_gui.x_h+1,
133 xpos + IOWIDTH-1, ypos + x->x_gui.x_h+2,
134 x, 0);
135 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
136 canvas,
137 xpos+x->x_gui.x_w+1-IOWIDTH, ypos + x->x_gui.x_h+1,
138 xpos+x->x_gui.x_w+1, ypos + x->x_gui.x_h+2,
139 x, 1);
140 }
141 if(!x->x_gui.x_fsf.x_rcv_able)
142 {
143 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
144 canvas,
145 xpos-1, ypos-2,
146 xpos + IOWIDTH-1, ypos-1,
147 x, 0);
148 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
149 canvas,
150 xpos+x->x_gui.x_w+1-IOWIDTH, ypos-2,
151 xpos+x->x_gui.x_w+1, ypos-1,
152 x, 1);
153 }
154}
155
156
157static void vu_draw_move(t_vu *x, t_glist *glist)
158{
159 t_canvas *canvas=glist_getcanvas(glist);
160
161 int xpos=text_xpix(&x->x_gui.x_obj, glist);
162 int ypos=text_ypix(&x->x_gui.x_obj, glist);
163 int w4=x->x_gui.x_w/4, quad1=xpos+w4+1;
164 int quad3=xpos+x->x_gui.x_w-w4,
165 end=xpos+x->x_gui.x_w+4;
166 int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2;
167 int yyy, i, k4=ypos-k3;
168
169 sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
170 canvas, x, xpos-1, ypos-2,
171 xpos+x->x_gui.x_w+1,ypos+x->x_gui.x_h+2);
172 for(i=1; i<=IEM_VU_STEPS; i++)
173 {
174 yyy = k4 + k1*(k2-i);
175 sys_vgui(".x%x.c coords %xRLED%d %d %d %d %d\n",
176 canvas, x, i, quad1, yyy, quad3, yyy);
177 if(((i+2)&3) && (x->x_scale))
178 sys_vgui(".x%x.c coords %xSCALE%d %d %d\n",
179 canvas, x, i, end, yyy+k3);
180 }
181 if(x->x_scale)
182 {
183 i=IEM_VU_STEPS+1;
184 yyy = k4 + k1*(k2-i);
185 sys_vgui(".x%x.c coords %xSCALE%d %d %d\n",
186 canvas, x, i, end, yyy+k3);
187 }
188 vu_update_peak(x, glist);
189 vu_update_rms(x, glist);
190 sys_vgui(".x%x.c coords %xLABEL %d %d\n",
191 canvas, x, xpos+x->x_gui.x_ldx,
192 ypos+x->x_gui.x_ldy);
193 if(!x->x_gui.x_fsf.x_snd_able)
194 {
195 sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
196 canvas, x, 0,
197 xpos-1, ypos + x->x_gui.x_h+1,
198 xpos + IOWIDTH-1, ypos + x->x_gui.x_h+2);
199 sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
200 canvas, x, 1,
201 xpos+x->x_gui.x_w+1-IOWIDTH, ypos + x->x_gui.x_h+1,
202 xpos+x->x_gui.x_w+1, ypos + x->x_gui.x_h+2);
203 }
204 if(!x->x_gui.x_fsf.x_rcv_able)
205 {
206 sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
207 canvas, x, 0,
208 xpos-1, ypos-2,
209 xpos + IOWIDTH-1, ypos-1);
210 sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
211 canvas, x, 1,
212 xpos+x->x_gui.x_w+1-IOWIDTH, ypos-2,
213 xpos+x->x_gui.x_w+1, ypos-1);
214 }
215}
216
217static void vu_draw_erase(t_vu* x,t_glist* glist)
218{
219 int i;
220 t_canvas *canvas=glist_getcanvas(glist);
221
222 sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
223 for(i=1; i<=IEM_VU_STEPS; i++)
224 {
225 sys_vgui(".x%x.c delete %xRLED%d\n", canvas, x, i);
226 if(((i+2)&3) && (x->x_scale))
227 sys_vgui(".x%x.c delete %xSCALE%d\n", canvas, x, i);
228 }
229 if(x->x_scale)
230 {
231 i=IEM_VU_STEPS+1;
232 sys_vgui(".x%x.c delete %xSCALE%d\n", canvas, x, i);
233 }
234 sys_vgui(".x%x.c delete %xPLED\n", canvas, x);
235 sys_vgui(".x%x.c delete %xRCOVER\n", canvas, x);
236 sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
237 if(!x->x_gui.x_fsf.x_snd_able)
238 {
239 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
240 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 1);
241 }
242 if(!x->x_gui.x_fsf.x_rcv_able)
243 {
244 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
245 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 1);
246 }
247}
248
249static void vu_draw_config(t_vu* x, t_glist* glist)
250{
251 int i;
252 t_canvas *canvas=glist_getcanvas(glist);
253
254 sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
255 for(i=1; i<=IEM_VU_STEPS; i++)
256 {
257 sys_vgui(".x%x.c itemconfigure %xRLED%d -width %d\n", canvas, x, i,
258 x->x_led_size);
259 if(((i+2)&3) && (x->x_scale))
260 sys_vgui(".x%x.c itemconfigure %xSCALE%d -text {%s} -font {%s %d bold} -fill #%6.6x\n",
261 canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
262 x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol);
263 }
264 if(x->x_scale)
265 {
266 i=IEM_VU_STEPS+1;
267 sys_vgui(".x%x.c itemconfigure %xSCALE%d -text {%s} -font {%s %d bold} -fill #%6.6x\n",
268 canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
269 x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol);
270 }
271 sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
272 canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
273 x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
274 strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
275
276 sys_vgui(".x%x.c itemconfigure %xRCOVER -fill #%6.6x -outline #%6.6x\n", canvas,
277 x, x->x_gui.x_bcol, x->x_gui.x_bcol);
278 sys_vgui(".x%x.c itemconfigure %xPLED -width %d\n", canvas, x,
279 x->x_led_size);
280}
281
282static void vu_draw_io(t_vu* x, t_glist* glist, int old_snd_rcv_flags)
283{
284 int xpos=text_xpix(&x->x_gui.x_obj, glist);
285 int ypos=text_ypix(&x->x_gui.x_obj, glist);
286 t_canvas *canvas=glist_getcanvas(glist);
287
288 if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
289 {
290 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
291 canvas,
292 xpos-1, ypos + x->x_gui.x_h+1,
293 xpos + IOWIDTH-1, ypos + x->x_gui.x_h+2,
294 x, 0);
295 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
296 canvas,
297 xpos+x->x_gui.x_w+1-IOWIDTH, ypos + x->x_gui.x_h+1,
298 xpos+x->x_gui.x_w+1, ypos + x->x_gui.x_h+2,
299 x, 1);
300 }
301 if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
302 {
303 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
304 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 1);
305 }
306 if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
307 {
308 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
309 canvas,
310 xpos-1, ypos-2,
311 xpos + IOWIDTH-1, ypos-1,
312 x, 0);
313 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
314 canvas,
315 xpos+x->x_gui.x_w+1-IOWIDTH, ypos-2,
316 xpos+x->x_gui.x_w+1, ypos-1,
317 x, 1);
318 }
319 if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
320 {
321 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
322 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 1);
323 }
324}
325
326static void vu_draw_select(t_vu* x,t_glist* glist)
327{
328 int i;
329 t_canvas *canvas=glist_getcanvas(glist);
330
331 if(x->x_gui.x_fsf.x_selected)
332 {
333 sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
334 for(i=1; i<=IEM_VU_STEPS; i++)
335 {
336 if(((i+2)&3) && (x->x_scale))
337 sys_vgui(".x%x.c itemconfigure %xSCALE%d -fill #%6.6x\n",
338 canvas, x, i, IEM_GUI_COLOR_SELECTED);
339 }
340 if(x->x_scale)
341 {
342 i=IEM_VU_STEPS+1;
343 sys_vgui(".x%x.c itemconfigure %xSCALE%d -fill #%6.6x\n",
344 canvas, x, i, IEM_GUI_COLOR_SELECTED);
345 }
346 sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
347 }
348 else
349 {
350 sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
351 for(i=1; i<=IEM_VU_STEPS; i++)
352 {
353 if(((i+2)&3) && (x->x_scale))
354 sys_vgui(".x%x.c itemconfigure %xSCALE%d -fill #%6.6x\n",
355 canvas, x, i, x->x_gui.x_lcol);
356 }
357 if(x->x_scale)
358 {
359 i=IEM_VU_STEPS+1;
360 sys_vgui(".x%x.c itemconfigure %xSCALE%d -fill #%6.6x\n",
361 canvas, x, i, x->x_gui.x_lcol);
362 }
363 sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
364 }
365}
366
367void vu_draw(t_vu *x, t_glist *glist, int mode)
368{
369 if(mode == IEM_GUI_DRAW_MODE_MOVE)
370 vu_draw_move(x, glist);
371 else if(mode == IEM_GUI_DRAW_MODE_NEW)
372 vu_draw_new(x, glist);
373 else if(mode == IEM_GUI_DRAW_MODE_SELECT)
374 vu_draw_select(x, glist);
375 else if(mode == IEM_GUI_DRAW_MODE_ERASE)
376 vu_draw_erase(x, glist);
377 else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
378 vu_draw_config(x, glist);
379 else if(mode >= IEM_GUI_DRAW_MODE_IO)
380 vu_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
381}
382
383/* ------------------------ vu widgetbehaviour----------------------------- */
384
385
386static void vu_getrect(t_gobj *z, t_glist *glist,
387 int *xp1, int *yp1, int *xp2, int *yp2)
388{
389 t_vu* x = (t_vu*)z;
390
391 *xp1 = text_xpix(&x->x_gui.x_obj, glist) - 1;
392 *yp1 = text_ypix(&x->x_gui.x_obj, glist) - 2;
393 *xp2 = *xp1 + x->x_gui.x_w + 2;
394 *yp2 = *yp1 + x->x_gui.x_h + 4;
395}
396
397static void vu_save(t_gobj *z, t_binbuf *b)
398{
399 t_vu *x = (t_vu *)z;
400 int bflcol[3];
401 t_symbol *srl[3];
402
403 iemgui_save(&x->x_gui, srl, bflcol);
404 binbuf_addv(b, "ssiisiissiiiiiiii", gensym("#X"),gensym("obj"),
405 (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
406 gensym("vu"), x->x_gui.x_w, x->x_gui.x_h,
407 srl[1], srl[2],
408 x->x_gui.x_ldx, x->x_gui.x_ldy,
409 iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
410 bflcol[0], bflcol[2], x->x_scale,
411 iem_symargstoint(&x->x_gui.x_isa));
412 binbuf_addv(b, ";");
413}
414
415void vu_check_height(t_vu *x, int h)
416{
417 int n;
418
419 n = h / IEM_VU_STEPS;
420 if(n < IEM_VU_MINSIZE)
421 n = IEM_VU_MINSIZE;
422 x->x_led_size = n-1;
423 x->x_gui.x_h = IEM_VU_STEPS * n;
424}
425
426static void vu_scale(t_vu *x, t_floatarg fscale)
427{
428 int i, scale = (int)fscale;
429
430 if(scale != 0) scale = 1;
431 if(x->x_scale && !scale)
432 {
433 t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
434
435 x->x_scale = (int)scale;
436 if(glist_isvisible(x->x_gui.x_glist))
437 {
438 for(i=1; i<=IEM_VU_STEPS; i++)
439 {
440 if((i+2)&3)
441 sys_vgui(".x%x.c delete %xSCALE%d\n", canvas, x, i);
442 }
443 i=IEM_VU_STEPS+1;
444 sys_vgui(".x%x.c delete %xSCALE%d\n", canvas, x, i);
445 }
446 }
447 if(!x->x_scale && scale)
448 {
449 int w4=x->x_gui.x_w/4, end=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist)+x->x_gui.x_w+4;
450 int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2;
451 int yyy, k4=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist)-k3;
452 t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
453
454 x->x_scale = (int)scale;
455 if(glist_isvisible(x->x_gui.x_glist))
456 {
457 for(i=1; i<=IEM_VU_STEPS; i++)
458 {
459 yyy = k4 + k1*(k2-i);
460 if((i+2)&3)
461 sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
462 -font {%s %d bold} -fill #%6.6x -tags %xSCALE%d\n",
463 canvas, end, yyy+k3, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
464 x->x_gui.x_lcol, x, i);
465 }
466 i=IEM_VU_STEPS+1;
467 yyy = k4 + k1*(k2-i);
468 sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
469 -font {%s %d bold} -fill #%6.6x -tags %xSCALE%d\n",
470 canvas, end, yyy+k3, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
471 x->x_gui.x_lcol, x, i);
472 }
473 }
474}
475
476static void vu_properties(t_gobj *z, t_glist *owner)
477{
478 t_vu *x = (t_vu *)z;
479 char buf[800];
480 t_symbol *srl[3];
481
482 iemgui_properties(&x->x_gui, srl);
483 sprintf(buf, "pdtk_iemgui_dialog %%s VU-METER \
484 --------dimensions(pix)(pix):-------- %d %d width: %d %d height: \
485 empty 0.0 empty 0.0 empty %d \
486 %d no_scale scale %d %d empty %d \
487 %s %s \
488 %s %d %d \
489 %d %d \
490 %d %d %d\n",
491 x->x_gui.x_w, IEM_GUI_MINSIZE, x->x_gui.x_h, IEM_VU_STEPS*IEM_VU_MINSIZE,
492 0,/*no_schedule*/
493 x->x_scale, -1, -1, -1,/*no linlog, no init, no multi*/
494 "nosndno", srl[1]->s_name,/*no send*/
495 srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
496 x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
497 0xffffff & x->x_gui.x_bcol, -1/*no front-color*/, 0xffffff & x->x_gui.x_lcol);
498 gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
499}
500
501static void vu_dialog(t_vu *x, t_symbol *s, int argc, t_atom *argv)
502{
503 t_symbol *srl[3];
504 int w = (int)atom_getintarg(0, argc, argv);
505 int h = (int)atom_getintarg(1, argc, argv);
506 int scale = (int)atom_getintarg(4, argc, argv);
507 int sr_flags;
508
509 srl[0] = gensym("empty");
510 sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
511 x->x_gui.x_fsf.x_snd_able = 0;
512 x->x_gui.x_isa.x_loadinit = 0;
513 x->x_gui.x_w = iemgui_clip_size(w);
514 vu_check_height(x, h);
515 if(scale != 0)
516 scale = 1;
517 vu_scale(x, (float)scale);
518 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
519 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
520 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
521 canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
522}
523
524static void vu_size(t_vu *x, t_symbol *s, int ac, t_atom *av)
525{
526 x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
527 if(ac > 1)
528 vu_check_height(x, (int)atom_getintarg(1, ac, av));
529 if(glist_isvisible(x->x_gui.x_glist))
530 {
531 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
532 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
533 canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
534 }
535}
536
537static void vu_delta(t_vu *x, t_symbol *s, int ac, t_atom *av)
538{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
539
540static void vu_pos(t_vu *x, t_symbol *s, int ac, t_atom *av)
541{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
542
543static void vu_color(t_vu *x, t_symbol *s, int ac, t_atom *av)
544{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
545
546static void vu_receive(t_vu *x, t_symbol *s)
547{iemgui_receive(x, &x->x_gui, s);}
548
549static void vu_label(t_vu *x, t_symbol *s)
550{iemgui_label((void *)x, &x->x_gui, s);}
551
552static void vu_label_pos(t_vu *x, t_symbol *s, int ac, t_atom *av)
553{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
554
555static void vu_label_font(t_vu *x, t_symbol *s, int ac, t_atom *av)
556{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
557
558static void vu_float(t_vu *x, t_floatarg rms)
559{
560 int i;
561
562 if(rms <= IEM_VU_MINDB)
563 x->x_rms = 0;
564 else if(rms >= IEM_VU_MAXDB)
565 x->x_rms = IEM_VU_STEPS;
566 else
567 {
568 int i = (int)(2.0*(rms + IEM_VU_OFFSET));
569 x->x_rms = iemgui_vu_db2i[i];
570 }
571 i = (int)(100.0*rms + 10000.5);
572 rms = 0.01*(float)(i - 10000);
573 x->x_fr = rms;
574 outlet_float(x->x_out_rms, rms);
575 vu_update_rms(x, x->x_gui.x_glist);
576}
577
578static void vu_ft1(t_vu *x, t_floatarg peak)
579{
580 int i;
581
582 if(peak <= IEM_VU_MINDB)
583 x->x_peak = 0;
584 else if(peak >= IEM_VU_MAXDB)
585 x->x_peak = IEM_VU_STEPS;
586 else
587 {
588 int i = (int)(2.0*(peak + IEM_VU_OFFSET));
589 x->x_peak = iemgui_vu_db2i[i];
590 }
591 i = (int)(100.0*peak + 10000.5);
592 peak = 0.01*(float)(i - 10000);
593 x->x_fp = peak;
594 outlet_float(x->x_out_peak, peak);
595 vu_update_peak(x, x->x_gui.x_glist);
596}
597
598static void vu_bang(t_vu *x)
599{
600 outlet_float(x->x_out_peak, x->x_fp);
601 outlet_float(x->x_out_rms, x->x_fr);
602 vu_update_rms(x, x->x_gui.x_glist);
603 vu_update_peak(x, x->x_gui.x_glist);
604}
605
606static void *vu_new(t_symbol *s, int argc, t_atom *argv)
607{
608 t_vu *x = (t_vu *)pd_new(vu_class);
609 int bflcol[]={-66577, -1, -1};
610 int w=IEM_GUI_DEFAULTSIZE, h=IEM_VU_STEPS*IEM_VU_DEFAULTSIZE;
611 int ldx=-1, ldy=-8, f=0, fs=8, scale=1;
612 int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
613 char str[144];
614
615 iem_inttosymargs(&x->x_gui.x_isa, 0);
616 iem_inttofstyle(&x->x_gui.x_fsf, 0);
617
618 if((argc >= 11)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
619 &&(IS_A_SYMBOL(argv,2)||IS_A_FLOAT(argv,2))
620 &&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3))
621 &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
622 &&IS_A_FLOAT(argv,6)&&IS_A_FLOAT(argv,7)
623 &&IS_A_FLOAT(argv,8)&&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10))
624 {
625 w = (int)atom_getintarg(0, argc, argv);
626 h = (int)atom_getintarg(1, argc, argv);
627 iemgui_new_getnames(&x->x_gui, 1, argv);
628 ldx = (int)atom_getintarg(4, argc, argv);
629 ldy = (int)atom_getintarg(5, argc, argv);
630 iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(6, argc, argv));
631 fs = (int)atom_getintarg(7, argc, argv);
632 bflcol[0] = (int)atom_getintarg(8, argc, argv);
633 bflcol[2] = (int)atom_getintarg(9, argc, argv);
634 scale = (int)atom_getintarg(10, argc, argv);
635 }
636 else iemgui_new_getnames(&x->x_gui, 1, 0);
637 if((argc == 12)&&IS_A_FLOAT(argv,11))
638 iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(11, argc, argv));
639 x->x_gui.x_draw = (t_iemfunptr)vu_draw;
640
641 x->x_gui.x_fsf.x_snd_able = 0;
642 x->x_gui.x_fsf.x_rcv_able = 1;
643 x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
644 if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
645 x->x_gui.x_fsf.x_rcv_able = 0;
646 if (x->x_gui.x_fsf.x_font_style == 1)
647 strcpy(x->x_gui.x_font, "helvetica");
648 else if(x->x_gui.x_fsf.x_font_style == 2)
649 strcpy(x->x_gui.x_font, "times");
650 else { x->x_gui.x_fsf.x_font_style = 0;
651 strcpy(x->x_gui.x_font, "courier"); }
652 if(x->x_gui.x_fsf.x_rcv_able)
653 pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
654 x->x_gui.x_ldx = ldx;
655 x->x_gui.x_ldy = ldy;
656
657 if(fs < 4)
658 fs = 4;
659 x->x_gui.x_fontsize = fs;
660 x->x_gui.x_w = iemgui_clip_size(w);
661 vu_check_height(x, h);
662 iemgui_all_colfromload(&x->x_gui, bflcol);
663 if(scale != 0)
664 scale = 1;
665 x->x_scale = scale;
666 x->x_peak = 0;
667 x->x_rms = 0;
668 x->x_fp = -101.0;
669 x->x_fr = -101.0;
670 iemgui_verify_snd_ne_rcv(&x->x_gui);
671 inlet_new(&x->x_gui.x_obj, &x->x_gui.x_obj.ob_pd, &s_float, gensym("ft1"));
672 x->x_out_rms = outlet_new(&x->x_gui.x_obj, &s_float);
673 x->x_out_peak = outlet_new(&x->x_gui.x_obj, &s_float);
674 return (x);
675}
676
677static void vu_free(t_vu *x)
678{
679 if(x->x_gui.x_fsf.x_rcv_able)
680 pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
681 gfxstub_deleteforkey(x);
682}
683
684void g_vumeter_setup(void)
685{
686 vu_class = class_new(gensym("vu"), (t_newmethod)vu_new, (t_method)vu_free,
687 sizeof(t_vu), 0, A_GIMME, 0);
688 class_addbang(vu_class,vu_bang);
689 class_addfloat(vu_class,vu_float);
690 class_addmethod(vu_class, (t_method)vu_ft1, gensym("ft1"), A_FLOAT, 0);
691 class_addmethod(vu_class, (t_method)vu_dialog, gensym("dialog"),
692 A_GIMME, 0);
693 class_addmethod(vu_class, (t_method)vu_size, gensym("size"), A_GIMME, 0);
694 class_addmethod(vu_class, (t_method)vu_scale, gensym("scale"), A_DEFFLOAT, 0);
695 class_addmethod(vu_class, (t_method)vu_delta, gensym("delta"), A_GIMME, 0);
696 class_addmethod(vu_class, (t_method)vu_pos, gensym("pos"), A_GIMME, 0);
697 class_addmethod(vu_class, (t_method)vu_color, gensym("color"), A_GIMME, 0);
698 class_addmethod(vu_class, (t_method)vu_receive, gensym("receive"), A_DEFSYM, 0);
699 class_addmethod(vu_class, (t_method)vu_label, gensym("label"), A_DEFSYM, 0);
700 class_addmethod(vu_class, (t_method)vu_label_pos, gensym("label_pos"), A_GIMME, 0);
701 class_addmethod(vu_class, (t_method)vu_label_font, gensym("label_font"), A_GIMME, 0);
702 vu_widgetbehavior.w_getrectfn = vu_getrect;
703 vu_widgetbehavior.w_displacefn = iemgui_displace;
704 vu_widgetbehavior.w_selectfn = iemgui_select;
705 vu_widgetbehavior.w_activatefn = NULL;
706 vu_widgetbehavior.w_deletefn = iemgui_delete;
707 vu_widgetbehavior.w_visfn = iemgui_vis;
708 vu_widgetbehavior.w_clickfn = NULL;
709 class_setwidget(vu_class,&vu_widgetbehavior);
710 class_sethelpsymbol(vu_class, gensym("vu"));
711 class_setsavefn(vu_class, vu_save);
712 class_setpropertiesfn(vu_class, vu_properties);
713}
714/* Copyright (c) 1997-1999 Miller Puckette.
715 * For information on usage and redistribution, and for a DISCLAIMER OF ALL
716 * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
717
718/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
719/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
720
721
722#include <stdlib.h>
723#include <string.h>
724#include <stdio.h>
725#include <ctype.h>
726#include "m_pd.h"
727#include "g_canvas.h"
728#include "t_tk.h"
729#include "g_all_guis.h"
730#include <math.h>
731
732#ifdef MSW
733#include <io.h>
734#else
735#include <unistd.h>
736#endif
737
738/* ----- vu gui-peak- & rms- vu-meter-display ---------- */
739
740t_widgetbehavior vu_widgetbehavior;
741static t_class *vu_class;
742
743/* widget helper functions */
744
745static void vu_update_rms(t_vu *x, t_glist *glist)
746{
747 if(glist_isvisible(glist))
748 {
749 int w4=x->x_gui.x_w/4, off=text_ypix(&x->x_gui.x_obj, glist)-1;
750 int xpos=text_xpix(&x->x_gui.x_obj, glist), quad1=xpos+w4+1, quad3=xpos+x->x_gui.x_w-w4-1;
751
752 sys_vgui(".x%x.c coords %xRCOVER %d %d %d %d\n",
753 glist_getcanvas(glist), x, quad1, off, quad3,
754 off + (x->x_led_size+1)*(IEM_VU_STEPS-x->x_rms));
755 }
756}
757
758static void vu_update_peak(t_vu *x, t_glist *glist)
759{
760 t_canvas *canvas=glist_getcanvas(glist);
761
762 if(glist_isvisible(glist))
763 {
764 int xpos=text_xpix(&x->x_gui.x_obj, glist);
765 int ypos=text_ypix(&x->x_gui.x_obj, glist);
766
767 if(x->x_peak)
768 {
769 int i=iemgui_vu_col[x->x_peak];
770 int j=ypos + (x->x_led_size+1)*(IEM_VU_STEPS+1-x->x_peak)
771 - (x->x_led_size+1)/2;
772
773 sys_vgui(".x%x.c coords %xPLED %d %d %d %d\n", canvas, x,
774 xpos, j,
775 xpos+x->x_gui.x_w+1, j);
776 sys_vgui(".x%x.c itemconfigure %xPLED -fill #%6.6x\n", canvas, x,
777 iemgui_color_hex[i]);
778 }
779 else
780 {
781 int mid=xpos+x->x_gui.x_w/2;
782
783 sys_vgui(".x%x.c itemconfigure %xPLED -fill #%6.6x\n",
784 canvas, x, x->x_gui.x_bcol);
785 sys_vgui(".x%x.c coords %xPLED %d %d %d %d\n",
786 canvas, x, mid, ypos+20,
787 mid, ypos+20);
788 }
789 }
790}
791
792static void vu_draw_new(t_vu *x, t_glist *glist)
793{
794 t_canvas *canvas=glist_getcanvas(glist);
795
796 int xpos=text_xpix(&x->x_gui.x_obj, glist);
797 int ypos=text_ypix(&x->x_gui.x_obj, glist);
798 int w4=x->x_gui.x_w/4, mid=xpos+x->x_gui.x_w/2,
799 quad1=xpos+w4+1;
800 int quad3=xpos+x->x_gui.x_w-w4,
801 end=xpos+x->x_gui.x_w+4;
802 int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2;
803 int led_col, yyy, i, k4=ypos-k3;
804
805 sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE\n",
806 canvas, xpos-1, ypos-2,
807 xpos+x->x_gui.x_w+1,
808 ypos+x->x_gui.x_h+2, x->x_gui.x_bcol, x);
809 for(i=1; i<=IEM_VU_STEPS; i++)
810 {
811 led_col = iemgui_vu_col[i];
812 yyy = k4 + k1*(k2-i);
813 sys_vgui(".x%x.c create line %d %d %d %d -width %d -fill #%6.6x -tags %xRLED%d\n",
814 canvas, quad1, yyy, quad3, yyy, x->x_led_size, iemgui_color_hex[led_col], x, i);
815 if(((i+2)&3) && (x->x_scale))
816 sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
817 -font {%s %d bold} -fill #%6.6x -tags %xSCALE%d\n",
818 canvas, end, yyy+k3, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
819 x->x_gui.x_lcol, x, i);
820 }
821 if(x->x_scale)
822 {
823 i=IEM_VU_STEPS+1;
824 yyy = k4 + k1*(k2-i);
825 sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
826 -font {%s %d bold} -fill #%6.6x -tags %xSCALE%d\n",
827 canvas, end, yyy+k3, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
828 x->x_gui.x_lcol, x, i);
829 }
830 sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags %xRCOVER\n",
831 canvas, quad1, ypos-1, quad3-1,
832 ypos-1 + k1*IEM_VU_STEPS, x->x_gui.x_bcol, x->x_gui.x_bcol, x);
833 sys_vgui(".x%x.c create line %d %d %d %d -width %d -fill #%6.6x -tags %xPLED\n",
834 canvas, mid, ypos+10,
835 mid, ypos+10, x->x_led_size, x->x_gui.x_bcol, x);
836 sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
837 -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
838 canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy,
839 strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
840 x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
841 if(!x->x_gui.x_fsf.x_snd_able)
842 {
843 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
844 canvas,
845 xpos-1, ypos + x->x_gui.x_h+1,
846 xpos + IOWIDTH-1, ypos + x->x_gui.x_h+2,
847 x, 0);
848 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
849 canvas,
850 xpos+x->x_gui.x_w+1-IOWIDTH, ypos + x->x_gui.x_h+1,
851 xpos+x->x_gui.x_w+1, ypos + x->x_gui.x_h+2,
852 x, 1);
853 }
854 if(!x->x_gui.x_fsf.x_rcv_able)
855 {
856 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
857 canvas,
858 xpos-1, ypos-2,
859 xpos + IOWIDTH-1, ypos-1,
860 x, 0);
861 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
862 canvas,
863 xpos+x->x_gui.x_w+1-IOWIDTH, ypos-2,
864 xpos+x->x_gui.x_w+1, ypos-1,
865 x, 1);
866 }
867}
868
869
870static void vu_draw_move(t_vu *x, t_glist *glist)
871{
872 t_canvas *canvas=glist_getcanvas(glist);
873
874 int xpos=text_xpix(&x->x_gui.x_obj, glist);
875 int ypos=text_ypix(&x->x_gui.x_obj, glist);
876 int w4=x->x_gui.x_w/4, quad1=xpos+w4+1;
877 int quad3=xpos+x->x_gui.x_w-w4,
878 end=xpos+x->x_gui.x_w+4;
879 int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2;
880 int yyy, i, k4=ypos-k3;
881
882 sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
883 canvas, x, xpos-1, ypos-2,
884 xpos+x->x_gui.x_w+1,ypos+x->x_gui.x_h+2);
885 for(i=1; i<=IEM_VU_STEPS; i++)
886 {
887 yyy = k4 + k1*(k2-i);
888 sys_vgui(".x%x.c coords %xRLED%d %d %d %d %d\n",
889 canvas, x, i, quad1, yyy, quad3, yyy);
890 if(((i+2)&3) && (x->x_scale))
891 sys_vgui(".x%x.c coords %xSCALE%d %d %d\n",
892 canvas, x, i, end, yyy+k3);
893 }
894 if(x->x_scale)
895 {
896 i=IEM_VU_STEPS+1;
897 yyy = k4 + k1*(k2-i);
898 sys_vgui(".x%x.c coords %xSCALE%d %d %d\n",
899 canvas, x, i, end, yyy+k3);
900 }
901 vu_update_peak(x, glist);
902 vu_update_rms(x, glist);
903 sys_vgui(".x%x.c coords %xLABEL %d %d\n",
904 canvas, x, xpos+x->x_gui.x_ldx,
905 ypos+x->x_gui.x_ldy);
906 if(!x->x_gui.x_fsf.x_snd_able)
907 {
908 sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
909 canvas, x, 0,
910 xpos-1, ypos + x->x_gui.x_h+1,
911 xpos + IOWIDTH-1, ypos + x->x_gui.x_h+2);
912 sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
913 canvas, x, 1,
914 xpos+x->x_gui.x_w+1-IOWIDTH, ypos + x->x_gui.x_h+1,
915 xpos+x->x_gui.x_w+1, ypos + x->x_gui.x_h+2);
916 }
917 if(!x->x_gui.x_fsf.x_rcv_able)
918 {
919 sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
920 canvas, x, 0,
921 xpos-1, ypos-2,
922 xpos + IOWIDTH-1, ypos-1);
923 sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
924 canvas, x, 1,
925 xpos+x->x_gui.x_w+1-IOWIDTH, ypos-2,
926 xpos+x->x_gui.x_w+1, ypos-1);
927 }
928}
929
930static void vu_draw_erase(t_vu* x,t_glist* glist)
931{
932 int i;
933 t_canvas *canvas=glist_getcanvas(glist);
934
935 sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
936 for(i=1; i<=IEM_VU_STEPS; i++)
937 {
938 sys_vgui(".x%x.c delete %xRLED%d\n", canvas, x, i);
939 if(((i+2)&3) && (x->x_scale))
940 sys_vgui(".x%x.c delete %xSCALE%d\n", canvas, x, i);
941 }
942 if(x->x_scale)
943 {
944 i=IEM_VU_STEPS+1;
945 sys_vgui(".x%x.c delete %xSCALE%d\n", canvas, x, i);
946 }
947 sys_vgui(".x%x.c delete %xPLED\n", canvas, x);
948 sys_vgui(".x%x.c delete %xRCOVER\n", canvas, x);
949 sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
950 if(!x->x_gui.x_fsf.x_snd_able)
951 {
952 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
953 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 1);
954 }
955 if(!x->x_gui.x_fsf.x_rcv_able)
956 {
957 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
958 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 1);
959 }
960}
961
962static void vu_draw_config(t_vu* x, t_glist* glist)
963{
964 int i;
965 t_canvas *canvas=glist_getcanvas(glist);
966
967 sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
968 for(i=1; i<=IEM_VU_STEPS; i++)
969 {
970 sys_vgui(".x%x.c itemconfigure %xRLED%d -width %d\n", canvas, x, i,
971 x->x_led_size);
972 if(((i+2)&3) && (x->x_scale))
973 sys_vgui(".x%x.c itemconfigure %xSCALE%d -text {%s} -font {%s %d bold} -fill #%6.6x\n",
974 canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
975 x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol);
976 }
977 if(x->x_scale)
978 {
979 i=IEM_VU_STEPS+1;
980 sys_vgui(".x%x.c itemconfigure %xSCALE%d -text {%s} -font {%s %d bold} -fill #%6.6x\n",
981 canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
982 x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol);
983 }
984 sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
985 canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
986 x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
987 strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
988
989 sys_vgui(".x%x.c itemconfigure %xRCOVER -fill #%6.6x -outline #%6.6x\n", canvas,
990 x, x->x_gui.x_bcol, x->x_gui.x_bcol);
991 sys_vgui(".x%x.c itemconfigure %xPLED -width %d\n", canvas, x,
992 x->x_led_size);
993}
994
995static void vu_draw_io(t_vu* x, t_glist* glist, int old_snd_rcv_flags)
996{
997 int xpos=text_xpix(&x->x_gui.x_obj, glist);
998 int ypos=text_ypix(&x->x_gui.x_obj, glist);
999 t_canvas *canvas=glist_getcanvas(glist);
1000
1001 if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
1002 {
1003 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
1004 canvas,
1005 xpos-1, ypos + x->x_gui.x_h+1,
1006 xpos + IOWIDTH-1, ypos + x->x_gui.x_h+2,
1007 x, 0);
1008 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
1009 canvas,
1010 xpos+x->x_gui.x_w+1-IOWIDTH, ypos + x->x_gui.x_h+1,
1011 xpos+x->x_gui.x_w+1, ypos + x->x_gui.x_h+2,
1012 x, 1);
1013 }
1014 if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
1015 {
1016 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
1017 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 1);
1018 }
1019 if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
1020 {
1021 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
1022 canvas,
1023 xpos-1, ypos-2,
1024 xpos + IOWIDTH-1, ypos-1,
1025 x, 0);
1026 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
1027 canvas,
1028 xpos+x->x_gui.x_w+1-IOWIDTH, ypos-2,
1029 xpos+x->x_gui.x_w+1, ypos-1,
1030 x, 1);
1031 }
1032 if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
1033 {
1034 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
1035 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 1);
1036 }
1037}
1038
1039static void vu_draw_select(t_vu* x,t_glist* glist)
1040{
1041 int i;
1042 t_canvas *canvas=glist_getcanvas(glist);
1043
1044 if(x->x_gui.x_fsf.x_selected)
1045 {
1046 sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
1047 for(i=1; i<=IEM_VU_STEPS; i++)
1048 {
1049 if(((i+2)&3) && (x->x_scale))
1050 sys_vgui(".x%x.c itemconfigure %xSCALE%d -fill #%6.6x\n",
1051 canvas, x, i, IEM_GUI_COLOR_SELECTED);
1052 }
1053 if(x->x_scale)
1054 {
1055 i=IEM_VU_STEPS+1;
1056 sys_vgui(".x%x.c itemconfigure %xSCALE%d -fill #%6.6x\n",
1057 canvas, x, i, IEM_GUI_COLOR_SELECTED);
1058 }
1059 sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
1060 }
1061 else
1062 {
1063 sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
1064 for(i=1; i<=IEM_VU_STEPS; i++)
1065 {
1066 if(((i+2)&3) && (x->x_scale))
1067 sys_vgui(".x%x.c itemconfigure %xSCALE%d -fill #%6.6x\n",
1068 canvas, x, i, x->x_gui.x_lcol);
1069 }
1070 if(x->x_scale)
1071 {
1072 i=IEM_VU_STEPS+1;
1073 sys_vgui(".x%x.c itemconfigure %xSCALE%d -fill #%6.6x\n",
1074 canvas, x, i, x->x_gui.x_lcol);
1075 }
1076 sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
1077 }
1078}
1079
1080void vu_draw(t_vu *x, t_glist *glist, int mode)
1081{
1082 if(mode == IEM_GUI_DRAW_MODE_MOVE)
1083 vu_draw_move(x, glist);
1084 else if(mode == IEM_GUI_DRAW_MODE_NEW)
1085 vu_draw_new(x, glist);
1086 else if(mode == IEM_GUI_DRAW_MODE_SELECT)
1087 vu_draw_select(x, glist);
1088 else if(mode == IEM_GUI_DRAW_MODE_ERASE)
1089 vu_draw_erase(x, glist);
1090 else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
1091 vu_draw_config(x, glist);
1092 else if(mode >= IEM_GUI_DRAW_MODE_IO)
1093 vu_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
1094}
1095
1096/* ------------------------ vu widgetbehaviour----------------------------- */
1097
1098
1099static void vu_getrect(t_gobj *z, t_glist *glist,
1100 int *xp1, int *yp1, int *xp2, int *yp2)
1101{
1102 t_vu* x = (t_vu*)z;
1103
1104 *xp1 = text_xpix(&x->x_gui.x_obj, glist) - 1;
1105 *yp1 = text_ypix(&x->x_gui.x_obj, glist) - 2;
1106 *xp2 = *xp1 + x->x_gui.x_w + 2;
1107 *yp2 = *yp1 + x->x_gui.x_h + 4;
1108}
1109
1110static void vu_save(t_gobj *z, t_binbuf *b)
1111{
1112 t_vu *x = (t_vu *)z;
1113 int bflcol[3];
1114 t_symbol *srl[3];
1115
1116 iemgui_save(&x->x_gui, srl, bflcol);
1117 binbuf_addv(b, "ssiisiissiiiiiiii", gensym("#X"),gensym("obj"),
1118 (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
1119 gensym("vu"), x->x_gui.x_w, x->x_gui.x_h,
1120 srl[1], srl[2],
1121 x->x_gui.x_ldx, x->x_gui.x_ldy,
1122 iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
1123 bflcol[0], bflcol[2], x->x_scale,
1124 iem_symargstoint(&x->x_gui.x_isa));
1125 binbuf_addv(b, ";");
1126}
1127
1128void vu_check_height(t_vu *x, int h)
1129{
1130 int n;
1131
1132 n = h / IEM_VU_STEPS;
1133 if(n < IEM_VU_MINSIZE)
1134 n = IEM_VU_MINSIZE;
1135 x->x_led_size = n-1;
1136 x->x_gui.x_h = IEM_VU_STEPS * n;
1137}
1138
1139static void vu_scale(t_vu *x, t_floatarg fscale)
1140{
1141 int i, scale = (int)fscale;
1142
1143 if(scale != 0) scale = 1;
1144 if(x->x_scale && !scale)
1145 {
1146 t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
1147
1148 x->x_scale = (int)scale;
1149 if(glist_isvisible(x->x_gui.x_glist))
1150 {
1151 for(i=1; i<=IEM_VU_STEPS; i++)
1152 {
1153 if((i+2)&3)
1154 sys_vgui(".x%x.c delete %xSCALE%d\n", canvas, x, i);
1155 }
1156 i=IEM_VU_STEPS+1;
1157 sys_vgui(".x%x.c delete %xSCALE%d\n", canvas, x, i);
1158 }
1159 }
1160 if(!x->x_scale && scale)
1161 {
1162 int w4=x->x_gui.x_w/4, end=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist)+x->x_gui.x_w+4;
1163 int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2;
1164 int yyy, k4=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist)-k3;
1165 t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
1166
1167 x->x_scale = (int)scale;
1168 if(glist_isvisible(x->x_gui.x_glist))
1169 {
1170 for(i=1; i<=IEM_VU_STEPS; i++)
1171 {
1172 yyy = k4 + k1*(k2-i);
1173 if((i+2)&3)
1174 sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
1175 -font {%s %d bold} -fill #%6.6x -tags %xSCALE%d\n",
1176 canvas, end, yyy+k3, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
1177 x->x_gui.x_lcol, x, i);
1178 }
1179 i=IEM_VU_STEPS+1;
1180 yyy = k4 + k1*(k2-i);
1181 sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
1182 -font {%s %d bold} -fill #%6.6x -tags %xSCALE%d\n",
1183 canvas, end, yyy+k3, iemgui_vu_scale_str[i], x->x_gui.x_font, x->x_gui.x_fontsize,
1184 x->x_gui.x_lcol, x, i);
1185 }
1186 }
1187}
1188
1189static void vu_properties(t_gobj *z, t_glist *owner)
1190{
1191 t_vu *x = (t_vu *)z;
1192 char buf[800];
1193 t_symbol *srl[3];
1194
1195 iemgui_properties(&x->x_gui, srl);
1196 sprintf(buf, "pdtk_iemgui_dialog %%s VU-METER \
1197 --------dimensions(pix)(pix):-------- %d %d width: %d %d height: \
1198 empty 0.0 empty 0.0 empty %d \
1199 %d no_scale scale %d %d empty %d \
1200 %s %s \
1201 %s %d %d \
1202 %d %d \
1203 %d %d %d\n",
1204 x->x_gui.x_w, IEM_GUI_MINSIZE, x->x_gui.x_h, IEM_VU_STEPS*IEM_VU_MINSIZE,
1205 0,/*no_schedule*/
1206 x->x_scale, -1, -1, -1,/*no linlog, no init, no multi*/
1207 "nosndno", srl[1]->s_name,/*no send*/
1208 srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
1209 x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
1210 0xffffff & x->x_gui.x_bcol, -1/*no front-color*/, 0xffffff & x->x_gui.x_lcol);
1211 gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
1212}
1213
1214static void vu_dialog(t_vu *x, t_symbol *s, int argc, t_atom *argv)
1215{
1216 t_symbol *srl[3];
1217 int w = (int)atom_getintarg(0, argc, argv);
1218 int h = (int)atom_getintarg(1, argc, argv);
1219 int scale = (int)atom_getintarg(4, argc, argv);
1220 int sr_flags;
1221
1222 srl[0] = gensym("empty");
1223 sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
1224 x->x_gui.x_fsf.x_snd_able = 0;
1225 x->x_gui.x_isa.x_loadinit = 0;
1226 x->x_gui.x_w = iemgui_clip_size(w);
1227 vu_check_height(x, h);
1228 if(scale != 0)
1229 scale = 1;
1230 vu_scale(x, (float)scale);
1231 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
1232 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
1233 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
1234 canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
1235}
1236
1237static void vu_size(t_vu *x, t_symbol *s, int ac, t_atom *av)
1238{
1239 x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
1240 if(ac > 1)
1241 vu_check_height(x, (int)atom_getintarg(1, ac, av));
1242 if(glist_isvisible(x->x_gui.x_glist))
1243 {
1244 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
1245 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
1246 canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
1247 }
1248}
1249
1250static void vu_delta(t_vu *x, t_symbol *s, int ac, t_atom *av)
1251{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
1252
1253static void vu_pos(t_vu *x, t_symbol *s, int ac, t_atom *av)
1254{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
1255
1256static void vu_color(t_vu *x, t_symbol *s, int ac, t_atom *av)
1257{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
1258
1259static void vu_receive(t_vu *x, t_symbol *s)
1260{iemgui_receive(x, &x->x_gui, s);}
1261
1262static void vu_label(t_vu *x, t_symbol *s)
1263{iemgui_label((void *)x, &x->x_gui, s);}
1264
1265static void vu_label_pos(t_vu *x, t_symbol *s, int ac, t_atom *av)
1266{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
1267
1268static void vu_label_font(t_vu *x, t_symbol *s, int ac, t_atom *av)
1269{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
1270
1271static void vu_float(t_vu *x, t_floatarg rms)
1272{
1273 int i;
1274
1275 if(rms <= IEM_VU_MINDB)
1276 x->x_rms = 0;
1277 else if(rms >= IEM_VU_MAXDB)
1278 x->x_rms = IEM_VU_STEPS;
1279 else
1280 {
1281 int i = (int)(2.0*(rms + IEM_VU_OFFSET));
1282 x->x_rms = iemgui_vu_db2i[i];
1283 }
1284 i = (int)(100.0*rms + 10000.5);
1285 rms = 0.01*(float)(i - 10000);
1286 x->x_fr = rms;
1287 outlet_float(x->x_out_rms, rms);
1288 vu_update_rms(x, x->x_gui.x_glist);
1289}
1290
1291static void vu_ft1(t_vu *x, t_floatarg peak)
1292{
1293 int i;
1294
1295 if(peak <= IEM_VU_MINDB)
1296 x->x_peak = 0;
1297 else if(peak >= IEM_VU_MAXDB)
1298 x->x_peak = IEM_VU_STEPS;
1299 else
1300 {
1301 int i = (int)(2.0*(peak + IEM_VU_OFFSET));
1302 x->x_peak = iemgui_vu_db2i[i];
1303 }
1304 i = (int)(100.0*peak + 10000.5);
1305 peak = 0.01*(float)(i - 10000);
1306 x->x_fp = peak;
1307 outlet_float(x->x_out_peak, peak);
1308 vu_update_peak(x, x->x_gui.x_glist);
1309}
1310
1311static void vu_bang(t_vu *x)
1312{
1313 outlet_float(x->x_out_peak, x->x_fp);
1314 outlet_float(x->x_out_rms, x->x_fr);
1315 vu_update_rms(x, x->x_gui.x_glist);
1316 vu_update_peak(x, x->x_gui.x_glist);
1317}
1318
1319static void *vu_new(t_symbol *s, int argc, t_atom *argv)
1320{
1321 t_vu *x = (t_vu *)pd_new(vu_class);
1322 int bflcol[]={-66577, -1, -1};
1323 int w=IEM_GUI_DEFAULTSIZE, h=IEM_VU_STEPS*IEM_VU_DEFAULTSIZE;
1324 int ldx=-1, ldy=-8, f=0, fs=8, scale=1;
1325 int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
1326 char str[144];
1327
1328 iem_inttosymargs(&x->x_gui.x_isa, 0);
1329 iem_inttofstyle(&x->x_gui.x_fsf, 0);
1330
1331 if((argc >= 11)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
1332 &&(IS_A_SYMBOL(argv,2)||IS_A_FLOAT(argv,2))
1333 &&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3))
1334 &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
1335 &&IS_A_FLOAT(argv,6)&&IS_A_FLOAT(argv,7)
1336 &&IS_A_FLOAT(argv,8)&&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10))
1337 {
1338 w = (int)atom_getintarg(0, argc, argv);
1339 h = (int)atom_getintarg(1, argc, argv);
1340 iemgui_new_getnames(&x->x_gui, 1, argv);
1341 ldx = (int)atom_getintarg(4, argc, argv);
1342 ldy = (int)atom_getintarg(5, argc, argv);
1343 iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(6, argc, argv));
1344 fs = (int)atom_getintarg(7, argc, argv);
1345 bflcol[0] = (int)atom_getintarg(8, argc, argv);
1346 bflcol[2] = (int)atom_getintarg(9, argc, argv);
1347 scale = (int)atom_getintarg(10, argc, argv);
1348 }
1349 else iemgui_new_getnames(&x->x_gui, 1, 0);
1350 if((argc == 12)&&IS_A_FLOAT(argv,11))
1351 iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(11, argc, argv));
1352 x->x_gui.x_draw = (t_iemfunptr)vu_draw;
1353
1354 x->x_gui.x_fsf.x_snd_able = 0;
1355 x->x_gui.x_fsf.x_rcv_able = 1;
1356 x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
1357 if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
1358 x->x_gui.x_fsf.x_rcv_able = 0;
1359 if (x->x_gui.x_fsf.x_font_style == 1)
1360 strcpy(x->x_gui.x_font, "helvetica");
1361 else if(x->x_gui.x_fsf.x_font_style == 2)
1362 strcpy(x->x_gui.x_font, "times");
1363 else { x->x_gui.x_fsf.x_font_style = 0;
1364 strcpy(x->x_gui.x_font, "courier"); }
1365 if(x->x_gui.x_fsf.x_rcv_able)
1366 pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
1367 x->x_gui.x_ldx = ldx;
1368 x->x_gui.x_ldy = ldy;
1369
1370 if(fs < 4)
1371 fs = 4;
1372 x->x_gui.x_fontsize = fs;
1373 x->x_gui.x_w = iemgui_clip_size(w);
1374 vu_check_height(x, h);
1375 iemgui_all_colfromload(&x->x_gui, bflcol);
1376 if(scale != 0)
1377 scale = 1;
1378 x->x_scale = scale;
1379 x->x_peak = 0;
1380 x->x_rms = 0;
1381 x->x_fp = -101.0;
1382 x->x_fr = -101.0;
1383 iemgui_verify_snd_ne_rcv(&x->x_gui);
1384 inlet_new(&x->x_gui.x_obj, &x->x_gui.x_obj.ob_pd, &s_float, gensym("ft1"));
1385 x->x_out_rms = outlet_new(&x->x_gui.x_obj, &s_float);
1386 x->x_out_peak = outlet_new(&x->x_gui.x_obj, &s_float);
1387 return (x);
1388}
1389
1390static void vu_free(t_vu *x)
1391{
1392 if(x->x_gui.x_fsf.x_rcv_able)
1393 pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
1394 gfxstub_deleteforkey(x);
1395}
1396
1397void g_vumeter_setup(void)
1398{
1399 vu_class = class_new(gensym("vu"), (t_newmethod)vu_new, (t_method)vu_free,
1400 sizeof(t_vu), 0, A_GIMME, 0);
1401 class_addbang(vu_class,vu_bang);
1402 class_addfloat(vu_class,vu_float);
1403 class_addmethod(vu_class, (t_method)vu_ft1, gensym("ft1"), A_FLOAT, 0);
1404 class_addmethod(vu_class, (t_method)vu_dialog, gensym("dialog"),
1405 A_GIMME, 0);
1406 class_addmethod(vu_class, (t_method)vu_size, gensym("size"), A_GIMME, 0);
1407 class_addmethod(vu_class, (t_method)vu_scale, gensym("scale"), A_DEFFLOAT, 0);
1408 class_addmethod(vu_class, (t_method)vu_delta, gensym("delta"), A_GIMME, 0);
1409 class_addmethod(vu_class, (t_method)vu_pos, gensym("pos"), A_GIMME, 0);
1410 class_addmethod(vu_class, (t_method)vu_color, gensym("color"), A_GIMME, 0);
1411 class_addmethod(vu_class, (t_method)vu_receive, gensym("receive"), A_DEFSYM, 0);
1412 class_addmethod(vu_class, (t_method)vu_label, gensym("label"), A_DEFSYM, 0);
1413 class_addmethod(vu_class, (t_method)vu_label_pos, gensym("label_pos"), A_GIMME, 0);
1414 class_addmethod(vu_class, (t_method)vu_label_font, gensym("label_font"), A_GIMME, 0);
1415 vu_widgetbehavior.w_getrectfn = vu_getrect;
1416 vu_widgetbehavior.w_displacefn = iemgui_displace;
1417 vu_widgetbehavior.w_selectfn = iemgui_select;
1418 vu_widgetbehavior.w_activatefn = NULL;
1419 vu_widgetbehavior.w_deletefn = iemgui_delete;
1420 vu_widgetbehavior.w_visfn = iemgui_vis;
1421 vu_widgetbehavior.w_clickfn = NULL;
1422 class_setwidget(vu_class,&vu_widgetbehavior);
1423 class_sethelpsymbol(vu_class, gensym("vu"));
1424 class_setsavefn(vu_class, vu_save);
1425 class_setpropertiesfn(vu_class, vu_properties);
1426}