summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/src/d_misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/d_misc.c')
-rw-r--r--apps/plugins/pdbox/PDa/src/d_misc.c265
1 files changed, 0 insertions, 265 deletions
diff --git a/apps/plugins/pdbox/PDa/src/d_misc.c b/apps/plugins/pdbox/PDa/src/d_misc.c
index f601d66d90..b6d36764b8 100644
--- a/apps/plugins/pdbox/PDa/src/d_misc.c
+++ b/apps/plugins/pdbox/PDa/src/d_misc.c
@@ -257,268 +257,3 @@ void d_misc_setup(void)
257 samplerate_tilde_setup(); 257 samplerate_tilde_setup();
258} 258}
259 259
260
261
262
263/* Copyright (c) 1997-1999 Miller Puckette.
264* For information on usage and redistribution, and for a DISCLAIMER OF ALL
265* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
266
267/* miscellaneous: print~; more to come.
268*/
269
270#include "m_pd.h"
271#include <stdio.h>
272#include <string.h>
273
274/* ------------------------- print~ -------------------------- */
275static t_class *print_class;
276
277typedef struct _print
278{
279 t_object x_obj;
280 float x_f;
281 t_symbol *x_sym;
282 int x_count;
283} t_print;
284
285static t_int *print_perform(t_int *w)
286{
287 t_print *x = (t_print *)(w[1]);
288 t_float *in = (t_float *)(w[2]);
289 int n = (int)(w[3]);
290 if (x->x_count)
291 {
292 post("%s:", x->x_sym->s_name);
293 if (n == 1) post("%8g", in[0]);
294 else if (n == 2) post("%8g %8g", in[0], in[1]);
295 else if (n == 4) post("%8g %8g %8g %8g",
296 in[0], in[1], in[2], in[3]);
297 else while (n > 0)
298 {
299 post("%-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g",
300 in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7]);
301 n -= 8;
302 in += 8;
303 }
304 x->x_count--;
305 }
306 return (w+4);
307}
308
309static void print_dsp(t_print *x, t_signal **sp)
310{
311 dsp_add(print_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
312}
313
314static void print_float(t_print *x, t_float f)
315{
316 if (f < 0) f = 0;
317 x->x_count = f;
318}
319
320static void print_bang(t_print *x)
321{
322 x->x_count = 1;
323}
324
325static void *print_new(t_symbol *s)
326{
327 t_print *x = (t_print *)pd_new(print_class);
328 x->x_sym = (s->s_name[0]? s : gensym("print~"));
329 x->x_count = 0;
330 x->x_f = 0;
331 return (x);
332}
333
334static void print_setup(void)
335{
336 print_class = class_new(gensym("print~"), (t_newmethod)print_new, 0,
337 sizeof(t_print), 0, A_DEFSYM, 0);
338 CLASS_MAINSIGNALIN(print_class, t_print, x_f);
339 class_addmethod(print_class, (t_method)print_dsp, gensym("dsp"), 0);
340 class_addbang(print_class, print_bang);
341 class_addfloat(print_class, print_float);
342}
343
344/* ------------------------- scope~ -------------------------- */
345/* this has been replaced by arrays; to be deleted later */
346
347#include "g_canvas.h"
348
349static t_class *scope_class;
350
351#define SCOPESIZE 256
352
353typedef struct _scope
354{
355 t_object x_obj;
356 t_sample x_samps[SCOPESIZE];
357 int x_phase;
358 int x_drawn;
359 void *x_canvas;
360} t_scope;
361
362static t_int *scope_perform(t_int *w)
363{
364 t_scope *x = (t_scope *)(w[1]);
365 t_float *in = (t_float *)(w[2]);
366 int n = (int)(w[3]), phase = x->x_phase;
367 while (n--)
368 {
369 x->x_samps[phase] = *in++;
370 phase = (phase + 1) & (SCOPESIZE-1);
371 }
372 x->x_phase = phase;
373 return (w+4);
374}
375
376static void scope_dsp(t_scope *x, t_signal **sp)
377{
378 dsp_add(scope_perform, 3, x, sp[0]->s_vec, sp[0]->s_n);
379}
380
381static void scope_erase(t_scope *x)
382{
383 if (x->x_drawn) sys_vgui(".x%x.c delete gumbo\n", x->x_canvas);
384}
385
386#define X1 10.
387#define X2 20.
388#define YC 5.
389static void scope_bang(t_scope *x)
390{
391 int n, phase;
392 char hugebuf[10000], *s = hugebuf;
393 scope_erase(x);
394 sys_vgui(".x%x.c create line 10c 5c 20c 5c -tags gumbo\n", x->x_canvas);
395 sprintf(s, ".x%x.c create line ", (t_int)x->x_canvas);
396 s += strlen(s);
397 for (n = 0, phase = x->x_phase;
398 n < SCOPESIZE; phase = ((phase+1) & (SCOPESIZE-1)), n++)
399 {
400 sprintf(s, "%fc %fc ", X1 + (X2 - X1) * (float)n * (1./SCOPESIZE),
401 YC - 5 * x->x_samps[phase]);
402 s += strlen(s);
403 /* post("phase %d", phase); */
404 }
405 sprintf(s, "-tags gumbo\n");
406 sys_gui(hugebuf);
407 x->x_drawn = 1;
408}
409
410static void scope_free(t_scope *x)
411{
412 scope_erase(x);
413}
414
415static void *scope_new(t_symbol *s)
416{
417 t_scope *x = (t_scope *)pd_new(scope_class);
418 error("scope: this is now obsolete; use arrays and tabwrite~ instead");
419 x->x_phase = 0;
420 x->x_drawn = 0;
421 x->x_canvas = canvas_getcurrent();
422 return (x);
423}
424
425static void scope_setup(void)
426{
427 scope_class = class_new(gensym("scope~"), (t_newmethod)scope_new,
428 (t_method)scope_free, sizeof(t_scope), 0, A_DEFSYM, 0);
429 class_addmethod(scope_class, nullfn, gensym("signal"), 0);
430 class_addmethod(scope_class, (t_method)scope_dsp, gensym("dsp"), 0);
431 class_addbang(scope_class, scope_bang);
432}
433
434/* ------------------------ bang~ -------------------------- */
435
436static t_class *bang_tilde_class;
437
438typedef struct _bang
439{
440 t_object x_obj;
441 t_clock *x_clock;
442} t_bang;
443
444static t_int *bang_tilde_perform(t_int *w)
445{
446 t_bang *x = (t_bang *)(w[1]);
447 clock_delay(x->x_clock, 0);
448 return (w+2);
449}
450
451static void bang_tilde_dsp(t_bang *x, t_signal **sp)
452{
453 dsp_add(bang_tilde_perform, 1, x);
454}
455
456static void bang_tilde_tick(t_bang *x)
457{
458 outlet_bang(x->x_obj.ob_outlet);
459}
460
461static void bang_tilde_free(t_bang *x)
462{
463 clock_free(x->x_clock);
464}
465
466static void *bang_tilde_new(t_symbol *s)
467{
468 t_bang *x = (t_bang *)pd_new(bang_tilde_class);
469 x->x_clock = clock_new(x, (t_method)bang_tilde_tick);
470 outlet_new(&x->x_obj, &s_bang);
471 return (x);
472}
473
474static void bang_tilde_setup(void)
475{
476 bang_tilde_class = class_new(gensym("bang~"), (t_newmethod)bang_tilde_new,
477 (t_method)bang_tilde_free, sizeof(t_bang), 0, 0);
478 class_addmethod(bang_tilde_class, (t_method)bang_tilde_dsp,
479 gensym("dsp"), 0);
480}
481
482/* ------------------------ samplerate~~ -------------------------- */
483
484static t_class *samplerate_tilde_class;
485
486typedef struct _samplerate
487{
488 t_object x_obj;
489} t_samplerate;
490
491static void samplerate_tilde_bang(t_samplerate *x)
492{
493 outlet_float(x->x_obj.ob_outlet, sys_getsr());
494}
495
496static void *samplerate_tilde_new(t_symbol *s)
497{
498 t_samplerate *x = (t_samplerate *)pd_new(samplerate_tilde_class);
499 outlet_new(&x->x_obj, &s_float);
500 return (x);
501}
502
503static void samplerate_tilde_setup(void)
504{
505 samplerate_tilde_class = class_new(gensym("samplerate~"),
506 (t_newmethod)samplerate_tilde_new, 0, sizeof(t_samplerate), 0, 0);
507 class_addbang(samplerate_tilde_class, samplerate_tilde_bang);
508}
509
510/* ------------------------ global setup routine ------------------------- */
511
512void d_misc_setup(void)
513{
514#ifndef FIXEDPOINT
515 print_setup();
516#endif
517 scope_setup();
518 bang_tilde_setup();
519 samplerate_tilde_setup();
520}
521
522
523
524