From a71366075fadcdb720b8fa02663bb19200fed5e5 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 13 Dec 2010 02:26:52 +0000 Subject: refactored d_misc.c into bang~.c and print~.c svn path=/trunk/; revision=14609 --- externals/vanilla/Makefile | 2 +- externals/vanilla/bang~-help.pd | 18 ++++++++++ externals/vanilla/bang~.c | 56 ++++++++++++++++++++++++++++++ externals/vanilla/lib_d_misc.c | 5 --- externals/vanilla/print~-help.pd | 18 ++++++++++ externals/vanilla/print~.c | 75 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 168 insertions(+), 6 deletions(-) create mode 100644 externals/vanilla/bang~-help.pd create mode 100644 externals/vanilla/bang~.c delete mode 100644 externals/vanilla/lib_d_misc.c create mode 100644 externals/vanilla/print~-help.pd create mode 100644 externals/vanilla/print~.c (limited to 'externals/vanilla') diff --git a/externals/vanilla/Makefile b/externals/vanilla/Makefile index 1aaf6884..9576a30e 100644 --- a/externals/vanilla/Makefile +++ b/externals/vanilla/Makefile @@ -5,7 +5,7 @@ LIBRARY_NAME = vanilla # add your .c source files, one object per file, to the SOURCES # variable, help files will be included automatically -SOURCES = abs~.c bng.c clip~.c cnv.c dbtopow~.c dbtorms~.c del.c delay.c exp~.c ftom~.c hdl.c hradio.c hsl.c hslider.c key.c keyname.c keyup.c line.c list.c log~.c metro.c mtof~.c my_canvas.c my_numbox.c nbx.c netsend.c netreceive.c openpanel.c pipe.c powtodb~.c pow~.c print.c qlist.c radiobut.c radiobutton.c rdb.c rmstodb~.c rsqrt~.c savepanel.c sqrt~.c textfile.c tgl.c timer.c toggle.c vdl.c vradio.c vsl.c vslider.c vu.c wrap~.c random.c loadbang.c namecanvas.c cputime.c realtime.c +SOURCES = abs~.c bng.c clip~.c cnv.c dbtopow~.c dbtorms~.c del.c delay.c exp~.c ftom~.c hdl.c hradio.c hsl.c hslider.c key.c keyname.c keyup.c line.c list.c log~.c metro.c mtof~.c my_canvas.c my_numbox.c nbx.c netsend.c netreceive.c openpanel.c pipe.c powtodb~.c pow~.c print.c qlist.c radiobut.c radiobutton.c rdb.c rmstodb~.c rsqrt~.c savepanel.c sqrt~.c textfile.c tgl.c timer.c toggle.c vdl.c vradio.c vsl.c vslider.c vu.c wrap~.c random.c loadbang.c namecanvas.c cputime.c realtime.c bang~.c print~.c # list all pd objects (i.e. myobject.pd) files here, and their helpfiles will # be included automatically diff --git a/externals/vanilla/bang~-help.pd b/externals/vanilla/bang~-help.pd new file mode 100644 index 00000000..debade2f --- /dev/null +++ b/externals/vanilla/bang~-help.pd @@ -0,0 +1,18 @@ +#N canvas 0 0 529 299 12; +#X obj 112 128 bang~; +#X obj 112 159 print; +#X msg 210 223 \; pd dsp 1; +#X msg 297 216 \; pd dsp 0; +#X msg 210 144 bang; +#X obj 19 20 bang~; +#X obj 306 193 loadbang; +#X obj 297 169 delay 100; +#X text 211 122 click to test; +#X text 71 21 - output bang after each DSP cycle; +#X text 5 59 Bang~ outputs a bang after each DSP cycle (at the same logical time as the DSP cycle.) This is primarily useful for sampling the outputs of analysis algorithms.; +#X text 251 266 updated for Pd version 0.33; +#X connect 0 0 1 0; +#X connect 4 0 2 0; +#X connect 4 0 7 0; +#X connect 6 0 3 0; +#X connect 7 0 3 0; diff --git a/externals/vanilla/bang~.c b/externals/vanilla/bang~.c new file mode 100644 index 00000000..559e6ef1 --- /dev/null +++ b/externals/vanilla/bang~.c @@ -0,0 +1,56 @@ +/* Copyright (c) 1997-1999 Miller Puckette. +* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* miscellaneous: print~; more to come. +*/ + +#include "m_pd.h" +#include +#include + +static t_class *bang_tilde_class; + +typedef struct _bang +{ + t_object x_obj; + t_clock *x_clock; +} t_bang; + +static t_int *bang_tilde_perform(t_int *w) +{ + t_bang *x = (t_bang *)(w[1]); + clock_delay(x->x_clock, 0); + return (w+2); +} + +static void bang_tilde_dsp(t_bang *x, t_signal **sp) +{ + dsp_add(bang_tilde_perform, 1, x); +} + +static void bang_tilde_tick(t_bang *x) +{ + outlet_bang(x->x_obj.ob_outlet); +} + +static void bang_tilde_free(t_bang *x) +{ + clock_free(x->x_clock); +} + +static void *bang_tilde_new(t_symbol *s) +{ + t_bang *x = (t_bang *)pd_new(bang_tilde_class); + x->x_clock = clock_new(x, (t_method)bang_tilde_tick); + outlet_new(&x->x_obj, &s_bang); + return (x); +} + +void bang_tilde_setup(void) +{ + bang_tilde_class = class_new(gensym("bang~"), (t_newmethod)bang_tilde_new, + (t_method)bang_tilde_free, sizeof(t_bang), 0, 0); + class_addmethod(bang_tilde_class, (t_method)bang_tilde_dsp, + gensym("dsp"), 0); +} diff --git a/externals/vanilla/lib_d_misc.c b/externals/vanilla/lib_d_misc.c deleted file mode 100644 index fb70d525..00000000 --- a/externals/vanilla/lib_d_misc.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "../../pd/src/d_misc.c" -void lib_d_misc_setup(void) -{ - d_misc_setup(); -} diff --git a/externals/vanilla/print~-help.pd b/externals/vanilla/print~-help.pd new file mode 100644 index 00000000..b3a9c429 --- /dev/null +++ b/externals/vanilla/print~-help.pd @@ -0,0 +1,18 @@ +#N canvas 118 333 531 212 10; +#X msg 74 143 2; +#X msg 455 77 \; pd dsp 0; +#X msg 454 40 \; pd dsp 1; +#X obj 62 177 print~; +#X msg 74 118 bang; +#X obj 62 92 phasor~ 1000; +#X text 122 119 bang prints one vector; +#X obj 454 18 loadbang; +#X text 109 142 print two or more successive vectors; +#X obj 32 12 print~; +#X text 85 12 - print out raw values of a signal; +#X text 301 171 Updated for Pd version 0.33; +#X text 19 44 The print~ object takes a signal input and prints one or more vectors out when you send it a bang or a number. By default a vector is 64 samples.; +#X connect 0 0 3 0; +#X connect 4 0 3 0; +#X connect 5 0 3 0; +#X connect 7 0 2 0; diff --git a/externals/vanilla/print~.c b/externals/vanilla/print~.c new file mode 100644 index 00000000..6615c34c --- /dev/null +++ b/externals/vanilla/print~.c @@ -0,0 +1,75 @@ +/* Copyright (c) 1997-1999 Miller Puckette. +* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* miscellaneous: print~; more to come. +*/ + +#include "m_pd.h" +#include +#include + +/* ------------------------- print~ -------------------------- */ +static t_class *print_class; + +typedef struct _print +{ + t_object x_obj; + t_float x_f; + t_symbol *x_sym; + int x_count; +} t_print; + +static t_int *print_perform(t_int *w) +{ + t_print *x = (t_print *)(w[1]); + t_sample *in = (t_sample *)(w[2]); + int n = (int)(w[3]); + if (x->x_count) + { + int i=0; + startpost("%s:", x->x_sym->s_name); + for(i=0; ix_count--; + } + return (w+4); +} + +static void print_dsp(t_print *x, t_signal **sp) +{ + dsp_add(print_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); +} + +static void print_float(t_print *x, t_float f) +{ + if (f < 0) f = 0; + x->x_count = f; +} + +static void print_bang(t_print *x) +{ + x->x_count = 1; +} + +static void *print_new(t_symbol *s) +{ + t_print *x = (t_print *)pd_new(print_class); + x->x_sym = (s->s_name[0]? s : gensym("print~")); + x->x_count = 0; + x->x_f = 0; + return (x); +} + +void print_tilde_setup(void) +{ + print_class = class_new(gensym("print~"), (t_newmethod)print_new, 0, + sizeof(t_print), 0, A_DEFSYM, 0); + CLASS_MAINSIGNALIN(print_class, t_print, x_f); + class_addmethod(print_class, (t_method)print_dsp, gensym("dsp"), 0); + class_addbang(print_class, print_bang); + class_addfloat(print_class, print_float); +} -- cgit v1.2.1