Debian Codegraph @

audience~.c

raw symbols ◀ ▶ SCIP
2 Debian patches touch this file
1 /* Copyright (c) 2002 Yves Degoyon. */
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 /* audience.c written by Yves Degoyon 2002 */
6 /* 2-dimensional audience simulation */
7 /* ( simulates spatialization and interferences ) */
8 /* */
9 /* This program is free software; you can redistribute it and/or */
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation; either version 2 */
12 /* of the License, or (at your option) any later version. */
13 /* */
14 /* See file LICENSE for further informations on licensing terms. */
15 /* */
16 /* This program is distributed in the hope that it will be useful, */
17 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
18 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
19 /* GNU General Public License for more details. */
20 /* */
21 /* You should have received a copy of the GNU General Public License */
22 /* along with this program; if not, write to the Free Software */
23 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 /* */
25 /* Based on PureData by Miller Puckette and others. */
26 /* */
27 /* Made while listening to : */
28 /* */
29 /* Shalaby Effect -- Instrumentals */
30 /* Honey Bane -- I Wish I Could Be Me */
31 /* ---------------------------------------------------------------------------- */
32
33
34 #include <stdlib.h>
35 #include <string.h>
36 #include <stdio.h>
37 #include <math.h>
38 #include <ctype.h>
39 #include "m_pd.h"
40 #include "m_imp.h"
41 #include "g_canvas.h"
42
43 #include "audience~.h"
44
45 #ifdef _WIN32
46 #include <io.h>
47 #else
48 #include <unistd.h>
49 #endif
50
51 #define DEFAULT_AUDIENCE_WIDTH 200
52 #define DEFAULT_AUDIENCE_HEIGHT 200
53 #define DEFAULT_AUDIENCE_NBINPUTS 4
54 #define DEFAULT_AUDIENCE_NBOUTPUTS 2
55 #define DEFAULT_AUDIENCE_ATTENUATION 0.01
56
57 #define LISTENER_WIDTH 15
58 #define LISTENER_HEIGHT 20
59 #define SPEAKER_WIDTH 15
60 #define SPEAKER_HEIGHT 20
61
62 // sound propagates at the speed of 340 m/s, isn't it ??
63 #define SOUNDSPEED 340.0
64
65 // a pixel is 0.1 meter
66 #define PIXELSIZE 0.1
67
68 static char *audience_version = "audience : 2d audience simulation, version 0.7 ([email protected])";
69
70 t_widgetbehavior audience_widgetbehavior;
71 static t_class *audience_class_tilde;
72
73 static int guidebug=0;
74
75 #define SYS_VGUI2(a,b) if (guidebug) \
76 post(a,b);\
77 sys_vgui(a,b)
78
79 #define SYS_VGUI3(a,b,c) if (guidebug) \
80 post(a,b,c);\
81 sys_vgui(a,b,c)
82
83 #define SYS_VGUI4(a,b,c,d) if (guidebug) \
84 post(a,b,c,d);\
85 sys_vgui(a,b,c,d)
86
87 #define SYS_VGUI5(a,b,c,d,e) if (guidebug) \
88 post(a,b,c,d,e);\
89 sys_vgui(a,b,c,d,e)
90
91 #define SYS_VGUI6(a,b,c,d,e,f) if (guidebug) \
92 post(a,b,c,d,e,f);\
93 sys_vgui(a,b,c,d,e,f)
94
95 #define SYS_VGUI7(a,b,c,d,e,f,g) if (guidebug) \
96 post(a,b,c,d,e,f,g );\
97 sys_vgui(a,b,c,d,e,f,g)
98
99 #define SYS_VGUI8(a,b,c,d,e,f,g,h) if (guidebug) \
100 post(a,b,c,d,e,f,g,h );\
101 sys_vgui(a,b,c,d,e,f,g,h)
102
103 #define SYS_VGUI9(a,b,c,d,e,f,g,h,i) if (guidebug) \
104 post(a,b,c,d,e,f,g,h,i );\
105 sys_vgui(a,b,c,d,e,f,g,h,i)
106
107 /* drawing functions */
108 static void audience_draw_update(t_audience_tilde *x, t_glist *glist)
109 {
110 t_canvas *canvas=glist_getcanvas(glist);
111 t_int ei;
112
113 for ( ei=0; ei<x->x_nbinputs; ei++ )
114 {
115 SYS_VGUI6(".x%lx.c coords %xISPEAKER%d %d %d\n",
116 canvas, x, ei,
117 text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei],
118 text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei]
119 );
120 SYS_VGUI6(".x%lx.c coords %xSPEAKERNUM%d %d %d\n",
121 canvas, x, ei,
122 text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei] - SPEAKER_WIDTH/2,
123 text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei] - SPEAKER_HEIGHT/2
124 );
125 }
126 for ( ei=0; ei<x->x_nboutputs; ei++ )
127 {
128 SYS_VGUI6(".x%lx.c coords %xILISTENER%d %d %d\n",
129 canvas, x, ei,
130 text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei],
131 text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei]
132 );
133 SYS_VGUI6(".x%lx.c coords %xLISTENERNUM%d %d %d\n",
134 canvas, x, ei,
135 text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei] + LISTENER_WIDTH/2,
136 text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei] + LISTENER_HEIGHT/2
137 );
138 }
139 }
140
141 static void audience_draw_new(t_audience_tilde *x, t_glist *glist)
142 {
143 t_canvas *canvas=glist_getcanvas(glist);
144 int ei;
145
146 SYS_VGUI7(".x%lx.c create rectangle %d %d %d %d -fill #EAF1E2 -tags %xAAUDIENCE\n",
147 canvas, text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),
148 text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height,
149 x);
150 // create captions
151 SYS_VGUI5(".x%lx.c create text %d %d -font -*-courier-bold--normal--10-* -text \"0m\" -tags %xBLCAPTION\n",
152 canvas, text_xpix(&x->x_obj, glist) - 10 , text_ypix(&x->x_obj, glist) + x->x_height + 10, x );
153 SYS_VGUI6(".x%lx.c create text %d %d -font -*-courier-bold--normal--10-* -text \"%dm\" -tags %xBRCAPTION\n",
154 canvas, text_xpix(&x->x_obj, glist) + x->x_width + 10 , text_ypix(&x->x_obj, glist) + x->x_height + 10, x->x_width, x );
155 SYS_VGUI6(".x%lx.c create text %d %d -font -*-courier-bold--normal--10-* -text \"%dm\" -tags %xULCAPTION\n",
156 canvas, text_xpix(&x->x_obj, glist) - 10 , text_ypix(&x->x_obj, glist), x->x_height, x );
157
158 // draw all outlets
159 if ( x->x_nboutputs > 1 )
160 {
161 for ( ei=0; ei<x->x_nboutputs; ei++ )
162 {
163 SYS_VGUI8(".x%lx.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xOUT%d\n",
164 canvas, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nboutputs-1),
165 text_ypix(&x->x_obj, glist) + x->x_height,
166 text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nboutputs-1) + 5,
167 text_ypix(&x->x_obj, glist) + x->x_height + 2,
168 x, ei);
169 }
170 }
171 else
172 {
173 SYS_VGUI8(".x%lx.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xOUT%d\n",
174 canvas, text_xpix(&x->x_obj, glist),
175 text_ypix(&x->x_obj, glist) + x->x_height,
176 text_xpix(&x->x_obj, glist) + 5,
177 text_ypix(&x->x_obj, glist) + x->x_height + 2,
178 x, 0);
179 }
180 // draw all inlets
181 for ( ei=0; ei<x->x_nbinputs+1; ei++ )
182 {
183 SYS_VGUI8(".x%lx.c create rectangle %d %d %d %d -outline #000000 -fill #000000 -tags %xIN%d\n",
184 canvas, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbinputs),
185 text_ypix(&x->x_obj, glist) - 2,
186 text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbinputs) + 5,
187 text_ypix(&x->x_obj, glist),
188 x, ei);
189 }
190 // create speaker images
191 for ( ei=0; ei<x->x_nbinputs; ei++ )
192 {
193 SYS_VGUI6("image create photo %xSPEAKER%d -file {%s/examples/speaker.gif} -format gif -width %d -height %d\n",
194 x, ei, audience_class_tilde->c_externdir->s_name, SPEAKER_WIDTH, SPEAKER_HEIGHT );
195 SYS_VGUI8(".x%lx.c create image %d %d -image %xSPEAKER%d -tags %xISPEAKER%d\n",
196 canvas,
197 text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei],
198 text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei],
199 x, ei, x, ei );
200 SYS_VGUI7(".x%lx.c create text %d %d -font -*-courier-bold--normal--10-* -text \"s%d\" -tags %xSPEAKERNUM%d\n",
201 canvas, text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei] - SPEAKER_WIDTH/2,
202 text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei] - SPEAKER_HEIGHT/2, ei+1, x, ei );
203 }
204 // create listener images
205 for ( ei=0; ei<x->x_nboutputs; ei++ )
206 {
207 SYS_VGUI6("image create photo %xLISTENER%d -file {%s/examples/wanderer.gif} -format gif -width %d -height %d\n",
208 x, ei, audience_class_tilde->c_externdir->s_name, LISTENER_WIDTH, LISTENER_HEIGHT );
209 SYS_VGUI8(".x%lx.c create image %d %d -image %xLISTENER%d -tags %xILISTENER%d\n",
210 canvas,
211 text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei],
212 text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei],
213 x, ei, x, ei );
214 SYS_VGUI7(".x%lx.c create text %d %d -font -*-courier-bold--normal--10-* -text \"l%d\" -tags %xLISTENERNUM%d\n",
215 canvas, text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei] + LISTENER_WIDTH/2,
216 text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei] + LISTENER_HEIGHT/2, ei+1, x, ei );
217 }
218 canvas_fixlinesfor( canvas, (t_text*)x );
219 }
220
221 static void audience_draw_move(t_audience_tilde *x, t_glist *glist)
222 {
223 t_canvas *canvas=glist_getcanvas(glist);
224 t_int ei;
225
226 SYS_VGUI7(".x%lx.c coords %xAAUDIENCE %d %d %d %d\n",
227 canvas, x,
228 text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),
229 text_xpix(&x->x_obj, glist)+x->x_width, text_ypix(&x->x_obj, glist)+x->x_height);
230 SYS_VGUI5(".x%lx.c coords %xBLCAPTION %d %d\n",
231 canvas, x,
232 text_xpix(&x->x_obj, glist) - 10 , text_ypix(&x->x_obj, glist) + x->x_height + 10);
233 SYS_VGUI5(".x%lx.c coords %xBRCAPTION %d %d\n",
234 canvas, x,
235 text_xpix(&x->x_obj, glist) + x->x_width + 10 , text_ypix(&x->x_obj, glist) + x->x_height + 10 );
236 SYS_VGUI5(".x%lx.c coords %xULCAPTION %d %d\n",
237 canvas, x,
238 text_xpix(&x->x_obj, glist) - 10 , text_ypix(&x->x_obj, glist) );
239
240 for ( ei=0; ei<x->x_nbinputs+1; ei++ )
241 {
242 SYS_VGUI8(".x%lx.c coords %xIN%d %d %d %d %d\n",
243 canvas, x, ei, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbinputs),
244 text_ypix(&x->x_obj, glist) - 2,
245 text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nbinputs) + 5,
246 text_ypix(&x->x_obj, glist)
247 );
248 }
249 for ( ei=0; ei<x->x_nbinputs+1; ei++ )
250 {
251 SYS_VGUI6(".x%lx.c coords %xISPEAKER%d %d %d\n",
252 canvas, x, ei,
253 text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei],
254 text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei]
255 );
256 SYS_VGUI6(".x%lx.c coords %xSPEAKERNUM%d %d %d\n",
257 canvas, x, ei,
258 text_xpix(&x->x_obj, glist) + x->x_inputs_x[ei] - SPEAKER_WIDTH/2,
259 text_ypix(&x->x_obj, glist) + x->x_inputs_y[ei] - SPEAKER_HEIGHT/2
260 );
261 }
262 if ( x->x_nboutputs > 1 )
263 {
264 for ( ei=0; ei<x->x_nboutputs; ei++ )
265 {
266 SYS_VGUI8(".x%lx.c coords %xOUT%d %d %d %d %d\n",
267 canvas, x, ei, text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nboutputs-1),
268 text_ypix(&x->x_obj, glist) + x->x_height,
269 text_xpix(&x->x_obj, glist) + ( ei * (x->x_width - 5) )/ (x->x_nboutputs-1) + 5,
270 text_ypix(&x->x_obj, glist) + x->x_height + 2
271 );
272 SYS_VGUI6(".x%lx.c coords %xILISTENER%d %d %d\n",
273 canvas, x, ei,
274 text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei],
275 text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei]
276 );
277 SYS_VGUI6(".x%lx.c coords %xLISTENERNUM%d %d %d\n",
278 canvas, x, ei,
279 text_xpix(&x->x_obj, glist) + x->x_outputs_x[ei] + LISTENER_WIDTH/2,
280 text_ypix(&x->x_obj, glist) + x->x_outputs_y[ei] + LISTENER_HEIGHT/2
281 );
282 }
283 }
284 else
285 {
286 SYS_VGUI8(".x%lx.c coords %xOUT%d %d %d %d %d\n",
287 canvas, x, 0, text_xpix(&x->x_obj, glist),
288 text_ypix(&x->x_obj, glist) + x->x_height,
289 text_xpix(&x->x_obj, glist) + 5,
290 text_ypix(&x->x_obj, glist) + x->x_height + 2
291 );
292 SYS_VGUI6(".x%lx.c coords %xILISTENER%d %d %d\n",
293 canvas, x, 0,
294 text_xpix(&x->x_obj, glist) + x->x_outputs_x[0],
295 text_ypix(&x->x_obj, glist) + x->x_outputs_y[0]
296 );
297 SYS_VGUI6(".x%lx.c coords %xLISTENERNUM%d %d %d\n",
298 canvas, x, 0,
299 text_xpix(&x->x_obj, glist) + x->x_outputs_x[0] + LISTENER_WIDTH/2,
300 text_ypix(&x->x_obj, glist) + x->x_outputs_y[0] + LISTENER_HEIGHT/2
301 );
302 }
303 canvas_fixlinesfor( canvas, (t_text*)x );
304 }
305
306 static void audience_draw_erase(t_audience_tilde* x,t_glist* glist)
307 {
308 t_canvas *canvas=glist_getcanvas(glist);
309 int ei;
310
311 SYS_VGUI3(".x%lx.c delete %xAAUDIENCE\n", canvas, x);
312 SYS_VGUI3(".x%lx.c delete %xBLCAPTION\n", canvas, x);
313 SYS_VGUI3(".x%lx.c delete %xBRCAPTION\n", canvas, x);
314 SYS_VGUI3(".x%lx.c delete %xULCAPTION\n", canvas, x);
315 for ( ei=0; ei<x->x_nbinputs+1; ei++ )
316 {
317 SYS_VGUI4(".x%lx.c delete %xIN%d\n", canvas, x, ei );
318 }
319 for ( ei=0; ei<x->x_nbinputs; ei++ )
320 {
321 SYS_VGUI4(".x%lx.c delete %xISPEAKER%d\n", canvas, x, ei );
322 SYS_VGUI4(".x%lx.c delete %xSPEAKERNUM%d\n", canvas, x, ei );
323 // SYS_VGUI3("image delete %xSPEAKER%d\n", x, ei );
324 }
325 for ( ei=0; ei<x->x_nboutputs; ei++ )
326 {
327 SYS_VGUI4(".x%lx.c delete %xOUT%d\n", canvas, x, ei );
328 SYS_VGUI4(".x%lx.c delete %xILISTENER%d\n", canvas, x, ei );
329 SYS_VGUI4(".x%lx.c delete %xLISTENERNUM%d\n", canvas, x, ei );
330 // SYS_VGUI3("image delete %xLISTENER%d\n", x, ei );
331 }
332 }
333
334 static void audience_draw_select(t_audience_tilde* x,t_glist* glist)
335 {
336 t_canvas *canvas=glist_getcanvas(glist);
337
338 if(x->x_selected)
339 {
340 /* sets the item in blue */
341 SYS_VGUI3(".x%lx.c itemconfigure %xAAUDIENCE -outline #0000FF\n", canvas, x);
342 }
343 else
344 {
345 SYS_VGUI3(".x%lx.c itemconfigure %xAAUDIENCE -outline #000000\n", canvas, x);
346 }
347 }
348
349 /* ------------------------ audience widgetbehaviour----------------------------- */
350
351
352 static void audience_getrect(t_gobj *z, t_glist *owner,
353 int *xp1, int *yp1, int *xp2, int *yp2)
354 {
355 t_audience_tilde* x = (t_audience_tilde*)z;
356
357 *xp1 = text_xpix(&x->x_obj, owner);
358 *yp1 = text_ypix(&x->x_obj, owner);
359 *xp2 = text_xpix(&x->x_obj, owner)+x->x_width;
360 *yp2 = text_ypix(&x->x_obj, owner)+x->x_height;
361 }
362
363 static void audience_save(t_gobj *z, t_binbuf *b)
364 {
365 t_audience_tilde *x = (t_audience_tilde *)z;
366 t_int ii;
367
368 binbuf_addv(b, "ssiisiiiifi", gensym("#X"),gensym("obj"),
369 (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix,
370 atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)),
371 x->x_width, x->x_height,
372 x->x_nbinputs, x->x_nboutputs, x->x_attenuation, x->x_applydelay );
373 for ( ii=0; ii<x->x_nbinputs; ii++ )
374 {
375 binbuf_addv(b, "ii", x->x_inputs_x[ii], x->x_inputs_y[ii] );
376 }
377 for ( ii=0; ii<x->x_nboutputs; ii++ )
378 {
379 binbuf_addv(b, "ii", x->x_outputs_x[ii], x->x_outputs_y[ii] );
380 }
381 binbuf_addv(b, ";");
382 }
383
384 static void audience_properties(t_gobj *z, t_glist *owner)
385 {
386 char buf[800];
387 t_audience_tilde *x=(t_audience_tilde *)z;
388
389 sprintf(buf, "pdtk_audience_dialog %%s %d %d %d\n",
390 x->x_width, x->x_height, x->x_nboutputs
391 );
392 // post("audience_properties : %s", buf );
393 gfxstub_new(&x->x_obj.ob_pd, x, buf);
394 }
395
396 static void audience_select(t_gobj *z, t_glist *glist, int selected)
397 {
398 t_audience_tilde *x = (t_audience_tilde *)z;
399
400 x->x_selected = selected;
401 audience_draw_select( x, glist );
402 }
403
404 static void audience_vis(t_gobj *z, t_glist *glist, int vis)
405 {
406 t_audience_tilde *x = (t_audience_tilde *)z;
407
408 // post( "audience~ : vis : %d", vis );
409 if (vis)
410 {
411 audience_draw_new( x, glist );
412 }
413 else
414 {
415 audience_draw_erase( x, glist );
416 }
417 }
418
419 static void audience_dialog(t_audience_tilde *x, t_symbol *s, int argc, t_atom *argv)
420 {
421 t_int onbinputs = x->x_nbinputs;
422 t_int onboutputs = x->x_nboutputs;
423 t_int owidth = x->x_width;
424 t_int oheight = x->x_height;
425 t_int bi, ei;
426 t_int dspstate;
427 t_canvas *canvas=glist_getcanvas(x->x_glist);
428
429 if ( !x )
430 {
431 post( "audience~ : error :tried to set properties on an unexisting object" );
432 }
433 if ( argc != 3 )
434 {
435 post( "audience : error in the number of arguments ( %d instead of 3 )", argc );
436 return;
437 }
438 if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT ||
439 argv[2].a_type != A_FLOAT )
440 {
441 post( "audience~ : wrong arguments" );
442 return;
443 }
444
445 dspstate = canvas_suspend_dsp();
446 audience_draw_erase(x, x->x_glist);
447
448 x->x_width = (int)argv[0].a_w.w_float;
449 if ( x->x_width < 10 ) x->x_width = 10;
450 x->x_height = (int)argv[1].a_w.w_float;
451 if ( x->x_height < 10 ) x->x_height = 10;
452 x->x_nboutputs = (int)argv[2].a_w.w_float;
453 if ( x->x_nboutputs < 1 ) x->x_nboutputs = 1;
454
455 // re-allocate audio buffers if needed
456 if ( ( owidth != x->x_width ) || ( oheight != x->x_height ) )
457 {
458 if ( x->x_audiobuffer )
459 {
460 for ( ei=0; ei<onbinputs; ei++ )
461 {
462 freebytes( x->x_audiobuffer[ei], x->x_audiobuffersize*sizeof(t_float) );
463 }
464 freebytes( x->x_audiobuffer, onbinputs*sizeof(t_float*) );
465 }
466 // allocate audio buffer
467 x->x_audiobuffer = (t_float **) getbytes( x->x_nbinputs*sizeof(t_float *) );
468 if ( !x->x_audiobuffer )
469 {
470 post( "audience~ : could not allocate audio buffer" );
471 return;
472 }
473 x->x_audiobuffersize = ( t_int ) ( ( ( ( t_float ) sqrt( pow( x->x_width, 2 )
474 + pow( x->x_height, 2 ) ) ) / SOUNDSPEED )
475 * ( (float ) sys_getsr() ) );
476 post( "audience~ : audio buffer size : %d samples", x->x_audiobuffersize );
477 for ( bi=0; bi<x->x_nbinputs; bi++ )
478 {
479 x->x_audiobuffer[bi] = (t_float *) getbytes( x->x_audiobuffersize*sizeof(t_float) );
480 if ( !x->x_audiobuffer[bi] )
481 {
482 post( "audience~ : could not allocate audio buffer" );
483 return;
484 }
485 }
486 x->x_audiowritepos = 0;
487 }
488
489 // re-allocate inlets : CRASHES PD,I GUESS IT'S NOT SUPPORTED
490 if ( onbinputs != x->x_nbinputs )
491 {
492 // post( "audience~ : cleaning up old inlets" );
493 if ( x->x_inputs )
494 {
495 for ( ei=0; ei<onbinputs; ei++ )
496 {
497 // post( "audience~ : freeing input ! %d", ei );
498 inlet_free( x->x_inputs[ei] );
499 }
500 freebytes( x->x_inputs, onbinputs*sizeof(t_inlet*) );
501 }
502 if ( x->x_inputs_x )
503 {
504 freebytes( x->x_inputs_x, onbinputs*sizeof(t_int) );
505 }
506 if ( x->x_inputs_y )
507 {
508 freebytes( x->x_inputs_y, onbinputs*sizeof(t_int) );
509 }
510 // post( "audience~ : creating new ones" );
511 x->x_inputs = (t_inlet **) getbytes( x->x_nbinputs*sizeof(t_inlet *) );
512 x->x_inputs_x = (t_int *) getbytes( x->x_nbinputs*sizeof(t_int) );
513 x->x_inputs_y = (t_int *) getbytes( x->x_nbinputs*sizeof(t_int) );
514 if ( !x->x_inputs || !x->x_inputs_x || !x->x_inputs_y )
515 {
•516 pd_error(x, "audience~ : fatal : could not create new object" );
517 return;
518 }
519 for ( bi=0; bi<x->x_nbinputs; bi++ )
520 {
521 // post( "audience~ : allocating input ! %d", bi );
522 x->x_inputs[bi] = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
523 }
524 }
525
526 // re-allocate outlets
527 if ( onboutputs != x->x_nboutputs )
528 {
529 // post( "audience~ : cleaning up old outlets" );
530 if ( x->x_outputs )
531 {
532 for ( ei=0; ei<onboutputs; ei++ )
533 {
534 canvas_rmoutlet(canvas, x->x_outputs[ei] );
535 // outlet_free( x->x_outputs[ei] );
536 }
537 freebytes( x->x_outputs, onboutputs*sizeof(t_outlet*) );
538 }
539 if ( x->x_outputs_x )
540 {
541 freebytes( x->x_outputs_x, onboutputs*sizeof(t_int) );
542 }
543 if ( x->x_outputs_y )
544 {
545 freebytes( x->x_outputs_y, onboutputs*sizeof(t_int) );
546 }
547 // post( "audience~ : creating new ones" );
548 x->x_outputs = (t_outlet **) getbytes( x->x_nboutputs*sizeof(t_outlet *) );
549 x->x_outputs_x = (t_int *) getbytes( x->x_nboutputs*sizeof(t_int) );
550 x->x_outputs_y = (t_int *) getbytes( x->x_nboutputs*sizeof(t_int) );
551 if ( !x->x_outputs || !x->x_outputs_x || !x->x_outputs_y )
552 {
•553 // pd_error(x, "audience~ : fatal : could not create new object" );
554 return;
555 }
556 for ( bi=0; bi<x->x_nboutputs; bi++ )
557 {
558 x->x_outputs[bi] = outlet_new( &x->x_obj, &s_signal );
559 }
560 // set default coordinates
561 if ( x->x_nboutputs > 1 )
562 {
563 for ( ei=0; ei<x->x_nboutputs; ei++ )
564 {
565 x->x_outputs_x[ei] = ei * (x->x_width - 5) / ( x->x_nboutputs - 1 );
566 x->x_outputs_y[ei] = x->x_height - LISTENER_HEIGHT/2;
567 }
568 }
569 else
570 {
571 x->x_outputs_x[0] = x->x_width;
572 x->x_outputs_y[0] = x->x_height - LISTENER_HEIGHT/2;
573 }
574 }
575
576 canvas_fixlinesfor( canvas, (t_text*)x );
577 audience_draw_new(x, x->x_glist);
578 canvas_resume_dsp(dspstate);
579 }
580
581 static void audience_delete(t_gobj *z, t_glist *glist)
582 {
583 t_audience_tilde *x = (t_audience_tilde *)z;
584
585 // post( "audience~ : delete" );
586 audience_draw_erase( x, glist );
587 canvas_deletelinesfor(glist, (t_text *)z);
588 }
589
590 static void audience_displace(t_gobj *z, t_glist *glist, int dx, int dy)
591 {
592 t_audience_tilde *x = (t_audience_tilde *)z;
593 int xold = text_xpix(&x->x_obj, glist);
594 int yold = text_ypix(&x->x_obj, glist);
595
596 // post( "audience_displace dx=%d dy=%d", dx, dy );
597
598 x->x_obj.te_xpix += dx;
599 x->x_obj.te_ypix += dy;
600 if(xold != x->x_obj.te_xpix || yold != x->x_obj.te_ypix)
601 {
602 audience_draw_move(x, x->x_glist);
603 }
604 }
605
606 static void audience_motion(t_audience_tilde *x, t_floatarg dx, t_floatarg dy)
607 {
608 // post( "audience_motion dx=%f dy=%f", dx, dy );
609
610 switch( x->x_type_selected )
611 {
612 case AUDIENCE_INPUT:
613 x->x_inputs_x[ x->x_nselected ] += dx;
614 if ( x->x_inputs_x[ x->x_nselected ] < 0 ) x->x_inputs_x[ x->x_nselected ] = 0;
615 if ( x->x_inputs_x[ x->x_nselected ] > x->x_width ) x->x_inputs_x[ x->x_nselected ] = x->x_width;
616 x->x_inputs_y[ x->x_nselected ] += dy;
617 if ( x->x_inputs_y[ x->x_nselected ] < 0 ) x->x_inputs_y[ x->x_nselected ] = 0;
618 if ( x->x_inputs_y[ x->x_nselected ] > x->x_height ) x->x_inputs_y[ x->x_nselected ] = x->x_height;
619 break;
620 case AUDIENCE_OUTPUT:
621 x->x_outputs_x[ x->x_nselected ] += dx;
622 if ( x->x_outputs_x[ x->x_nselected ] < 0 ) x->x_outputs_x[ x->x_nselected ] = 0;
623 if ( x->x_outputs_x[ x->x_nselected ] > x->x_width ) x->x_outputs_x[ x->x_nselected ] = x->x_width;
624 x->x_outputs_y[ x->x_nselected ] += dy;
625 if ( x->x_outputs_y[ x->x_nselected ] < 0 ) x->x_outputs_y[ x->x_nselected ] = 0;
626 if ( x->x_outputs_y[ x->x_nselected ] > x->x_height ) x->x_outputs_y[ x->x_nselected ] = x->x_height;
627 break;
628 }
629
630 audience_draw_update(x, x->x_glist);
631 }
632
633 static int audience_click(t_gobj *z, struct _glist *glist,
634 int xpix, int ypix, int shift, int alt, int dbl, int doit)
635 {
636 t_audience_tilde* x = (t_audience_tilde *)z;
637 t_int bi;
638
639 // post( "audience_click doit=%d x=%d y=%d", doit, xpix, ypix );
640 if ( doit)
641 {
642 t_int relx = xpix-text_xpix(&x->x_obj, glist);
643 t_int rely = ypix-text_ypix(&x->x_obj, glist);
644
645 // post( "audience~ : relx : %d : rely : %d", relx, rely );
646 x->x_type_selected = AUDIENCE_NONE;
647 x->x_nselected = -1;
648 for ( bi=0; bi<x->x_nbinputs; bi++ )
649 {
650 if ( ( abs( relx - x->x_inputs_x[bi] ) < SPEAKER_WIDTH ) &&
651 ( abs( rely - x->x_inputs_y[bi] ) < SPEAKER_HEIGHT ) )
652 {
653 x->x_type_selected = AUDIENCE_INPUT;
654 x->x_nselected = bi;
655 break;
656 }
657 }
658 if ( x->x_type_selected == AUDIENCE_NONE )
659 {
660 for ( bi=0; bi<x->x_nboutputs; bi++ )
661 {
662 if ( ( abs( relx - x->x_outputs_x[bi] ) < LISTENER_WIDTH ) &&
663 ( abs( rely - x->x_outputs_y[bi] ) < LISTENER_HEIGHT ) )
664 {
665 x->x_type_selected = AUDIENCE_OUTPUT;
666 x->x_nselected = bi;
667 break;
668 }
669 }
670 }
671 audience_draw_update(x, glist);
672 glist_grab(glist, &x->x_obj.te_g, (t_glistmotionfn)audience_motion,
673 0, xpix, ypix);
674 }
675 return (1);
676 }
677
678 static t_audience_tilde *audience_new(t_symbol *s, int argc, t_atom *argv)
679 {
680 t_int bi, ei;
681 t_audience_tilde *x;
682 t_pd *x2;
683 char *str;
684
685 // post( "audience_new : create : %s argc =%d", s->s_name, argc );
686
687 x = (t_audience_tilde *)pd_new(audience_class_tilde);
688 // new audience created from the gui
689 if ( argc != 0 )
690 {
691 if ( argc < 5 )
692 {
693 post( "audience~ : error in the number of arguments ( %d )", argc );
694 return NULL;
695 }
696 if ( argv[0].a_type != A_FLOAT || argv[1].a_type != A_FLOAT ||
697 argv[2].a_type != A_FLOAT || argv[3].a_type != A_FLOAT ||
698 argv[4].a_type != A_FLOAT || argv[5].a_type != A_FLOAT )
699 {
700 post( "audience~ : wrong arguments" );
701 return NULL;
702 }
703
704 x->x_width = (int)argv[0].a_w.w_float;
705 if ( x->x_width < 10 ) x->x_width = 10;
706 x->x_height = (int)argv[1].a_w.w_float;
707 if ( x->x_height < 10 ) x->x_height = 10;
708 x->x_nbinputs = (int)argv[2].a_w.w_float;
709 if ( x->x_nbinputs < 1 ) x->x_nbinputs = 1;
710 x->x_nboutputs = (int)argv[3].a_w.w_float;
711 if ( x->x_nboutputs < 1 ) x->x_nboutputs = 1;
712 x->x_attenuation = argv[4].a_w.w_float;
713 if ( x->x_attenuation < 0 ) x->x_attenuation = 0;
714 x->x_applydelay = argv[5].a_w.w_float;
715 }
716 else
717 {
718 x->x_width = DEFAULT_AUDIENCE_WIDTH;
719 x->x_height = DEFAULT_AUDIENCE_HEIGHT;
720 x->x_nbinputs = DEFAULT_AUDIENCE_NBINPUTS;
721 x->x_nboutputs = DEFAULT_AUDIENCE_NBOUTPUTS;
722 x->x_attenuation = DEFAULT_AUDIENCE_ATTENUATION;
723 x->x_applydelay = 0;
724 }
725
726 // create inlets and outlets
727 x->x_outputs = (t_outlet **) getbytes( x->x_nboutputs*sizeof(t_outlet *) );
728 x->x_outputs_x = (t_int *) getbytes( x->x_nboutputs*sizeof(t_int) );
729 x->x_outputs_y = (t_int *) getbytes( x->x_nboutputs*sizeof(t_int) );
730 if ( !x->x_outputs || !x->x_outputs_x || !x->x_outputs_y )
731 {
732 post( "audience~ : could not allocate outputs" );
733 return NULL;
734 }
735 for ( bi=0; bi<x->x_nboutputs; bi++ )
736 {
737 x->x_outputs[bi] = outlet_new( &x->x_obj, &s_signal );
738 }
739 x->x_inputs = (t_inlet **) getbytes( x->x_nbinputs*sizeof(t_inlet *) );
740 x->x_inputs_x = (t_int *) getbytes( x->x_nbinputs*sizeof(t_int) );
741 x->x_inputs_y = (t_int *) getbytes( x->x_nbinputs*sizeof(t_int) );
742 if ( !x->x_inputs || !x->x_inputs_x || !x->x_inputs_y )
743 {
744 post( "audience~ : could not allocate inputs" );
745 return NULL;
746 }
747 for ( bi=0; bi<x->x_nbinputs; bi++ )
748 {
749 x->x_inputs[bi] = inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
750 }
751
752 // allocate audio buffer
753 x->x_audiowritepos = 0;
754 x->x_audiobuffer = (t_float **) getbytes( x->x_nbinputs*sizeof(t_float *) );
755 if ( !x->x_audiobuffer )
756 {
757 post( "audience~ : could not allocate audio buffer" );
758 return NULL;
759 }
760 x->x_audiobuffersize = ( t_int ) ( ( ( ( t_float ) sqrt( pow( x->x_width, 2 )
761 + pow( x->x_height, 2 ) ) ) / SOUNDSPEED )
762 * ( (float ) sys_getsr() ) );
763 post( "audience~ : audio buffer size : %d samples", x->x_audiobuffersize );
764 for ( bi=0; bi<x->x_nbinputs; bi++ )
765 {
766 x->x_audiobuffer[bi] = (t_float *) getbytes( x->x_audiobuffersize*sizeof(t_float) );
767 if ( !x->x_audiobuffer[bi] )
768 {
769 post( "audience~ : could not allocate audio buffer" );
770 return NULL;
771 }
772 }
773
774 if ( argc == 0 )
775 {
776 // set default coordinates
777 if ( x->x_nbinputs > 1 )
778 {
779 for ( ei=0; ei<x->x_nbinputs; ei++ )
780 {
781 x->x_inputs_x[ei] = (ei+1) * (x->x_width - 5) / x->x_nbinputs;
782 x->x_inputs_y[ei] = SPEAKER_HEIGHT/2;
783 }
784 }
785 else
786 {
787 x->x_inputs_x[0] = x->x_width;
788 x->x_inputs_y[0] = SPEAKER_HEIGHT/2;
789 }
790
791 if ( x->x_nboutputs > 1 )
792 {
793 for ( ei=0; ei<x->x_nboutputs; ei++ )
794 {
795 x->x_outputs_x[ei] = ei * (x->x_width - 5) / ( x->x_nboutputs - 1 );
796 x->x_outputs_y[ei] = x->x_height - LISTENER_HEIGHT/2;
797 }
798 }
799 else
800 {
801 x->x_outputs_x[0] = x->x_width;
802 x->x_outputs_y[0] = x->x_height - LISTENER_HEIGHT/2;
803 }
804 }
805 else
806 {
807 t_int ai = 6;
808
809 // restore coordinates from arguments
810 for ( ei=0; ei<x->x_nbinputs; ei++ )
811 {
812 x->x_inputs_x[ei] = argv[ai++].a_w.w_float;
813 x->x_inputs_y[ei] = argv[ai++].a_w.w_float;
814 }
815 for ( ei=0; ei<x->x_nboutputs; ei++ )
816 {
817 x->x_outputs_x[ei] = argv[ai++].a_w.w_float;
818 x->x_outputs_y[ei] = argv[ai++].a_w.w_float;
819 }
820 }
821
822 x->x_glist = (t_glist *) canvas_getcurrent();
823 x->x_type_selected = AUDIENCE_NONE;
824 x->x_nselected = -1;
825
826 // post( "audience~ : new object : inlets : %d : outlets : %d : attenuation : %f", x->x_nbinputs, x->x_nboutputs, x->x_attenuation );
827 return (x);
828 }
829
830 static void audience_free(t_audience_tilde *x)
831 {
832 t_int ei;
833
834 if ( x->x_outputs )
835 {
836 for ( ei=0; ei<x->x_nboutputs; ei++ )
837 {
838 outlet_free( x->x_outputs[ei] );
839 }
840 freebytes( x->x_outputs, x->x_nboutputs*sizeof(t_outlet*) );
841 }
842 if ( x->x_inputs )
843 {
844 for ( ei=0; ei<x->x_nbinputs; ei++ )
845 {
846 inlet_free( x->x_inputs[ei] );
847 }
848 freebytes( x->x_inputs, x->x_nbinputs*sizeof(t_outlet*) );
849 }
850 if ( x->x_audiobuffer )
851 {
852 for ( ei=0; ei<x->x_nbinputs; ei++ )
853 {
854 freebytes( x->x_audiobuffer[ei], x->x_audiobuffersize*sizeof(t_float) );
855 }
856 freebytes( x->x_audiobuffer, x->x_nbinputs*sizeof(t_float*) );
857 }
858 }
859
860 static t_int *audience_perform(t_int *w)
861 {
862 t_int ii, oi, op;
863 t_audience_tilde *x = (t_audience_tilde*)(w[1]);
864 t_int bsize = w[2];
865
866 {
867 // save input sounds in the audio buffer
868 for ( ii=0; ii<x->x_nbinputs; ii++ )
869 {
870 t_float* isound = (t_float*)w[ii+3];
871
872 if ( x->x_audiobuffer[ii] )
873 {
874 op = 0;
875 while ( op < bsize )
876 {
877 *(x->x_audiobuffer[ii] + x->x_audiowritepos + op ) = *(isound + op);
878 op++;
879 }
880 }
881 }
882
883 // set outputs
884 for ( oi=0; oi<x->x_nboutputs; oi++ )
885 {
886 t_float* osound = (t_float*)w[oi+3+x->x_nbinputs];
887
888 // zeroing output
889 memset( osound, 0x00, bsize*sizeof( t_float ) );
890
891 for ( ii=0; ii<x->x_nbinputs; ii++ )
892 {
893 t_int delay;
894 t_int dist;
895 t_int readpos;
896 t_int maxwritepos;
897
898 maxwritepos = ( x->x_audiobuffersize / bsize ) * bsize;
899 dist = sqrt( pow( (x->x_outputs_x[oi] - x->x_inputs_x[ii]), 2 )
900 + pow( (x->x_outputs_y[oi] - x->x_inputs_y[ii]), 2 ) );
901 delay = ( t_int ) ( ( ( ( t_float ) dist ) * ( (float ) sys_getsr() ) ) / SOUNDSPEED );
902 delay = ( delay / bsize ) * bsize; // set a block frontier
903 if ( x->x_applydelay )
904 {
905 if ( x->x_audiowritepos >= delay )
906 {
907 readpos = x->x_audiowritepos - delay;
908 }
909 else
910 {
911 readpos = maxwritepos - delay + x->x_audiowritepos;
912 }
913 }
914 else
915 {
916 readpos = x->x_audiowritepos;
917 }
918 // if ( ii == 0 )
919 // {
920 // post( "audience~ : dist : %d : delay : %d : readpos : %d : writepos : %d",
921 // dist, delay, readpos, x->x_audiowritepos );
922 // }
923
924 op = 0;
925 while ( op < bsize )
926 {
927 if ( ( readpos < x->x_audiobuffersize ) && ( readpos >= 0 ) )
928 {
929 if ( 1.0-x->x_attenuation*dist < 0 )
930 {
931 *(osound+op) += 0.0;
932 }
933 else
934 {
935 *(osound+op) += *(x->x_audiobuffer[ii] + readpos + op)*(1.0-x->x_attenuation*dist);
936 }
937 }
938 else
939 {
•940 pd_error(x, "audience~ : delay : %d : wrong readpos !!! : %d >= %d or < 0", delay, readpos, x->x_audiobuffersize );
941 }
942 op++;
943 }
944 }
945 }
946
947 // update write position
948 if ( x->x_audiowritepos + bsize > x->x_audiobuffersize - bsize )
949 {
950 // post( "audience~ : write back to zero @ %d", x->x_audiowritepos );
951 x->x_audiowritepos = 0;
952 }
953 else
954 {
955 x->x_audiowritepos += bsize;
956 }
957
958 }
959
960 return (w+x->x_nbinputs+x->x_nboutputs+3);
961 }
962
963 static void audience_dsp(t_audience_tilde *x, t_signal **sp)
964 {
965 switch ( x->x_nbinputs+x->x_nboutputs )
966 {
967 case 2 :
968 dsp_add(audience_perform, 4, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec );
969 break;
970
971 case 3 :
972 dsp_add(audience_perform, 5, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec );
973 break;
974
975 case 4 :
976 dsp_add(audience_perform, 6, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec );
977 break;
978
979 case 5 :
980 dsp_add(audience_perform, 7, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec, sp[5]->s_vec );
981 break;
982
983 case 6 :
984 dsp_add(audience_perform, 8, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec,
985 sp[5]->s_vec, sp[6]->s_vec );
986 break;
987
988 case 7 :
989 dsp_add(audience_perform, 9, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec,
990 sp[5]->s_vec, sp[6]->s_vec, sp[7]->s_vec );
991 break;
992
993 case 8 :
994 dsp_add(audience_perform, 10, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec,
995 sp[5]->s_vec, sp[6]->s_vec, sp[7]->s_vec, sp[8]->s_vec );
996 break;
997
998 case 9 :
999 dsp_add(audience_perform, 11, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec,
1000 sp[5]->s_vec, sp[6]->s_vec, sp[7]->s_vec, sp[8]->s_vec, sp[9]->s_vec );
1001 break;
1002
1003 case 10 :
1004 dsp_add(audience_perform, 12, x, sp[1]->s_n, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec,
1005 sp[5]->s_vec, sp[6]->s_vec, sp[7]->s_vec, sp[8]->s_vec,
1006 sp[9]->s_vec, sp[10]->s_vec );
1007 break;
1008
1009 default :
1010 post( "audience~ : number of inlets/outlets not supported" );
1011 break;
1012 }
1013 }
1014
1015 // set attenuation
1016 static void audience_attenuation(t_audience_tilde *x, t_floatarg fattenuation )
1017 {
1018 if ( fattenuation < 0 )
1019 {
1020 post( "audience~ : error : wrong attenuation : %f", fattenuation );
1021 return;
1022 }
1023 x->x_attenuation = fattenuation;
1024 }
1025
1026 // set delay
1027 static void audience_delay(t_audience_tilde *x, t_floatarg fdelay )
1028 {
1029 if ( fdelay == 0. )
1030 {
1031 x->x_applydelay = 0;
1032 }
1033 else
1034 {
1035 x->x_applydelay = 1;
1036 }
1037 }
1038
1039 void audience_tilde_setup(void)
1040 {
•1041 logpost(NULL, 4, "%s", "%s", audience_version );
1042 audience_class_tilde = class_new(gensym("audience~"), (t_newmethod)audience_new,
1043 (t_method)audience_free, sizeof(t_audience_tilde), 0, A_GIMME, 0);
1044 CLASS_MAINSIGNALIN( audience_class_tilde, t_audience_tilde, x_f );
1045 class_addmethod(audience_class_tilde, (t_method)audience_dsp, gensym("dsp"), 0);
1046 class_addmethod(audience_class_tilde, (t_method)audience_dialog, gensym("dialog"), A_GIMME, 0);
1047 class_addmethod(audience_class_tilde, (t_method)audience_attenuation, gensym("attenuation"), A_DEFFLOAT, 0);
1048 class_addmethod(audience_class_tilde, (t_method)audience_delay, gensym("delay"), A_DEFFLOAT, 0);
1049 audience_widgetbehavior.w_getrectfn = audience_getrect;
1050 audience_widgetbehavior.w_displacefn = audience_displace;
1051 audience_widgetbehavior.w_selectfn = audience_select;
1052 audience_widgetbehavior.w_activatefn = NULL;
1053 audience_widgetbehavior.w_deletefn = audience_delete;
1054 audience_widgetbehavior.w_visfn = audience_vis;
1055 audience_widgetbehavior.w_clickfn = audience_click;
1056
1057 #if PD_MINOR_VERSION >= 37
1058 class_setpropertiesfn(audience_class_tilde, audience_properties);
1059 class_setsavefn(audience_class_tilde, audience_save);
1060 #else
1061 audience_widgetbehavior.w_propertiesfn = audience_properties;
1062 audience_widgetbehavior.w_savefn = audience_save;
1063 #endif
1064
1065 class_setwidget(audience_class_tilde, &audience_widgetbehavior);
1066
1067 sys_vgui("eval [read [open {%s/%s.tcl}]]\n",
1068 audience_class_tilde->c_externdir->s_name, audience_class_tilde->c_name->s_name);
1069 }