From 8bbda088b6be12a1c8633a05f2c3edee28c3b493 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 2 Apr 2007 20:42:38 +0000 Subject: cleaned up cxc so that it passes the automated test in scripts/load_every_help.sh: renamed help files to standard name; made each file named after the class; removed non-functional aliases in flatspace svn path=/trunk/externals/cxc/; revision=7538 --- ENV.c | 1 - bangfilt.c | 52 ------ bangfilt2.c | 53 ------ bfilt.c | 52 ++++++ bfilt2.c | 53 ++++++ delta~.c | 55 ++++++ makefile | 2 +- makefile.in | 2 +- mean.c | 440 -------------------------------------------- mean~.c | 440 ++++++++++++++++++++++++++++++++++++++++++++ microtime.c | 76 -------- proc.c | 1 - reference/ENV-help.pd | 34 ++++ reference/ENV.pd | 34 ---- reference/ascseq-help.pd | 12 ++ reference/ascseq.pd | 12 -- reference/ascwave-help.pd | 65 +++++++ reference/ascwave.pd | 65 ------- reference/bfilt-help.pd | 23 +++ reference/bfilt.pd | 23 --- reference/bfilt2-help.pd | 23 +++ reference/delta.pd | 63 ------- reference/delta~-help.pd | 63 +++++++ reference/proc-help.pd | 75 ++++++++ reference/proc.pd | 75 -------- reference/randomix-help.pd | 223 ++++++++++++++++++++++ reference/randomix.pd | 223 ---------------------- reference/reson~-help.pd | 3 + reference/reson~.pd | 3 - reference/serialize-help.pd | 10 + reference/serialize.pd | 10 - reference/utime-help.pd | 9 + reference/utime.pd | 9 - reson.c | 156 ---------------- reson~.c | 156 ++++++++++++++++ sigdelta.c | 56 ------ utime.c | 75 ++++++++ 37 files changed, 1373 insertions(+), 1354 deletions(-) delete mode 100644 bangfilt.c delete mode 100644 bangfilt2.c create mode 100644 bfilt.c create mode 100644 bfilt2.c create mode 100644 delta~.c delete mode 100644 mean.c create mode 100644 mean~.c delete mode 100644 microtime.c create mode 100644 reference/ENV-help.pd delete mode 100644 reference/ENV.pd create mode 100644 reference/ascseq-help.pd delete mode 100644 reference/ascseq.pd create mode 100644 reference/ascwave-help.pd delete mode 100644 reference/ascwave.pd create mode 100644 reference/bfilt-help.pd delete mode 100644 reference/bfilt.pd create mode 100644 reference/bfilt2-help.pd delete mode 100644 reference/delta.pd create mode 100644 reference/delta~-help.pd create mode 100644 reference/proc-help.pd delete mode 100644 reference/proc.pd create mode 100644 reference/randomix-help.pd delete mode 100644 reference/randomix.pd create mode 100644 reference/reson~-help.pd delete mode 100644 reference/reson~.pd create mode 100644 reference/serialize-help.pd delete mode 100644 reference/serialize.pd create mode 100644 reference/utime-help.pd delete mode 100644 reference/utime.pd delete mode 100644 reson.c create mode 100644 reson~.c delete mode 100644 sigdelta.c create mode 100644 utime.c diff --git a/ENV.c b/ENV.c index 772e4e1..c898559 100644 --- a/ENV.c +++ b/ENV.c @@ -84,6 +84,5 @@ void ENV_setup(void) class_addmethod(ENV_class, (t_method)ENV_getenv, gensym("getenv"), A_SYMBOL); class_addmethod(ENV_class, (t_method)ENV_setenv, gensym("setenv"), A_SYMBOL, A_SYMBOL); class_addfloat(ENV_class, ENV_float); - class_sethelpsymbol(ENV_class, gensym("ENV.pd")); } diff --git a/bangfilt.c b/bangfilt.c deleted file mode 100644 index 54b1e69..0000000 --- a/bangfilt.c +++ /dev/null @@ -1,52 +0,0 @@ -/* bangfilter: = % x plus sel 0 - * spaeter: % x plus sel y mit 2 arguments - */ -#include "m_pd.h" -#include - -static t_class *bfilt_class; - -typedef struct _bfilt -{ - t_object x_obj; - t_float x_f1; - t_float x_f2; -} t_bfilt; - -static void *bfilt_new(t_floatarg f) -{ - t_bfilt *x = (t_bfilt *)pd_new(bfilt_class); - outlet_new(&x->x_obj, &s_bang); - floatinlet_new(&x->x_obj, &x->x_f2); - x->x_f1 = 0; - x->x_f2 = f; - return (x); -} - -static void bfilt_bang(t_bfilt *x) -{ - int n2 = x->x_f2, result; - if (n2 < 0) n2 = -n2; - else if (!n2) n2 = 1; - result = ((int)(x->x_f1)) % n2; - if (result == 0) //result += n2; - { - outlet_bang(x->x_obj.ob_outlet); - } - //outlet_float(x->x_obj.ob_outlet, (t_float)result); -} - -static void bfilt_float(t_bfilt *x, t_float f) -{ - x->x_f1 = f; - bfilt_bang(x); -} - - -void bfilt_setup() -{ - bfilt_class = class_new(gensym("bfilt"), (t_newmethod)bfilt_new, 0, - sizeof(t_bfilt), 0, A_DEFFLOAT, 0); - class_addbang(bfilt_class, bfilt_bang); - class_addfloat(bfilt_class, (t_method)bfilt_float); -} diff --git a/bangfilt2.c b/bangfilt2.c deleted file mode 100644 index 9dd6c8c..0000000 --- a/bangfilt2.c +++ /dev/null @@ -1,53 +0,0 @@ -/* bangfilter: = % x plus sel 0 - * spaeter: % x plus sel y mit 2 arguments - */ -#include "m_pd.h" -#include - -static t_class *bfilt2_class; - -typedef struct _bfilt2 -{ - t_object x_obj; - t_float x_f1; - t_float x_f2; -} t_bfilt2; - -static void *bfilt2_new(t_floatarg f) -{ - t_bfilt2 *x = (t_bfilt2 *)pd_new(bfilt2_class); - outlet_new(&x->x_obj, &s_bang); - floatinlet_new(&x->x_obj, &x->x_f2); - x->x_f1 = 0; - x->x_f2 = f; - return (x); -} - -static void bfilt2_bang(t_bfilt2 *x) -{ - int n2 = x->x_f2, result; - if (n2 < 0) n2 = -n2; - else if (!n2) n2 = 1; - x->x_f1++; - result = ((int)(x->x_f1)) % n2; - if (result == 0) //result += n2; - { - outlet_bang(x->x_obj.ob_outlet); - } - //outlet_float(x->x_obj.ob_outlet, (t_float)result); -} - -static void bfilt2_float(t_bfilt2 *x, t_float f) -{ - x->x_f1 = f; - bfilt2_bang(x); -} - - -void bfilt2_setup() -{ - bfilt2_class = class_new(gensym("bfilt2"), (t_newmethod)bfilt2_new, 0, - sizeof(t_bfilt2), 0, A_DEFFLOAT, 0); - class_addbang(bfilt2_class, bfilt2_bang); - class_addfloat(bfilt2_class, (t_method)bfilt2_float); -} diff --git a/bfilt.c b/bfilt.c new file mode 100644 index 0000000..54b1e69 --- /dev/null +++ b/bfilt.c @@ -0,0 +1,52 @@ +/* bangfilter: = % x plus sel 0 + * spaeter: % x plus sel y mit 2 arguments + */ +#include "m_pd.h" +#include + +static t_class *bfilt_class; + +typedef struct _bfilt +{ + t_object x_obj; + t_float x_f1; + t_float x_f2; +} t_bfilt; + +static void *bfilt_new(t_floatarg f) +{ + t_bfilt *x = (t_bfilt *)pd_new(bfilt_class); + outlet_new(&x->x_obj, &s_bang); + floatinlet_new(&x->x_obj, &x->x_f2); + x->x_f1 = 0; + x->x_f2 = f; + return (x); +} + +static void bfilt_bang(t_bfilt *x) +{ + int n2 = x->x_f2, result; + if (n2 < 0) n2 = -n2; + else if (!n2) n2 = 1; + result = ((int)(x->x_f1)) % n2; + if (result == 0) //result += n2; + { + outlet_bang(x->x_obj.ob_outlet); + } + //outlet_float(x->x_obj.ob_outlet, (t_float)result); +} + +static void bfilt_float(t_bfilt *x, t_float f) +{ + x->x_f1 = f; + bfilt_bang(x); +} + + +void bfilt_setup() +{ + bfilt_class = class_new(gensym("bfilt"), (t_newmethod)bfilt_new, 0, + sizeof(t_bfilt), 0, A_DEFFLOAT, 0); + class_addbang(bfilt_class, bfilt_bang); + class_addfloat(bfilt_class, (t_method)bfilt_float); +} diff --git a/bfilt2.c b/bfilt2.c new file mode 100644 index 0000000..9dd6c8c --- /dev/null +++ b/bfilt2.c @@ -0,0 +1,53 @@ +/* bangfilter: = % x plus sel 0 + * spaeter: % x plus sel y mit 2 arguments + */ +#include "m_pd.h" +#include + +static t_class *bfilt2_class; + +typedef struct _bfilt2 +{ + t_object x_obj; + t_float x_f1; + t_float x_f2; +} t_bfilt2; + +static void *bfilt2_new(t_floatarg f) +{ + t_bfilt2 *x = (t_bfilt2 *)pd_new(bfilt2_class); + outlet_new(&x->x_obj, &s_bang); + floatinlet_new(&x->x_obj, &x->x_f2); + x->x_f1 = 0; + x->x_f2 = f; + return (x); +} + +static void bfilt2_bang(t_bfilt2 *x) +{ + int n2 = x->x_f2, result; + if (n2 < 0) n2 = -n2; + else if (!n2) n2 = 1; + x->x_f1++; + result = ((int)(x->x_f1)) % n2; + if (result == 0) //result += n2; + { + outlet_bang(x->x_obj.ob_outlet); + } + //outlet_float(x->x_obj.ob_outlet, (t_float)result); +} + +static void bfilt2_float(t_bfilt2 *x, t_float f) +{ + x->x_f1 = f; + bfilt2_bang(x); +} + + +void bfilt2_setup() +{ + bfilt2_class = class_new(gensym("bfilt2"), (t_newmethod)bfilt2_new, 0, + sizeof(t_bfilt2), 0, A_DEFFLOAT, 0); + class_addbang(bfilt2_class, bfilt2_bang); + class_addfloat(bfilt2_class, (t_method)bfilt2_float); +} diff --git a/delta~.c b/delta~.c new file mode 100644 index 0000000..8b1826f --- /dev/null +++ b/delta~.c @@ -0,0 +1,55 @@ +#include "m_pd.h" +#include +#ifdef NT +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ delta~ ----------------------------- */ + +/* tilde object to take difference value. */ + +static t_class *delta_class; + +typedef struct _delta +{ + t_object x_obj; + t_sample x_last; +} t_delta; + +static t_int *delta_perform(t_int *w) +{ + t_delta *x = (t_delta *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + while (n--) + { + float f = *(in++); + // *out++ = (f > 0 ? f : -f); + *out++ = (f > x->x_last ? fabs(f - x->x_last) : -fabs(f - x->x_last)); + x->x_last = f; + } + return (w+5); +} + +static void delta_dsp(t_delta *x, t_signal **sp) +{ + dsp_add(delta_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +static void *delta_new(void) +{ + t_delta *x = (t_delta *)pd_new(delta_class); + x->x_last = 0.; + outlet_new(&x->x_obj, gensym("signal")); + return (x); +} + +void delta_tilde_setup(void) +{ + delta_class = class_new(gensym("delta~"), (t_newmethod)delta_new, 0, + sizeof(t_delta), 0, A_DEFFLOAT, 0); + class_addmethod(delta_class, nullfn, gensym("signal"), 0); + class_addmethod(delta_class, (t_method)delta_dsp, gensym("dsp"), 0); +} diff --git a/makefile b/makefile index e5f370b..63d3627 100644 --- a/makefile +++ b/makefile @@ -22,7 +22,7 @@ CXXFLAGS = $(CFLAGS) LIBS = -lc -lm #LIBS = -lpthread -lm -lc -SOURCES = ENV.c ascseq.c ascwave.c bangfilt.c bangfilt2.c binshift.c cx.c ixprint.c mean.c microtime.c proc.c randomix.c reson.c sigdelta.c split.c +SOURCES = ENV.c ascseq.c ascwave.c bangfilt.c bangfilt2.c binshift.c cx.c ixprint.c mean.c utime.c proc.c randomix.c reson~.c sigdelta.c split.c TARGETS = $(SOURCES:.c=.$(EXT)) # all: $(TARGETS) diff --git a/makefile.in b/makefile.in index 3d0fec8..163b6e1 100644 --- a/makefile.in +++ b/makefile.in @@ -22,7 +22,7 @@ CXXFLAGS = $(CFLAGS) LIBS = -lc -lm #LIBS = -lpthread -lm -lc -SOURCES = ENV.c ascseq.c ascwave.c bangfilt.c bangfilt2.c binshift.c counter.c cx.c ixprint.c mean.c microtime.c prepend.c proc.c randomix.c reson.c sigdelta.c split.c +SOURCES = ENV.c ascseq.c ascwave.c bangfilt.c bangfilt2.c binshift.c counter.c cx.c ixprint.c mean.c utime.c prepend.c proc.c randomix.c reson~.c sigdelta.c split.c TARGETS = $(SOURCES:.c=.$(EXT)) # all: $(TARGETS) diff --git a/mean.c b/mean.c deleted file mode 100644 index fe6b7c6..0000000 --- a/mean.c +++ /dev/null @@ -1,440 +0,0 @@ -/* - jdl@xdv.org, 200203 - calculate mean of buffer - standard deviation + histogram - */ - - -#include "m_pd.h" -#include -//#include - - -/* cx.mean: calculate the mean from a table */ -/* as defined by: add all samples together and divide by number of samples */ -t_class *cxmean_class; - -typedef struct _cxmean -{ - t_object x_obj; - t_symbol *x_arrayname; - t_float x_mean; - float *x_vec; - t_float f; - int x_nsampsintab; -} t_cxmean; - -void *cxmean_new(t_symbol *s) -{ - t_cxmean *x = (t_cxmean *)pd_new(cxmean_class); - x->x_arrayname = s; - x->x_mean = 0; - outlet_new(&x->x_obj, &s_float); - return (x); -} - -static void cxmean_set(t_cxmean *x, t_symbol *s) -{ - t_garray *a; - - x->x_arrayname = s; - if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) - { - if (*s->s_name) pd_error(x, "mean~: %s: no such array", - x->x_arrayname->s_name); - x->x_vec = 0; - } - else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec)) - { - error("%s: bad template for mean~", x->x_arrayname->s_name); - x->x_vec = 0; - } - else garray_usedindsp(a); -} - -void cxmean_bang(t_cxmean *x) -{ - outlet_float(x->x_obj.ob_outlet,x->x_mean); -} - -static void cxmean_mean(t_cxmean *x) -{ - // t_float *bl; - t_garray *a; - int cnt; - t_float *fp; - t_float xz = 0.; - - cnt = 0; - if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) { - pd_error(x, "%s: no such table", x->x_arrayname->s_name); - } - garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec); - - fp = x->x_vec; - - while(cnt < x->x_nsampsintab) { - //post("cxc/mean.c: %f",*fp++); - xz += *fp++; - cnt++; - } -#ifdef DEBUG - post("cxc/mean.c: sampsum: %f",xz); -#endif - x->x_mean = xz / x->x_nsampsintab; - - outlet_float(x->x_obj.ob_outlet, x->x_mean); -} - -void cxmean_setup(void) -{ - cxmean_class = class_new(gensym("cxmean"), - (t_newmethod)cxmean_new, - 0, - sizeof(t_cxmean), - CLASS_DEFAULT, - A_DEFSYM, 0); - class_addcreator((t_newmethod)cxmean_new,gensym("cx.mean"),A_DEFSYM, 0); - - class_addmethod(cxmean_class, (t_method)cxmean_set, - gensym("set"), A_DEFSYM, 0); - class_addmethod(cxmean_class, (t_method)cxmean_mean, - gensym("mean"), A_DEFSYM, 0); - class_addbang(cxmean_class, cxmean_bang); - class_sethelpsymbol(cxmean_class, gensym("statistics.pd")); -} - - -/* cx.avgdev: calculate the average deviation of an array from - mean as input and array. - takes mean as input, sum of abs values of sample-val - mean - divided by number of samples - */ - -t_class *cxavgdev_class; - -typedef struct _cxavgdev -{ - t_object x_obj; - t_symbol *x_arrayname; - t_float x_avgdev; - float *x_vec; - t_float f; - int x_nsampsintab; -} t_cxavgdev; - -void *cxavgdev_new(t_symbol *s) -{ - t_cxavgdev *x = (t_cxavgdev *)pd_new(cxavgdev_class); - x->x_arrayname = s; - x->x_avgdev = 0; - outlet_new(&x->x_obj, &s_float); - return (x); -} - -static void cxavgdev_set(t_cxavgdev *x, t_symbol *s) -{ - t_garray *a; - - x->x_arrayname = s; - if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) - { - if (*s->s_name) pd_error(x, "mean~: %s: no such array", - x->x_arrayname->s_name); - x->x_vec = 0; - } - else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec)) - { - error("%s: bad template for mean~", x->x_arrayname->s_name); - x->x_vec = 0; - } - else garray_usedindsp(a); -} - -void cxavgdev_bang(t_cxavgdev *x) -{ - outlet_float(x->x_obj.ob_outlet,x->x_avgdev); -} - -static void cxavgdev_float(t_cxavgdev *x, t_float f) -{ - // t_float *bl; - t_garray *a; - int cnt; - t_float *fp; - t_float xz = 0.; - t_float tz = 0.; - - cnt = 0; - if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) { - pd_error(x, "%s: no such table", x->x_arrayname->s_name); - } - garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec); - - fp = x->x_vec; - - while(cnt < x->x_nsampsintab) { - tz = *fp++; - tz = fabs(tz - f); - xz += tz; -#ifdef DEBUG - //post("cxc/mean.c: sampdeviation: %f",tz); -#endif - cnt++; - } -#ifdef DEBUG - post("cxc/mean.c: avgsum: %f",xz); -#endif - x->x_avgdev = xz / x->x_nsampsintab; - - outlet_float(x->x_obj.ob_outlet, x->x_avgdev); -} - -void cxavgdev_setup(void) -{ - cxavgdev_class = class_new(gensym("cxavgdev"), - (t_newmethod)cxavgdev_new, - 0, - sizeof(t_cxavgdev), - CLASS_DEFAULT, - A_DEFSYM, 0); - - class_addcreator((t_newmethod)cxavgdev_new,gensym("cx.avgdev"),A_DEFSYM, 0); - class_addmethod(cxavgdev_class, (t_method)cxavgdev_set, - gensym("set"), A_DEFSYM, 0); -/* class_addmethod(cxavgdev_class, (t_method)cxavgdev_mean, */ -/* gensym("mean"), A_DEFSYM, 0); */ - class_addfloat(cxavgdev_class, (t_method)cxavgdev_float); - class_addbang(cxavgdev_class, cxavgdev_bang); - class_sethelpsymbol(cxavgdev_class, gensym("statistics.pd")); -} - -/* cx.stddev: calculate the standard deviation of an array from - mean as input and array. - square root of sum of power of sample - mean divided by num of - samps - 1 - */ - -t_class *cxstddev_class; - -typedef struct _cxstddev -{ - t_object x_obj; - t_symbol *x_arrayname; - t_float x_stddev; - float *x_vec; - t_float f; - int x_nsampsintab; -} t_cxstddev; - -void *cxstddev_new(t_symbol *s) -{ - t_cxstddev *x = (t_cxstddev *)pd_new(cxstddev_class); - x->x_arrayname = s; - x->x_stddev = 0; - outlet_new(&x->x_obj, &s_float); - return (x); -} - -static void cxstddev_set(t_cxstddev *x, t_symbol *s) -{ - t_garray *a; - - x->x_arrayname = s; - if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) - { - if (*s->s_name) pd_error(x, "mean~: %s: no such array", - x->x_arrayname->s_name); - x->x_vec = 0; - } - else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec)) - { - error("%s: bad template for mean~", x->x_arrayname->s_name); - x->x_vec = 0; - } - else garray_usedindsp(a); -} - -void cxstddev_bang(t_cxstddev *x) -{ - outlet_float(x->x_obj.ob_outlet,x->x_stddev); -} - -static void cxstddev_float(t_cxstddev *x, t_float f) -{ - // t_float *bl; - t_garray *a; - int cnt; - t_float *fp; - t_float xz = 0.; - t_float tz = 0.; - - cnt = 0; - if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) { - pd_error(x, "%s: no such table", x->x_arrayname->s_name); - } - garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec); - - fp = x->x_vec; - - while(cnt < x->x_nsampsintab) { - tz = *fp++; - tz = pow(tz - f,2); // power of 2 - xz += tz; -#ifdef DEBUG - //post("cxc/mean.c: sampdeviation: %f",tz); -#endif - cnt++; - } -#ifdef DEBUG - post("cxc/mean.c: avgsum: %f",xz); -#endif - x->x_stddev = sqrt(xz / (x->x_nsampsintab - 1)); - - outlet_float(x->x_obj.ob_outlet, x->x_stddev); -} - -void cxstddev_setup(void) -{ - cxstddev_class = class_new(gensym("cxstddev"), - (t_newmethod)cxstddev_new, - 0, - sizeof(t_cxstddev), - CLASS_DEFAULT, - A_DEFSYM, 0); - - class_addcreator((t_newmethod)cxstddev_new,gensym("cx.stddev"),A_DEFSYM, 0); - class_addmethod(cxstddev_class, (t_method)cxstddev_set, - gensym("set"), A_DEFSYM, 0); -/* class_addmethod(cxstddev_class, (t_method)cxstddev_mean, */ -/* gensym("mean"), A_DEFSYM, 0); */ - class_addfloat(cxstddev_class, (t_method)cxstddev_float); - class_addbang(cxstddev_class, cxstddev_bang); - class_sethelpsymbol(cxstddev_class, gensym("statistics.pd")); -} - -/* ---------- mean~ ---------- */ -/* output the mean as a signal */ - -t_class *mean_tilde_class; - -typedef struct _mean_tilde -{ - t_object x_obj; - t_symbol *x_arrayname; - t_float x_mean; - float *x_vec; - t_float f; - int x_nsampsintab; -} t_mean_tilde; - -void *mean_tilde_new(t_symbol *s) -{ - t_mean_tilde *x = (t_mean_tilde *)pd_new(mean_tilde_class); - x->x_arrayname = s; - x->x_mean = 0; - outlet_new(&x->x_obj, &s_float); - return (x); -} - -static t_int *mean_tilde_perform(t_int *w) -{ - t_mean_tilde *x = (t_mean_tilde *)(w[1]); - //t_float *out = (t_float *)(w[3]), - t_float *fp; - //// t_float *in = (t_float *)(w[2]); - //// *out = *in; - int n = (int)(w[2]); - t_float xz = 0.; - fp = x->x_vec; - while(n--) { - xz += abs(*fp++); - //post("cxc/mean.c: %d : %f : %f",n,xz,fp); - } - x->x_mean = (t_float)(xz / n); - //post("cxc/mean.c: %f",xz); - return (w+3); - //return 0; -} - -static void mean_tilde_set(t_mean_tilde *x, t_symbol *s) -{ - t_garray *a; - - x->x_arrayname = s; - if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) - { - if (*s->s_name) pd_error(x, "mean~: %s: no such array", - x->x_arrayname->s_name); - x->x_vec = 0; - } - else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec)) - { - error("%s: bad template for mean~", x->x_arrayname->s_name); - x->x_vec = 0; - } - else garray_usedindsp(a); -} - -static void mean_tilde_dsp(t_mean_tilde *x, t_signal **sp) -{ - mean_tilde_set(x, x->x_arrayname); - //dsp_add(mean_tilde_perform, 2, x, sp[0]->s_vec, sp[0]->s_n); - //dsp_add(mean_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); - dsp_add(mean_tilde_perform, 2, x, sp[0]->s_n); -} - -void mean_tilde_bang(t_mean_tilde *x) -{ - outlet_float(x->x_obj.ob_outlet,x->x_mean); -} - -static void mean_tilde_mean(t_mean_tilde *x) -{ - // t_float *bl; - t_garray *a; - int cnt; - t_float *fp; - t_float xz = 0.; - - cnt = 0; - if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) { - pd_error(x, "%s: no such table", x->x_arrayname->s_name); - } - garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec); - - fp = x->x_vec; - - while(cnt < x->x_nsampsintab) { - //post("cxc/mean.c: %f",*fp++); - xz += *fp++; - cnt++; - } -#ifdef DEBUG - post("cxc/mean.c: sampsum: %f",xz); -#endif - x->x_mean = xz / x->x_nsampsintab; - - outlet_float(x->x_obj.ob_outlet, x->x_mean); -} - -void mean_tilde_setup(void) -{ - //post("mean~ setup"); - mean_tilde_class = class_new(gensym("mean~"), - (t_newmethod)mean_tilde_new, - 0, - sizeof(t_mean_tilde), - CLASS_DEFAULT, - A_DEFSYM, 0); - //CLASS_MAINSIGNALIN(mean_tilde_class, t_mean_tilde, f); - class_addmethod(mean_tilde_class, nullfn, gensym("signal"), 0); - class_addmethod(mean_tilde_class, - (t_method)mean_tilde_dsp, - gensym("dsp"), 0); - class_addmethod(mean_tilde_class, (t_method)mean_tilde_set, - gensym("set"), A_DEFSYM, 0); - class_addmethod(mean_tilde_class, (t_method)mean_tilde_mean, - gensym("mean"), A_DEFSYM, 0); - class_addbang(mean_tilde_class, mean_tilde_bang); -} diff --git a/mean~.c b/mean~.c new file mode 100644 index 0000000..fe6b7c6 --- /dev/null +++ b/mean~.c @@ -0,0 +1,440 @@ +/* + jdl@xdv.org, 200203 + calculate mean of buffer + standard deviation + histogram + */ + + +#include "m_pd.h" +#include +//#include + + +/* cx.mean: calculate the mean from a table */ +/* as defined by: add all samples together and divide by number of samples */ +t_class *cxmean_class; + +typedef struct _cxmean +{ + t_object x_obj; + t_symbol *x_arrayname; + t_float x_mean; + float *x_vec; + t_float f; + int x_nsampsintab; +} t_cxmean; + +void *cxmean_new(t_symbol *s) +{ + t_cxmean *x = (t_cxmean *)pd_new(cxmean_class); + x->x_arrayname = s; + x->x_mean = 0; + outlet_new(&x->x_obj, &s_float); + return (x); +} + +static void cxmean_set(t_cxmean *x, t_symbol *s) +{ + t_garray *a; + + x->x_arrayname = s; + if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) + { + if (*s->s_name) pd_error(x, "mean~: %s: no such array", + x->x_arrayname->s_name); + x->x_vec = 0; + } + else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec)) + { + error("%s: bad template for mean~", x->x_arrayname->s_name); + x->x_vec = 0; + } + else garray_usedindsp(a); +} + +void cxmean_bang(t_cxmean *x) +{ + outlet_float(x->x_obj.ob_outlet,x->x_mean); +} + +static void cxmean_mean(t_cxmean *x) +{ + // t_float *bl; + t_garray *a; + int cnt; + t_float *fp; + t_float xz = 0.; + + cnt = 0; + if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) { + pd_error(x, "%s: no such table", x->x_arrayname->s_name); + } + garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec); + + fp = x->x_vec; + + while(cnt < x->x_nsampsintab) { + //post("cxc/mean.c: %f",*fp++); + xz += *fp++; + cnt++; + } +#ifdef DEBUG + post("cxc/mean.c: sampsum: %f",xz); +#endif + x->x_mean = xz / x->x_nsampsintab; + + outlet_float(x->x_obj.ob_outlet, x->x_mean); +} + +void cxmean_setup(void) +{ + cxmean_class = class_new(gensym("cxmean"), + (t_newmethod)cxmean_new, + 0, + sizeof(t_cxmean), + CLASS_DEFAULT, + A_DEFSYM, 0); + class_addcreator((t_newmethod)cxmean_new,gensym("cx.mean"),A_DEFSYM, 0); + + class_addmethod(cxmean_class, (t_method)cxmean_set, + gensym("set"), A_DEFSYM, 0); + class_addmethod(cxmean_class, (t_method)cxmean_mean, + gensym("mean"), A_DEFSYM, 0); + class_addbang(cxmean_class, cxmean_bang); + class_sethelpsymbol(cxmean_class, gensym("statistics.pd")); +} + + +/* cx.avgdev: calculate the average deviation of an array from + mean as input and array. + takes mean as input, sum of abs values of sample-val - mean + divided by number of samples + */ + +t_class *cxavgdev_class; + +typedef struct _cxavgdev +{ + t_object x_obj; + t_symbol *x_arrayname; + t_float x_avgdev; + float *x_vec; + t_float f; + int x_nsampsintab; +} t_cxavgdev; + +void *cxavgdev_new(t_symbol *s) +{ + t_cxavgdev *x = (t_cxavgdev *)pd_new(cxavgdev_class); + x->x_arrayname = s; + x->x_avgdev = 0; + outlet_new(&x->x_obj, &s_float); + return (x); +} + +static void cxavgdev_set(t_cxavgdev *x, t_symbol *s) +{ + t_garray *a; + + x->x_arrayname = s; + if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) + { + if (*s->s_name) pd_error(x, "mean~: %s: no such array", + x->x_arrayname->s_name); + x->x_vec = 0; + } + else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec)) + { + error("%s: bad template for mean~", x->x_arrayname->s_name); + x->x_vec = 0; + } + else garray_usedindsp(a); +} + +void cxavgdev_bang(t_cxavgdev *x) +{ + outlet_float(x->x_obj.ob_outlet,x->x_avgdev); +} + +static void cxavgdev_float(t_cxavgdev *x, t_float f) +{ + // t_float *bl; + t_garray *a; + int cnt; + t_float *fp; + t_float xz = 0.; + t_float tz = 0.; + + cnt = 0; + if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) { + pd_error(x, "%s: no such table", x->x_arrayname->s_name); + } + garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec); + + fp = x->x_vec; + + while(cnt < x->x_nsampsintab) { + tz = *fp++; + tz = fabs(tz - f); + xz += tz; +#ifdef DEBUG + //post("cxc/mean.c: sampdeviation: %f",tz); +#endif + cnt++; + } +#ifdef DEBUG + post("cxc/mean.c: avgsum: %f",xz); +#endif + x->x_avgdev = xz / x->x_nsampsintab; + + outlet_float(x->x_obj.ob_outlet, x->x_avgdev); +} + +void cxavgdev_setup(void) +{ + cxavgdev_class = class_new(gensym("cxavgdev"), + (t_newmethod)cxavgdev_new, + 0, + sizeof(t_cxavgdev), + CLASS_DEFAULT, + A_DEFSYM, 0); + + class_addcreator((t_newmethod)cxavgdev_new,gensym("cx.avgdev"),A_DEFSYM, 0); + class_addmethod(cxavgdev_class, (t_method)cxavgdev_set, + gensym("set"), A_DEFSYM, 0); +/* class_addmethod(cxavgdev_class, (t_method)cxavgdev_mean, */ +/* gensym("mean"), A_DEFSYM, 0); */ + class_addfloat(cxavgdev_class, (t_method)cxavgdev_float); + class_addbang(cxavgdev_class, cxavgdev_bang); + class_sethelpsymbol(cxavgdev_class, gensym("statistics.pd")); +} + +/* cx.stddev: calculate the standard deviation of an array from + mean as input and array. + square root of sum of power of sample - mean divided by num of + samps - 1 + */ + +t_class *cxstddev_class; + +typedef struct _cxstddev +{ + t_object x_obj; + t_symbol *x_arrayname; + t_float x_stddev; + float *x_vec; + t_float f; + int x_nsampsintab; +} t_cxstddev; + +void *cxstddev_new(t_symbol *s) +{ + t_cxstddev *x = (t_cxstddev *)pd_new(cxstddev_class); + x->x_arrayname = s; + x->x_stddev = 0; + outlet_new(&x->x_obj, &s_float); + return (x); +} + +static void cxstddev_set(t_cxstddev *x, t_symbol *s) +{ + t_garray *a; + + x->x_arrayname = s; + if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) + { + if (*s->s_name) pd_error(x, "mean~: %s: no such array", + x->x_arrayname->s_name); + x->x_vec = 0; + } + else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec)) + { + error("%s: bad template for mean~", x->x_arrayname->s_name); + x->x_vec = 0; + } + else garray_usedindsp(a); +} + +void cxstddev_bang(t_cxstddev *x) +{ + outlet_float(x->x_obj.ob_outlet,x->x_stddev); +} + +static void cxstddev_float(t_cxstddev *x, t_float f) +{ + // t_float *bl; + t_garray *a; + int cnt; + t_float *fp; + t_float xz = 0.; + t_float tz = 0.; + + cnt = 0; + if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) { + pd_error(x, "%s: no such table", x->x_arrayname->s_name); + } + garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec); + + fp = x->x_vec; + + while(cnt < x->x_nsampsintab) { + tz = *fp++; + tz = pow(tz - f,2); // power of 2 + xz += tz; +#ifdef DEBUG + //post("cxc/mean.c: sampdeviation: %f",tz); +#endif + cnt++; + } +#ifdef DEBUG + post("cxc/mean.c: avgsum: %f",xz); +#endif + x->x_stddev = sqrt(xz / (x->x_nsampsintab - 1)); + + outlet_float(x->x_obj.ob_outlet, x->x_stddev); +} + +void cxstddev_setup(void) +{ + cxstddev_class = class_new(gensym("cxstddev"), + (t_newmethod)cxstddev_new, + 0, + sizeof(t_cxstddev), + CLASS_DEFAULT, + A_DEFSYM, 0); + + class_addcreator((t_newmethod)cxstddev_new,gensym("cx.stddev"),A_DEFSYM, 0); + class_addmethod(cxstddev_class, (t_method)cxstddev_set, + gensym("set"), A_DEFSYM, 0); +/* class_addmethod(cxstddev_class, (t_method)cxstddev_mean, */ +/* gensym("mean"), A_DEFSYM, 0); */ + class_addfloat(cxstddev_class, (t_method)cxstddev_float); + class_addbang(cxstddev_class, cxstddev_bang); + class_sethelpsymbol(cxstddev_class, gensym("statistics.pd")); +} + +/* ---------- mean~ ---------- */ +/* output the mean as a signal */ + +t_class *mean_tilde_class; + +typedef struct _mean_tilde +{ + t_object x_obj; + t_symbol *x_arrayname; + t_float x_mean; + float *x_vec; + t_float f; + int x_nsampsintab; +} t_mean_tilde; + +void *mean_tilde_new(t_symbol *s) +{ + t_mean_tilde *x = (t_mean_tilde *)pd_new(mean_tilde_class); + x->x_arrayname = s; + x->x_mean = 0; + outlet_new(&x->x_obj, &s_float); + return (x); +} + +static t_int *mean_tilde_perform(t_int *w) +{ + t_mean_tilde *x = (t_mean_tilde *)(w[1]); + //t_float *out = (t_float *)(w[3]), + t_float *fp; + //// t_float *in = (t_float *)(w[2]); + //// *out = *in; + int n = (int)(w[2]); + t_float xz = 0.; + fp = x->x_vec; + while(n--) { + xz += abs(*fp++); + //post("cxc/mean.c: %d : %f : %f",n,xz,fp); + } + x->x_mean = (t_float)(xz / n); + //post("cxc/mean.c: %f",xz); + return (w+3); + //return 0; +} + +static void mean_tilde_set(t_mean_tilde *x, t_symbol *s) +{ + t_garray *a; + + x->x_arrayname = s; + if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) + { + if (*s->s_name) pd_error(x, "mean~: %s: no such array", + x->x_arrayname->s_name); + x->x_vec = 0; + } + else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec)) + { + error("%s: bad template for mean~", x->x_arrayname->s_name); + x->x_vec = 0; + } + else garray_usedindsp(a); +} + +static void mean_tilde_dsp(t_mean_tilde *x, t_signal **sp) +{ + mean_tilde_set(x, x->x_arrayname); + //dsp_add(mean_tilde_perform, 2, x, sp[0]->s_vec, sp[0]->s_n); + //dsp_add(mean_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); + dsp_add(mean_tilde_perform, 2, x, sp[0]->s_n); +} + +void mean_tilde_bang(t_mean_tilde *x) +{ + outlet_float(x->x_obj.ob_outlet,x->x_mean); +} + +static void mean_tilde_mean(t_mean_tilde *x) +{ + // t_float *bl; + t_garray *a; + int cnt; + t_float *fp; + t_float xz = 0.; + + cnt = 0; + if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) { + pd_error(x, "%s: no such table", x->x_arrayname->s_name); + } + garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec); + + fp = x->x_vec; + + while(cnt < x->x_nsampsintab) { + //post("cxc/mean.c: %f",*fp++); + xz += *fp++; + cnt++; + } +#ifdef DEBUG + post("cxc/mean.c: sampsum: %f",xz); +#endif + x->x_mean = xz / x->x_nsampsintab; + + outlet_float(x->x_obj.ob_outlet, x->x_mean); +} + +void mean_tilde_setup(void) +{ + //post("mean~ setup"); + mean_tilde_class = class_new(gensym("mean~"), + (t_newmethod)mean_tilde_new, + 0, + sizeof(t_mean_tilde), + CLASS_DEFAULT, + A_DEFSYM, 0); + //CLASS_MAINSIGNALIN(mean_tilde_class, t_mean_tilde, f); + class_addmethod(mean_tilde_class, nullfn, gensym("signal"), 0); + class_addmethod(mean_tilde_class, + (t_method)mean_tilde_dsp, + gensym("dsp"), 0); + class_addmethod(mean_tilde_class, (t_method)mean_tilde_set, + gensym("set"), A_DEFSYM, 0); + class_addmethod(mean_tilde_class, (t_method)mean_tilde_mean, + gensym("mean"), A_DEFSYM, 0); + class_addbang(mean_tilde_class, mean_tilde_bang); +} diff --git a/microtime.c b/microtime.c deleted file mode 100644 index dea2bb6..0000000 --- a/microtime.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - (c) 2002:cxc@web.fm - microtime: seconds since epoch plus microsecs - */ - -#include -#ifdef NT -#include -#else -#include -#endif -#include - -/* ----------------------- utime --------------------- */ - -static t_class *utime_class; - -typedef struct _utime -{ - t_object x_obj; - t_outlet *x_outlet1; - t_outlet *x_outlet2; -} t_utime; - -static void *utime_new(t_symbol *s, int argc, t_atom *argv) { - t_utime *x = (t_utime *)pd_new(utime_class); - x->x_outlet1 = outlet_new(&x->x_obj, &s_float); - x->x_outlet2 = outlet_new(&x->x_obj, &s_float); - return (x); -} - -#ifndef NT -static void utime_bang(t_utime *x) -{ - struct timeval myutime; - struct timezone mytz; - - gettimeofday(&myutime, &mytz); - outlet_float(x->x_outlet2, (t_float)myutime.tv_usec); - outlet_float(x->x_outlet1, (t_float)myutime.tv_sec); -} -#else -static void utime_bang(t_utime *x) -{ - FILETIME myfiletime; - ULARGE_INTEGER ulfiletime, ulSec, uluSec; - - GetSystemTimeAsFileTime(&myfiletime); - ulfiletime.LowPart = myfiletime.dwLowDateTime; - ulfiletime.HighPart = myfiletime.dwHighDateTime; - ulfiletime.QuadPart -= 116444736000000000; // number of 100ns ticks from 1601-01-01 to 1970-01-01 - ulSec.QuadPart = ulfiletime.QuadPart / (10 * 1000 * 1000); // FILETIME uses 100ns ticks - uluSec.QuadPart = (ulfiletime.QuadPart - ulSec.QuadPart * 10 * 1000 * 1000) / 10; // FILETIME uses 100ns ticks - - outlet_float(x->x_outlet2, (t_float)(__int64)ulSec.QuadPart ); - outlet_float(x->x_outlet1, (t_float)(__int64)uluSec.QuadPart); -} -#endif - -static void help_utime(t_utime *x) -{ - post("\n%c utime\t\t:: get the current system time", 70); - post("\noutputs are\t: seconds since epoch / remaining microseconds"); -} - -void utime_setup(void) -{ - utime_class = class_new(gensym("utime"), - (t_newmethod)utime_new, 0, - sizeof(t_utime), 0, A_GIMME, 0); - - class_addbang(utime_class, utime_bang); - - class_addmethod(utime_class, (t_method)help_utime, gensym("help"), 0); - class_sethelpsymbol(utime_class, gensym("utime.pd")); -} diff --git a/proc.c b/proc.c index 429cefa..1bb633c 100644 --- a/proc.c +++ b/proc.c @@ -218,6 +218,5 @@ void proc_setup(void) //class_addmethod(proc_class, (t_method)proc_getenv, gensym("getenv"), A_SYMBOL); //class_addmethod(proc_class, (t_method)proc_setenv, gensym("setenv"), A_SYMBOL, A_SYMBOL); class_addfloat(proc_class, proc_float); - class_sethelpsymbol(proc_class, gensym("proc.pd")); } diff --git a/reference/ENV-help.pd b/reference/ENV-help.pd new file mode 100644 index 0000000..7582c67 --- /dev/null +++ b/reference/ENV-help.pd @@ -0,0 +1,34 @@ +#N canvas 370 240 625 314 10; +#X obj 147 203 ENV; +#X msg 147 163 RAND_MAX; +#X floatatom 226 253 10 0 0; +#X obj 147 277 print; +#X msg 214 164 getenv \$1; +#X symbolatom 215 130 10 0 0; +#X obj 295 130 symbol; +#X msg 311 105 HOSTNAME; +#X msg 310 80 USERNAME; +#X obj 147 228 route symbol; +#X msg 147 253 \$1; +#X msg 424 110 USERNAME bla; +#X obj 386 168 cxc.prepend setenv; +#X obj 395 202 print pre; +#X msg 425 135 HOSTNAME testi; +#X msg 312 45 RANDOM; +#X text 18 7 get and set environment variables etc ...; +#X msg 244 51 DATE; +#X connect 0 0 9 0; +#X connect 1 0 0 0; +#X connect 4 0 0 0; +#X connect 5 0 4 0; +#X connect 6 0 4 0; +#X connect 7 0 6 0; +#X connect 8 0 6 0; +#X connect 9 0 10 0; +#X connect 9 1 2 0; +#X connect 10 0 3 0; +#X connect 11 0 12 0; +#X connect 12 0 0 0; +#X connect 14 0 12 0; +#X connect 15 0 6 0; +#X connect 17 0 6 0; diff --git a/reference/ENV.pd b/reference/ENV.pd deleted file mode 100644 index 7582c67..0000000 --- a/reference/ENV.pd +++ /dev/null @@ -1,34 +0,0 @@ -#N canvas 370 240 625 314 10; -#X obj 147 203 ENV; -#X msg 147 163 RAND_MAX; -#X floatatom 226 253 10 0 0; -#X obj 147 277 print; -#X msg 214 164 getenv \$1; -#X symbolatom 215 130 10 0 0; -#X obj 295 130 symbol; -#X msg 311 105 HOSTNAME; -#X msg 310 80 USERNAME; -#X obj 147 228 route symbol; -#X msg 147 253 \$1; -#X msg 424 110 USERNAME bla; -#X obj 386 168 cxc.prepend setenv; -#X obj 395 202 print pre; -#X msg 425 135 HOSTNAME testi; -#X msg 312 45 RANDOM; -#X text 18 7 get and set environment variables etc ...; -#X msg 244 51 DATE; -#X connect 0 0 9 0; -#X connect 1 0 0 0; -#X connect 4 0 0 0; -#X connect 5 0 4 0; -#X connect 6 0 4 0; -#X connect 7 0 6 0; -#X connect 8 0 6 0; -#X connect 9 0 10 0; -#X connect 9 1 2 0; -#X connect 10 0 3 0; -#X connect 11 0 12 0; -#X connect 12 0 0 0; -#X connect 14 0 12 0; -#X connect 15 0 6 0; -#X connect 17 0 6 0; diff --git a/reference/ascseq-help.pd b/reference/ascseq-help.pd new file mode 100644 index 0000000..5038a84 --- /dev/null +++ b/reference/ascseq-help.pd @@ -0,0 +1,12 @@ +#N canvas 454 117 570 300 10; +#X obj 132 168 print ascseq; +#X msg 253 112 bang; +#X obj 223 70 random_fl -10000 10000; +#X obj 131 118 ascseq 100; +#X floatatom 268 137 5 0 0; +#X msg 83 34 "abcde 123 dsfjnsdf ewrte 3k4n5 3n hjb5465hj 6"; +#X connect 1 0 2 0; +#X connect 2 0 3 0; +#X connect 3 0 0 0; +#X connect 4 0 3 1; +#X connect 5 0 3 0; diff --git a/reference/ascseq.pd b/reference/ascseq.pd deleted file mode 100644 index 5038a84..0000000 --- a/reference/ascseq.pd +++ /dev/null @@ -1,12 +0,0 @@ -#N canvas 454 117 570 300 10; -#X obj 132 168 print ascseq; -#X msg 253 112 bang; -#X obj 223 70 random_fl -10000 10000; -#X obj 131 118 ascseq 100; -#X floatatom 268 137 5 0 0; -#X msg 83 34 "abcde 123 dsfjnsdf ewrte 3k4n5 3n hjb5465hj 6"; -#X connect 1 0 2 0; -#X connect 2 0 3 0; -#X connect 3 0 0 0; -#X connect 4 0 3 1; -#X connect 5 0 3 0; diff --git a/reference/ascwave-help.pd b/reference/ascwave-help.pd new file mode 100644 index 0000000..bb36502 --- /dev/null +++ b/reference/ascwave-help.pd @@ -0,0 +1,65 @@ +#N canvas 448 258 407 316 10; +#X msg 80 153 bang; +#X floatatom 169 176; +#X floatatom 214 58; +#X obj 151 13 loadbang; +#X obj 157 97 metro 100; +#X msg 157 196 1; +#X msg 157 58 1; +#X msg 186 58 0; +#X obj 145 221 ascwave; +#X msg 75 192 fill 1; +#X msg 74 211 fill 0; +#X obj 145 262 ixprint; +#X msg 145 241 \$1; +#N canvas 517 176 588 372 modulate 0; +#X obj 84 200 outlet; +#X obj 84 139 random 80; +#X msg 30 110 bang; +#X obj 84 75 * 50; +#X obj 84 93 metro 5000; +#X obj 29 52 loadbang; +#X msg 29 70 1; +#X obj 84 161 pack 1 5000; +#X obj 84 180 line; +#X obj 86 31 inlet start/stop; +#X obj 130 53 inlet time; +#X connect 1 0 7 0; +#X connect 2 0 1 0; +#X connect 3 0 4 0; +#X connect 3 0 7 1; +#X connect 4 0 1 0; +#X connect 5 0 6 0; +#X connect 6 0 4 0; +#X connect 7 0 8 0; +#X connect 8 0 0 0; +#X connect 9 0 4 0; +#X connect 10 0 3 0; +#X restore 169 154 page modulate; +#X floatatom 262 132; +#X obj 262 179 min 127; +#X obj 262 154 max 33; +#X obj 157 77 f; +#X obj 210 78 f; +#X text 200 178 <== here; +#X text 297 131 <== and here; +#X connect 0 0 8 0; +#X connect 1 0 8 2; +#X connect 2 0 18 0; +#X connect 3 0 6 0; +#X connect 4 0 5 0; +#X connect 5 0 8 1; +#X connect 6 0 17 0; +#X connect 7 0 17 0; +#X connect 8 0 12 0; +#X connect 9 0 8 0; +#X connect 10 0 8 0; +#X connect 12 0 11 0; +#X connect 13 0 8 2; +#X connect 14 0 16 0; +#X connect 15 0 8 3; +#X connect 16 0 15 0; +#X connect 17 0 4 0; +#X connect 17 0 13 0; +#X connect 18 0 4 1; +#X connect 18 0 13 1; diff --git a/reference/ascwave.pd b/reference/ascwave.pd deleted file mode 100644 index bb36502..0000000 --- a/reference/ascwave.pd +++ /dev/null @@ -1,65 +0,0 @@ -#N canvas 448 258 407 316 10; -#X msg 80 153 bang; -#X floatatom 169 176; -#X floatatom 214 58; -#X obj 151 13 loadbang; -#X obj 157 97 metro 100; -#X msg 157 196 1; -#X msg 157 58 1; -#X msg 186 58 0; -#X obj 145 221 ascwave; -#X msg 75 192 fill 1; -#X msg 74 211 fill 0; -#X obj 145 262 ixprint; -#X msg 145 241 \$1; -#N canvas 517 176 588 372 modulate 0; -#X obj 84 200 outlet; -#X obj 84 139 random 80; -#X msg 30 110 bang; -#X obj 84 75 * 50; -#X obj 84 93 metro 5000; -#X obj 29 52 loadbang; -#X msg 29 70 1; -#X obj 84 161 pack 1 5000; -#X obj 84 180 line; -#X obj 86 31 inlet start/stop; -#X obj 130 53 inlet time; -#X connect 1 0 7 0; -#X connect 2 0 1 0; -#X connect 3 0 4 0; -#X connect 3 0 7 1; -#X connect 4 0 1 0; -#X connect 5 0 6 0; -#X connect 6 0 4 0; -#X connect 7 0 8 0; -#X connect 8 0 0 0; -#X connect 9 0 4 0; -#X connect 10 0 3 0; -#X restore 169 154 page modulate; -#X floatatom 262 132; -#X obj 262 179 min 127; -#X obj 262 154 max 33; -#X obj 157 77 f; -#X obj 210 78 f; -#X text 200 178 <== here; -#X text 297 131 <== and here; -#X connect 0 0 8 0; -#X connect 1 0 8 2; -#X connect 2 0 18 0; -#X connect 3 0 6 0; -#X connect 4 0 5 0; -#X connect 5 0 8 1; -#X connect 6 0 17 0; -#X connect 7 0 17 0; -#X connect 8 0 12 0; -#X connect 9 0 8 0; -#X connect 10 0 8 0; -#X connect 12 0 11 0; -#X connect 13 0 8 2; -#X connect 14 0 16 0; -#X connect 15 0 8 3; -#X connect 16 0 15 0; -#X connect 17 0 4 0; -#X connect 17 0 13 0; -#X connect 18 0 4 1; -#X connect 18 0 13 1; diff --git a/reference/bfilt-help.pd b/reference/bfilt-help.pd new file mode 100644 index 0000000..4be9d45 --- /dev/null +++ b/reference/bfilt-help.pd @@ -0,0 +1,23 @@ +#N canvas 203 207 404 226 10; +#X floatatom 85 119; +#X obj 57 175 print; +#X floatatom 45 120; +#X obj 58 146 bfilt 5; +#X text 43 16 bfilt (at the moment) is: modulo something + select 0; +#X floatatom 167 120; +#X obj 139 176 print; +#X floatatom 127 121; +#X obj 140 147 bfilt2 5; +#X obj 145 87 metro 100; +#X msg 145 68 1; +#X text 42 29 bfilt2: real bangfilter: bangs on first inlet \, internal counter \, only outputs every arg2th bang ...; +#X msg 169 67 0; +#X connect 0 0 3 1; +#X connect 2 0 3 0; +#X connect 3 0 1 0; +#X connect 5 0 8 1; +#X connect 7 0 8 0; +#X connect 8 0 6 0; +#X connect 9 0 8 0; +#X connect 10 0 9 0; +#X connect 12 0 9 0; diff --git a/reference/bfilt.pd b/reference/bfilt.pd deleted file mode 100644 index 4be9d45..0000000 --- a/reference/bfilt.pd +++ /dev/null @@ -1,23 +0,0 @@ -#N canvas 203 207 404 226 10; -#X floatatom 85 119; -#X obj 57 175 print; -#X floatatom 45 120; -#X obj 58 146 bfilt 5; -#X text 43 16 bfilt (at the moment) is: modulo something + select 0; -#X floatatom 167 120; -#X obj 139 176 print; -#X floatatom 127 121; -#X obj 140 147 bfilt2 5; -#X obj 145 87 metro 100; -#X msg 145 68 1; -#X text 42 29 bfilt2: real bangfilter: bangs on first inlet \, internal counter \, only outputs every arg2th bang ...; -#X msg 169 67 0; -#X connect 0 0 3 1; -#X connect 2 0 3 0; -#X connect 3 0 1 0; -#X connect 5 0 8 1; -#X connect 7 0 8 0; -#X connect 8 0 6 0; -#X connect 9 0 8 0; -#X connect 10 0 9 0; -#X connect 12 0 9 0; diff --git a/reference/bfilt2-help.pd b/reference/bfilt2-help.pd new file mode 100644 index 0000000..4be9d45 --- /dev/null +++ b/reference/bfilt2-help.pd @@ -0,0 +1,23 @@ +#N canvas 203 207 404 226 10; +#X floatatom 85 119; +#X obj 57 175 print; +#X floatatom 45 120; +#X obj 58 146 bfilt 5; +#X text 43 16 bfilt (at the moment) is: modulo something + select 0; +#X floatatom 167 120; +#X obj 139 176 print; +#X floatatom 127 121; +#X obj 140 147 bfilt2 5; +#X obj 145 87 metro 100; +#X msg 145 68 1; +#X text 42 29 bfilt2: real bangfilter: bangs on first inlet \, internal counter \, only outputs every arg2th bang ...; +#X msg 169 67 0; +#X connect 0 0 3 1; +#X connect 2 0 3 0; +#X connect 3 0 1 0; +#X connect 5 0 8 1; +#X connect 7 0 8 0; +#X connect 8 0 6 0; +#X connect 9 0 8 0; +#X connect 10 0 9 0; +#X connect 12 0 9 0; diff --git a/reference/delta.pd b/reference/delta.pd deleted file mode 100644 index 7f0bf8b..0000000 --- a/reference/delta.pd +++ /dev/null @@ -1,63 +0,0 @@ -#N canvas 9 51 986 579 10; -#X obj 139 177 delta~; -#X obj 80 44 noise~; -#X obj 83 268 print a; -#X obj 143 267 print b; -#X obj 329 312 dac~; -#X obj 226 47 osc~ 400; -#X graph graph1 0 -1 999 1 497 206 697 66; -#X array orig 1000 float 0; -#X pop; -#X graph graph2 0 -1 999 1 431 563 931 203; -#X array diff 1000 float 0; -#X pop; -#X obj 129 390 tabwrite~ diff; -#X msg 220 340 bang; -#X floatatom 225 24 5 0 0; -#X obj 139 468 table test; -#X msg 139 442 resize 2205; -#X obj 242 389 tabwrite~ test; -#X obj 243 415 tabwrite~ orig; -#X obj 403 515 print; -#X msg 350 441 bang; -#X obj 346 530 t b; -#X obj 332 552 spigot; -#X obj 375 528 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 -1; -#X obj 320 474 tabread~ test; -#X obj 201 532 phasor~ 10; -#X floatatom 201 510 5 0 0; -#X obj 201 556 *~ 2205; -#X obj 147 45 phasor~ 1; -#X obj 160 93 nop~; -#X obj 287 224 metro 100; -#X obj 287 198 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 -1; -#X floatatom 173 18 5 0 0; -#X obj 109 77 *~ 0.1; -#X floatatom 86 103 5 0 0; -#X text 308 36 if this sample is larger than last \, value is positive -\, else negative ...; -#X text 308 18 delta~: difference between this and last sample; -#X connect 0 0 4 1; -#X connect 0 0 8 0; -#X connect 1 0 29 0; -#X connect 9 0 8 0; -#X connect 9 0 13 0; -#X connect 9 0 14 0; -#X connect 10 0 5 0; -#X connect 12 0 11 0; -#X connect 17 0 18 0; -#X connect 19 0 18 1; -#X connect 21 0 23 0; -#X connect 22 0 21 0; -#X connect 23 0 20 0; -#X connect 24 0 25 0; -#X connect 25 0 0 0; -#X connect 25 0 13 0; -#X connect 25 0 14 0; -#X connect 26 0 9 0; -#X connect 27 0 26 0; -#X connect 28 0 24 0; -#X connect 29 0 25 0; -#X connect 30 0 29 1; diff --git a/reference/delta~-help.pd b/reference/delta~-help.pd new file mode 100644 index 0000000..7f0bf8b --- /dev/null +++ b/reference/delta~-help.pd @@ -0,0 +1,63 @@ +#N canvas 9 51 986 579 10; +#X obj 139 177 delta~; +#X obj 80 44 noise~; +#X obj 83 268 print a; +#X obj 143 267 print b; +#X obj 329 312 dac~; +#X obj 226 47 osc~ 400; +#X graph graph1 0 -1 999 1 497 206 697 66; +#X array orig 1000 float 0; +#X pop; +#X graph graph2 0 -1 999 1 431 563 931 203; +#X array diff 1000 float 0; +#X pop; +#X obj 129 390 tabwrite~ diff; +#X msg 220 340 bang; +#X floatatom 225 24 5 0 0; +#X obj 139 468 table test; +#X msg 139 442 resize 2205; +#X obj 242 389 tabwrite~ test; +#X obj 243 415 tabwrite~ orig; +#X obj 403 515 print; +#X msg 350 441 bang; +#X obj 346 530 t b; +#X obj 332 552 spigot; +#X obj 375 528 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 +1; +#X obj 320 474 tabread~ test; +#X obj 201 532 phasor~ 10; +#X floatatom 201 510 5 0 0; +#X obj 201 556 *~ 2205; +#X obj 147 45 phasor~ 1; +#X obj 160 93 nop~; +#X obj 287 224 metro 100; +#X obj 287 198 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 +1; +#X floatatom 173 18 5 0 0; +#X obj 109 77 *~ 0.1; +#X floatatom 86 103 5 0 0; +#X text 308 36 if this sample is larger than last \, value is positive +\, else negative ...; +#X text 308 18 delta~: difference between this and last sample; +#X connect 0 0 4 1; +#X connect 0 0 8 0; +#X connect 1 0 29 0; +#X connect 9 0 8 0; +#X connect 9 0 13 0; +#X connect 9 0 14 0; +#X connect 10 0 5 0; +#X connect 12 0 11 0; +#X connect 17 0 18 0; +#X connect 19 0 18 1; +#X connect 21 0 23 0; +#X connect 22 0 21 0; +#X connect 23 0 20 0; +#X connect 24 0 25 0; +#X connect 25 0 0 0; +#X connect 25 0 13 0; +#X connect 25 0 14 0; +#X connect 26 0 9 0; +#X connect 27 0 26 0; +#X connect 28 0 24 0; +#X connect 29 0 25 0; +#X connect 30 0 29 1; diff --git a/reference/proc-help.pd b/reference/proc-help.pd new file mode 100644 index 0000000..65411ae --- /dev/null +++ b/reference/proc-help.pd @@ -0,0 +1,75 @@ +#N canvas 179 113 717 546 10; +#X obj 151 118 proc; +#X text 96 15 interface to the linux proc filesystem; +#X msg 88 80 cpuinfo; +#X obj 27 281 unpack f f f; +#X floatatom 25 304 5 0 0; +#X floatatom 67 305 5 0 0; +#X floatatom 109 304 5 0 0; +#X text 37 254 cpu-id \, cpu-mhz \, bogomips; +#X obj 151 147 print proc_raw; +#X msg 151 94 proc \$1; +#X obj 151 71 symbol; +#X msg 123 38 cpuinfo; +#X msg 183 38 uptime; +#X msg 351 38 stat; +#X msg 389 38 blubb; +#X obj 242 276 unpack f f; +#X text 241 255 uptime in s \, idle-time in s; +#X floatatom 241 301 5 0 0; +#X floatatom 302 305 5 0 0; +#X msg 237 38 loadavg; +#X msg 297 39 version; +#X obj 174 349 unpack f f f f f f; +#X floatatom 172 373 5 0 0; +#X floatatom 187 397 5 0 0; +#X floatatom 220 373 5 0 0; +#X floatatom 238 397 5 0 0; +#X floatatom 271 372 5 0 0; +#X floatatom 289 396 5 0 0; +#X text 315 345 apparently the loadavg format is something liek this +; +#X text 318 359 my manpage seems outdated ...; +#X text 330 379 1: number of jobs in the run queue (1'); +#X text 340 394 2: numofjobs in R qu (5'); +#X text 348 411 3: numofjobs in R qu (15'); +#X text 339 425 4: num of procs waiting for disk io?; +#X text 339 452 6: num of processes ever total; +#X text 339 438 5: num of processes now total; +#X obj 27 234 route cpuinfo uptime loadavg version stat; +#X obj 458 241 unpack f f f; +#X floatatom 458 267 5 0 0; +#X floatatom 484 293 5 0 0; +#X floatatom 516 266 5 0 0; +#X text 462 215 uname -r; +#X text 307 82 really useless stuff but maybe good for estimating number +of voices in self-generating patches; +#X connect 0 0 8 0; +#X connect 0 0 36 0; +#X connect 2 0 0 0; +#X connect 3 0 4 0; +#X connect 3 1 5 0; +#X connect 3 2 6 0; +#X connect 9 0 0 0; +#X connect 10 0 9 0; +#X connect 11 0 10 0; +#X connect 12 0 10 0; +#X connect 13 0 10 0; +#X connect 14 0 10 0; +#X connect 15 0 17 0; +#X connect 15 1 18 0; +#X connect 19 0 10 0; +#X connect 20 0 10 0; +#X connect 21 0 22 0; +#X connect 21 1 23 0; +#X connect 21 2 24 0; +#X connect 21 3 25 0; +#X connect 21 4 26 0; +#X connect 21 5 27 0; +#X connect 36 0 3 0; +#X connect 36 1 15 0; +#X connect 36 2 21 0; +#X connect 36 3 37 0; +#X connect 37 0 38 0; +#X connect 37 1 39 0; +#X connect 37 2 40 0; diff --git a/reference/proc.pd b/reference/proc.pd deleted file mode 100644 index 65411ae..0000000 --- a/reference/proc.pd +++ /dev/null @@ -1,75 +0,0 @@ -#N canvas 179 113 717 546 10; -#X obj 151 118 proc; -#X text 96 15 interface to the linux proc filesystem; -#X msg 88 80 cpuinfo; -#X obj 27 281 unpack f f f; -#X floatatom 25 304 5 0 0; -#X floatatom 67 305 5 0 0; -#X floatatom 109 304 5 0 0; -#X text 37 254 cpu-id \, cpu-mhz \, bogomips; -#X obj 151 147 print proc_raw; -#X msg 151 94 proc \$1; -#X obj 151 71 symbol; -#X msg 123 38 cpuinfo; -#X msg 183 38 uptime; -#X msg 351 38 stat; -#X msg 389 38 blubb; -#X obj 242 276 unpack f f; -#X text 241 255 uptime in s \, idle-time in s; -#X floatatom 241 301 5 0 0; -#X floatatom 302 305 5 0 0; -#X msg 237 38 loadavg; -#X msg 297 39 version; -#X obj 174 349 unpack f f f f f f; -#X floatatom 172 373 5 0 0; -#X floatatom 187 397 5 0 0; -#X floatatom 220 373 5 0 0; -#X floatatom 238 397 5 0 0; -#X floatatom 271 372 5 0 0; -#X floatatom 289 396 5 0 0; -#X text 315 345 apparently the loadavg format is something liek this -; -#X text 318 359 my manpage seems outdated ...; -#X text 330 379 1: number of jobs in the run queue (1'); -#X text 340 394 2: numofjobs in R qu (5'); -#X text 348 411 3: numofjobs in R qu (15'); -#X text 339 425 4: num of procs waiting for disk io?; -#X text 339 452 6: num of processes ever total; -#X text 339 438 5: num of processes now total; -#X obj 27 234 route cpuinfo uptime loadavg version stat; -#X obj 458 241 unpack f f f; -#X floatatom 458 267 5 0 0; -#X floatatom 484 293 5 0 0; -#X floatatom 516 266 5 0 0; -#X text 462 215 uname -r; -#X text 307 82 really useless stuff but maybe good for estimating number -of voices in self-generating patches; -#X connect 0 0 8 0; -#X connect 0 0 36 0; -#X connect 2 0 0 0; -#X connect 3 0 4 0; -#X connect 3 1 5 0; -#X connect 3 2 6 0; -#X connect 9 0 0 0; -#X connect 10 0 9 0; -#X connect 11 0 10 0; -#X connect 12 0 10 0; -#X connect 13 0 10 0; -#X connect 14 0 10 0; -#X connect 15 0 17 0; -#X connect 15 1 18 0; -#X connect 19 0 10 0; -#X connect 20 0 10 0; -#X connect 21 0 22 0; -#X connect 21 1 23 0; -#X connect 21 2 24 0; -#X connect 21 3 25 0; -#X connect 21 4 26 0; -#X connect 21 5 27 0; -#X connect 36 0 3 0; -#X connect 36 1 15 0; -#X connect 36 2 21 0; -#X connect 36 3 37 0; -#X connect 37 0 38 0; -#X connect 37 1 39 0; -#X connect 37 2 40 0; diff --git a/reference/randomix-help.pd b/reference/randomix-help.pd new file mode 100644 index 0000000..d913f39 --- /dev/null +++ b/reference/randomix-help.pd @@ -0,0 +1,223 @@ +#N canvas 33 162 966 505 10; +#X msg 197 150 bang; +#X floatatom 244 150 5 0 0 0 - - -; +#X floatatom 197 218 10 0 0 0 - - -; +#X floatatom 53 162 5 0 0 0 - - -; +#X msg 54 111 bang; +#X floatatom 289 152 5 0 0 0 - - -; +#X obj 53 135 random 100; +#X msg 427 151 bang; +#X floatatom 474 151 5 0 0 0 - - -; +#X floatatom 427 219 10 0 0 0 - - -; +#X floatatom 519 153 5 0 0 0 - - -; +#X obj 196 183 random1 0 1; +#X obj 426 184 random_fl 0 1; +#X msg 672 152 bang; +#X floatatom 719 152 5 0 0 0 - - -; +#X floatatom 672 220 10 0 0 0 - - -; +#X floatatom 764 154 5 0 0 0 - - -; +#X obj 671 185 random_icg 0 1; +#X msg 197 276 bang; +#X floatatom 244 276 5 0 0 0 - - -; +#X floatatom 197 344 10 0 0 0 - - -; +#X floatatom 289 278 5 0 0 0 - - -; +#X text 193 251 random_icg lowerlimit \, upperlimit; +#X msg 368 288 help; +#X text 253 10 the random number generatorse; +#X obj 539 406 dist_normal; +#X msg 540 356 bang; +#X obj 579 357 metro 100; +#X obj 579 337 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 +1; +#X obj 196 309 random_tw 0 1; +#X floatatom 637 334 5 0 0 0 - - -; +#N canvas 0 0 600 400 streamview 0; +#N canvas 0 0 450 300 graph2 0; +#X array randstream 100 float 0; +#X coords 0 2 99 -2 200 140 1; +#X restore 92 222 graph; +#X obj 146 144 tabwrite randstream; +#X obj 200 63 count; +#X obj 200 88 % 100; +#X obj 156 28 t f b; +#X obj 49 15 inlet; +#X connect 2 0 3 0; +#X connect 3 0 1 1; +#X connect 4 0 1 0; +#X connect 4 1 2 0; +#X connect 5 0 4 0; +#X restore 570 433 pd streamview; +#N canvas 306 24 679 400 distview 0; +#N canvas 0 0 450 300 graph1 0; +#X array randview1 100 float 0; +#X coords 0 200 99 0 400 200 1; +#X restore 248 31 graph; +#X obj 28 26 inlet; +#X obj 45 355 tabwrite randview1; +#X obj 136 201 * 100; +#X obj 136 225 int; +#X obj 136 153 + 2; +#X obj 45 280 tabread randview1; +#X obj 136 176 / 4; +#X obj 136 250 t f f; +#X obj 45 304 t f b; +#X obj 45 329 + 1; +#X obj 136 129 t f; +#X connect 1 0 11 0; +#X connect 3 0 4 0; +#X connect 4 0 8 0; +#X connect 5 0 7 0; +#X connect 6 0 9 0; +#X connect 7 0 3 0; +#X connect 8 0 6 0; +#X connect 8 1 2 1; +#X connect 9 0 10 0; +#X connect 10 0 2 0; +#X connect 11 0 5 0; +#X restore 550 458 pd distview; +#X obj 540 381 t b; +#X floatatom 477 430 5 0 0 0 - - -; +#N canvas 0 0 600 400 seedit 0; +#X msg 284 154 seed \$1; +#X obj 284 107 utime; +#X msg 304 74 bang; +#X obj 254 28 loadbang; +#X obj 284 130 * 1e+06; +#X obj 360 167 until; +#X msg 455 156 bang; +#X obj 359 194 random 2.14748e+08; +#X msg 359 267 seed \$1; +#X msg 385 294 seed \$1; +#X msg 412 318 seed \$1; +#X msg 439 267 seed \$1; +#X msg 466 293 seed \$1; +#X obj 254 50 t b b; +#X obj 195 155 print seed1; +#X obj 143 360 outlet; +#X obj 204 361 outlet; +#X obj 264 361 outlet; +#X obj 317 361 outlet; +#X obj 367 361 outlet; +#X text 35 9 seed one random obj \, which generates the seeds for all +the others.; +#X obj 359 218 serialize 6; +#X msg 360 140 6; +#X obj 359 242 unpack f f f f f f; +#X msg 485 317 seed \$1; +#X obj 420 359 outlet; +#X connect 0 0 7 0; +#X connect 1 1 4 0; +#X connect 2 0 1 0; +#X connect 3 0 13 0; +#X connect 4 0 0 0; +#X connect 4 0 14 0; +#X connect 5 0 7 0; +#X connect 6 0 7 0; +#X connect 7 0 21 0; +#X connect 8 0 15 0; +#X connect 9 0 16 0; +#X connect 10 0 17 0; +#X connect 11 0 18 0; +#X connect 12 0 19 0; +#X connect 13 0 22 0; +#X connect 13 1 1 0; +#X connect 21 0 23 0; +#X connect 22 0 5 0; +#X connect 23 0 8 0; +#X connect 23 1 9 0; +#X connect 23 2 10 0; +#X connect 23 3 11 0; +#X connect 23 4 12 0; +#X connect 23 5 24 0; +#X connect 24 0 25 0; +#X restore 258 33 pd seedit; +#X text 37 79 std pd random; +#X text 197 124 linear congruential generator; +#X text 197 77 creation arguments for the extra randoms are:; +#X text 205 92 \, defaults to 0 respectively +RAND_MAX; +#X text 545 17 see also:; +#X obj 545 40 utime; +#X text 428 129 another lcg method ..; +#X text 668 127 inverse linear congruential generator; +#X text 536 249 normal distribution mean 0 and dist 1; +#X text 536 264 right now it uses random1 for the actual rand values +; +#X text 537 278 but later on it should take one of the randoms as creation +argument \, so yu can specify which generator is being used.; +#X text 198 106 they all output floats); +#X text 540 311 also \, there is some burst at the upper and lower +limits; +#N canvas 622 685 592 356 signalversions 1; +#X obj 68 131 random1~; +#X obj 368 239 tabwrite~ randomix_test; +#N canvas 0 0 450 300 graph1 0; +#X array randomix_test 64 float 1; +#A 0 -0.599965 0.178987 -0.501604 -1.10592 0.426163 -0.481499 -0.553236 +0.0961931 0.554738 -0.695487 0.541875 -0.415309 -0.419922 -0.871908 +0.0688377 -1.03721 -0.136159 -0.207339 -1.18947 -0.25981 -0.628915 +-0.826873 0.334755 -0.738558 -0.0926691 -0.262739 0.309148 0.50131 +-1.40461 -0.859907 0.621724 -0.888718 0.692579 -1.11799 0.162897 0.116501 +-0.390333 0.327364 -0.902445 -0.201419 0.300071 -1.10817 -1.09973 0.34181 +-0.0511739 -0.613584 -0.306316 0.433381 -0.154481 -1.17821 -0.428187 +-0.449014 -1.04248 -0.906665 0.0687456 -1.08289 0.59097 0.0438875 -1.20429 +0.0862183 -0.995607 0.585034 0.205198 -0.337256; +#X coords 0 1 63 -1 200 140 1; +#X restore 351 23 graph; +#X obj 382 183 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 +1; +#X floatatom 440 184 5 0 0 0 - - -; +#X obj 382 201 metro 100; +#X msg 342 201 bang; +#X obj 73 295 dac~; +#X floatatom 140 220 5 0 0 0 - - -; +#X msg 68 58 seed 30000; +#X obj 142 131 random_fl~; +#X text 120 98 etc ..; +#X obj 229 131 random_icg~; +#X obj 81 241 fader 75; +#X connect 0 0 13 0; +#X connect 3 0 5 0; +#X connect 4 0 5 1; +#X connect 5 0 1 0; +#X connect 6 0 1 0; +#X connect 8 0 13 2; +#X connect 9 0 0 0; +#X connect 10 0 13 1; +#X connect 12 0 1 0; +#X connect 12 0 13 0; +#X connect 13 0 7 0; +#X connect 13 1 7 1; +#X restore 98 421 pd signalversions; +#X connect 0 0 11 0; +#X connect 1 0 11 1; +#X connect 4 0 6 0; +#X connect 5 0 11 2; +#X connect 6 0 3 0; +#X connect 7 0 12 0; +#X connect 8 0 12 1; +#X connect 10 0 12 2; +#X connect 11 0 2 0; +#X connect 12 0 9 0; +#X connect 13 0 17 0; +#X connect 14 0 17 1; +#X connect 16 0 17 2; +#X connect 17 0 15 0; +#X connect 18 0 29 0; +#X connect 19 0 29 1; +#X connect 21 0 29 2; +#X connect 23 0 29 0; +#X connect 25 0 31 0; +#X connect 25 0 32 0; +#X connect 25 0 34 0; +#X connect 26 0 33 0; +#X connect 27 0 33 0; +#X connect 28 0 27 0; +#X connect 29 0 20 0; +#X connect 30 0 27 1; +#X connect 33 0 25 0; +#X connect 35 0 6 0; +#X connect 35 1 11 0; +#X connect 35 2 12 0; +#X connect 35 3 17 0; +#X connect 35 4 29 0; diff --git a/reference/randomix.pd b/reference/randomix.pd deleted file mode 100644 index d913f39..0000000 --- a/reference/randomix.pd +++ /dev/null @@ -1,223 +0,0 @@ -#N canvas 33 162 966 505 10; -#X msg 197 150 bang; -#X floatatom 244 150 5 0 0 0 - - -; -#X floatatom 197 218 10 0 0 0 - - -; -#X floatatom 53 162 5 0 0 0 - - -; -#X msg 54 111 bang; -#X floatatom 289 152 5 0 0 0 - - -; -#X obj 53 135 random 100; -#X msg 427 151 bang; -#X floatatom 474 151 5 0 0 0 - - -; -#X floatatom 427 219 10 0 0 0 - - -; -#X floatatom 519 153 5 0 0 0 - - -; -#X obj 196 183 random1 0 1; -#X obj 426 184 random_fl 0 1; -#X msg 672 152 bang; -#X floatatom 719 152 5 0 0 0 - - -; -#X floatatom 672 220 10 0 0 0 - - -; -#X floatatom 764 154 5 0 0 0 - - -; -#X obj 671 185 random_icg 0 1; -#X msg 197 276 bang; -#X floatatom 244 276 5 0 0 0 - - -; -#X floatatom 197 344 10 0 0 0 - - -; -#X floatatom 289 278 5 0 0 0 - - -; -#X text 193 251 random_icg lowerlimit \, upperlimit; -#X msg 368 288 help; -#X text 253 10 the random number generatorse; -#X obj 539 406 dist_normal; -#X msg 540 356 bang; -#X obj 579 357 metro 100; -#X obj 579 337 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 -1; -#X obj 196 309 random_tw 0 1; -#X floatatom 637 334 5 0 0 0 - - -; -#N canvas 0 0 600 400 streamview 0; -#N canvas 0 0 450 300 graph2 0; -#X array randstream 100 float 0; -#X coords 0 2 99 -2 200 140 1; -#X restore 92 222 graph; -#X obj 146 144 tabwrite randstream; -#X obj 200 63 count; -#X obj 200 88 % 100; -#X obj 156 28 t f b; -#X obj 49 15 inlet; -#X connect 2 0 3 0; -#X connect 3 0 1 1; -#X connect 4 0 1 0; -#X connect 4 1 2 0; -#X connect 5 0 4 0; -#X restore 570 433 pd streamview; -#N canvas 306 24 679 400 distview 0; -#N canvas 0 0 450 300 graph1 0; -#X array randview1 100 float 0; -#X coords 0 200 99 0 400 200 1; -#X restore 248 31 graph; -#X obj 28 26 inlet; -#X obj 45 355 tabwrite randview1; -#X obj 136 201 * 100; -#X obj 136 225 int; -#X obj 136 153 + 2; -#X obj 45 280 tabread randview1; -#X obj 136 176 / 4; -#X obj 136 250 t f f; -#X obj 45 304 t f b; -#X obj 45 329 + 1; -#X obj 136 129 t f; -#X connect 1 0 11 0; -#X connect 3 0 4 0; -#X connect 4 0 8 0; -#X connect 5 0 7 0; -#X connect 6 0 9 0; -#X connect 7 0 3 0; -#X connect 8 0 6 0; -#X connect 8 1 2 1; -#X connect 9 0 10 0; -#X connect 10 0 2 0; -#X connect 11 0 5 0; -#X restore 550 458 pd distview; -#X obj 540 381 t b; -#X floatatom 477 430 5 0 0 0 - - -; -#N canvas 0 0 600 400 seedit 0; -#X msg 284 154 seed \$1; -#X obj 284 107 utime; -#X msg 304 74 bang; -#X obj 254 28 loadbang; -#X obj 284 130 * 1e+06; -#X obj 360 167 until; -#X msg 455 156 bang; -#X obj 359 194 random 2.14748e+08; -#X msg 359 267 seed \$1; -#X msg 385 294 seed \$1; -#X msg 412 318 seed \$1; -#X msg 439 267 seed \$1; -#X msg 466 293 seed \$1; -#X obj 254 50 t b b; -#X obj 195 155 print seed1; -#X obj 143 360 outlet; -#X obj 204 361 outlet; -#X obj 264 361 outlet; -#X obj 317 361 outlet; -#X obj 367 361 outlet; -#X text 35 9 seed one random obj \, which generates the seeds for all -the others.; -#X obj 359 218 serialize 6; -#X msg 360 140 6; -#X obj 359 242 unpack f f f f f f; -#X msg 485 317 seed \$1; -#X obj 420 359 outlet; -#X connect 0 0 7 0; -#X connect 1 1 4 0; -#X connect 2 0 1 0; -#X connect 3 0 13 0; -#X connect 4 0 0 0; -#X connect 4 0 14 0; -#X connect 5 0 7 0; -#X connect 6 0 7 0; -#X connect 7 0 21 0; -#X connect 8 0 15 0; -#X connect 9 0 16 0; -#X connect 10 0 17 0; -#X connect 11 0 18 0; -#X connect 12 0 19 0; -#X connect 13 0 22 0; -#X connect 13 1 1 0; -#X connect 21 0 23 0; -#X connect 22 0 5 0; -#X connect 23 0 8 0; -#X connect 23 1 9 0; -#X connect 23 2 10 0; -#X connect 23 3 11 0; -#X connect 23 4 12 0; -#X connect 23 5 24 0; -#X connect 24 0 25 0; -#X restore 258 33 pd seedit; -#X text 37 79 std pd random; -#X text 197 124 linear congruential generator; -#X text 197 77 creation arguments for the extra randoms are:; -#X text 205 92 \, defaults to 0 respectively -RAND_MAX; -#X text 545 17 see also:; -#X obj 545 40 utime; -#X text 428 129 another lcg method ..; -#X text 668 127 inverse linear congruential generator; -#X text 536 249 normal distribution mean 0 and dist 1; -#X text 536 264 right now it uses random1 for the actual rand values -; -#X text 537 278 but later on it should take one of the randoms as creation -argument \, so yu can specify which generator is being used.; -#X text 198 106 they all output floats); -#X text 540 311 also \, there is some burst at the upper and lower -limits; -#N canvas 622 685 592 356 signalversions 1; -#X obj 68 131 random1~; -#X obj 368 239 tabwrite~ randomix_test; -#N canvas 0 0 450 300 graph1 0; -#X array randomix_test 64 float 1; -#A 0 -0.599965 0.178987 -0.501604 -1.10592 0.426163 -0.481499 -0.553236 -0.0961931 0.554738 -0.695487 0.541875 -0.415309 -0.419922 -0.871908 -0.0688377 -1.03721 -0.136159 -0.207339 -1.18947 -0.25981 -0.628915 --0.826873 0.334755 -0.738558 -0.0926691 -0.262739 0.309148 0.50131 --1.40461 -0.859907 0.621724 -0.888718 0.692579 -1.11799 0.162897 0.116501 --0.390333 0.327364 -0.902445 -0.201419 0.300071 -1.10817 -1.09973 0.34181 --0.0511739 -0.613584 -0.306316 0.433381 -0.154481 -1.17821 -0.428187 --0.449014 -1.04248 -0.906665 0.0687456 -1.08289 0.59097 0.0438875 -1.20429 -0.0862183 -0.995607 0.585034 0.205198 -0.337256; -#X coords 0 1 63 -1 200 140 1; -#X restore 351 23 graph; -#X obj 382 183 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 -1; -#X floatatom 440 184 5 0 0 0 - - -; -#X obj 382 201 metro 100; -#X msg 342 201 bang; -#X obj 73 295 dac~; -#X floatatom 140 220 5 0 0 0 - - -; -#X msg 68 58 seed 30000; -#X obj 142 131 random_fl~; -#X text 120 98 etc ..; -#X obj 229 131 random_icg~; -#X obj 81 241 fader 75; -#X connect 0 0 13 0; -#X connect 3 0 5 0; -#X connect 4 0 5 1; -#X connect 5 0 1 0; -#X connect 6 0 1 0; -#X connect 8 0 13 2; -#X connect 9 0 0 0; -#X connect 10 0 13 1; -#X connect 12 0 1 0; -#X connect 12 0 13 0; -#X connect 13 0 7 0; -#X connect 13 1 7 1; -#X restore 98 421 pd signalversions; -#X connect 0 0 11 0; -#X connect 1 0 11 1; -#X connect 4 0 6 0; -#X connect 5 0 11 2; -#X connect 6 0 3 0; -#X connect 7 0 12 0; -#X connect 8 0 12 1; -#X connect 10 0 12 2; -#X connect 11 0 2 0; -#X connect 12 0 9 0; -#X connect 13 0 17 0; -#X connect 14 0 17 1; -#X connect 16 0 17 2; -#X connect 17 0 15 0; -#X connect 18 0 29 0; -#X connect 19 0 29 1; -#X connect 21 0 29 2; -#X connect 23 0 29 0; -#X connect 25 0 31 0; -#X connect 25 0 32 0; -#X connect 25 0 34 0; -#X connect 26 0 33 0; -#X connect 27 0 33 0; -#X connect 28 0 27 0; -#X connect 29 0 20 0; -#X connect 30 0 27 1; -#X connect 33 0 25 0; -#X connect 35 0 6 0; -#X connect 35 1 11 0; -#X connect 35 2 12 0; -#X connect 35 3 17 0; -#X connect 35 4 29 0; diff --git a/reference/reson~-help.pd b/reference/reson~-help.pd new file mode 100644 index 0000000..d90c159 --- /dev/null +++ b/reference/reson~-help.pd @@ -0,0 +1,3 @@ +#N canvas 0 22 454 304 10; +#X obj 183 119 reson~; +#X text 104 237 An interpolating reson filter; diff --git a/reference/reson~.pd b/reference/reson~.pd deleted file mode 100644 index d90c159..0000000 --- a/reference/reson~.pd +++ /dev/null @@ -1,3 +0,0 @@ -#N canvas 0 22 454 304 10; -#X obj 183 119 reson~; -#X text 104 237 An interpolating reson filter; diff --git a/reference/serialize-help.pd b/reference/serialize-help.pd new file mode 100644 index 0000000..b9d8469 --- /dev/null +++ b/reference/serialize-help.pd @@ -0,0 +1,10 @@ +#N canvas 246 82 551 292 10; +#X obj 34 141 print; +#X floatatom 34 69 0 0 0; +#X text 30 195 (C) 2000 Guenter Geiger; +#X text 30 39 serialize ... turn a stream of floats into a list; +#X obj 33 107 serialize 4; +#X floatatom 105 82 5 0 0; +#X connect 1 0 4 0; +#X connect 4 0 0 0; +#X connect 5 0 4 1; diff --git a/reference/serialize.pd b/reference/serialize.pd deleted file mode 100644 index b9d8469..0000000 --- a/reference/serialize.pd +++ /dev/null @@ -1,10 +0,0 @@ -#N canvas 246 82 551 292 10; -#X obj 34 141 print; -#X floatatom 34 69 0 0 0; -#X text 30 195 (C) 2000 Guenter Geiger; -#X text 30 39 serialize ... turn a stream of floats into a list; -#X obj 33 107 serialize 4; -#X floatatom 105 82 5 0 0; -#X connect 1 0 4 0; -#X connect 4 0 0 0; -#X connect 5 0 4 1; diff --git a/reference/utime-help.pd b/reference/utime-help.pd new file mode 100644 index 0000000..aa5af83 --- /dev/null +++ b/reference/utime-help.pd @@ -0,0 +1,9 @@ +#N canvas 305 149 450 300 10; +#X obj 199 94 utime; +#X msg 192 55 bang; +#X floatatom 259 170 8 0 0; +#X floatatom 174 129 20 0 0; +#X text 25 8 output seconds since epoch and microsecond fraction; +#X connect 0 0 3 0; +#X connect 0 1 2 0; +#X connect 1 0 0 0; diff --git a/reference/utime.pd b/reference/utime.pd deleted file mode 100644 index aa5af83..0000000 --- a/reference/utime.pd +++ /dev/null @@ -1,9 +0,0 @@ -#N canvas 305 149 450 300 10; -#X obj 199 94 utime; -#X msg 192 55 bang; -#X floatatom 259 170 8 0 0; -#X floatatom 174 129 20 0 0; -#X text 25 8 output seconds since epoch and microsecond fraction; -#X connect 0 0 3 0; -#X connect 0 1 2 0; -#X connect 1 0 0 0; diff --git a/reson.c b/reson.c deleted file mode 100644 index a7ba2b0..0000000 --- a/reson.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 1997-1999 Mark Danks. - * For information on usage and redistribution, and for a DISCLAIMER OF ALL - * WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. - */ - -/* Original code by Miller Puckette */ -/* a non-interpolating reson filter, not very carefully coded... */ -/* 11/29/94 modified to do interpolation - M. Danks */ - -#include "m_pd.h" - -#include - -#define BUFSIZE 4096 - -typedef struct resonctl -{ - float c_freq; - float c_samprate; - float c_feedback; - int c_delayinsamps; - float c_fraction; - int c_phase; - float *c_buf; -} t_resonctl; - -typedef struct sigreson -{ - t_object x_obj; /* header */ - t_resonctl *x_ctl; /* pointer to state */ - t_resonctl x_cspace; /* garage for state when not in a chain */ -} t_sigreson; - -/* the DSP routine -- called for every n samples of input */ -static t_int *cu_reson(t_int *w) -{ - t_float *in1 = (t_float *)(w[1]); - t_float *in2 = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - t_resonctl *x = (t_resonctl *)(w[4]); - int n = (int)(w[5]); - long i; - int writephase = x->c_phase; - for (i = 0; i < n; i++) - { - /* note two tricks: 1. input is read before output - * is written, because the routine might be called - * in-place; - * 2 - a seed of 1E-20 is thrown in to avoid floating - * underflow which slows the calculation down. - */ - int readphase, phase, delayinsamps; - float fraction, f, g, freq, freqtemp; - - float ftemp; - - freq = *in2++; - freqtemp = (freq < 1 ? 1 : freq); - - ftemp = x->c_samprate/freqtemp; - if (ftemp >= BUFSIZE-1) - ftemp = BUFSIZE - 1.f; - else if (ftemp < 1.0) - ftemp = 1.f; - delayinsamps = (int)ftemp; - fraction = ftemp - delayinsamps; - - readphase = writephase - delayinsamps; - phase = readphase & (BUFSIZE-1); - f = x->c_buf[phase] + fraction * - (x->c_buf[(phase-1)& (BUFSIZE-1)] - x->c_buf[phase]); - g = *in1++; - *out++ = x->c_buf[(writephase++) & (BUFSIZE-1)] = - g + x->c_feedback * f + 1E-20f; - } - x->c_phase = writephase & (BUFSIZE-1); - return (w+6); -} - -/* sets the reson frequency */ - -void sigreson_float(t_sigreson *x, t_floatarg f) -{ - float ftemp; - - x->x_ctl->c_freq = (f < 1 ? 1 : f); - - ftemp = x->x_ctl->c_samprate/x->x_ctl->c_freq; - if (ftemp >= BUFSIZE - 1) - ftemp = BUFSIZE - 1.f; - else if (ftemp < 1.0) - ftemp = 1.f; - x->x_ctl->c_delayinsamps = (int)ftemp; - x->x_ctl->c_fraction = ftemp - x->x_ctl->c_delayinsamps; -} - -/* routine which FTS calls to put you on the DSP chain or take you off. */ - -static void sigreson_dsp(t_sigreson *x, t_signal **sp) -{ - x->x_ctl->c_samprate = sp[0]->s_sr; - sigreson_float(x, x->x_ctl->c_freq); - dsp_add(cu_reson, 5, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, - x->x_ctl, sp[0]->s_n); -} - -static void sigreson_ft1(t_sigreson *x, t_floatarg f) /* sets feedback */ -{ - if (f > .99999) f = .99999f; - else if (f < -.99999) f = -.99999f; - x->x_ctl->c_feedback = (float)f; -} - -static void sigreson_ff(t_sigreson *x) /* cleanup on free */ -{ - free(x->x_ctl->c_buf); -} - -static t_class *sigreson_class; - -void *sigreson_new(t_floatarg f, t_floatarg g) -{ - t_sigreson *x = (t_sigreson *)pd_new(sigreson_class); - outlet_new(&x->x_obj, &s_signal); - - /* things in "cspace" are things you'll actually use at DSP time */ - x->x_cspace.c_phase = 0; - if (!(x->x_cspace.c_buf = (float *)malloc(BUFSIZE * sizeof(float)))) - { - error("buffer alloc failed"); - return (0); - } - x->x_cspace.c_samprate = 44100.f; /* just a plausible default */ - - /* control block is in the garage at startup */ - x->x_ctl = &x->x_cspace; - sigreson_float(x, (t_float)f); /* setup params */ - sigreson_ft1(x, g); - /* make a "float" inlet */ - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); - return (x); -} - -void reson_setup() -{ - sigreson_class = class_new(gensym("reson~"), (t_newmethod)sigreson_new, - (t_method)sigreson_ff, sizeof(t_sigreson), 0, - A_DEFFLOAT, A_DEFFLOAT, 0); - class_addfloat(sigreson_class, (t_method)sigreson_float); - class_addmethod(sigreson_class, (t_method)sigreson_ft1, gensym("ft1"), A_FLOAT, 0); - class_addmethod(sigreson_class, (t_method)nullfn, &s_signal, A_NULL); - class_addmethod(sigreson_class, (t_method)sigreson_dsp, gensym("dsp"), A_NULL); -} - diff --git a/reson~.c b/reson~.c new file mode 100644 index 0000000..26aa245 --- /dev/null +++ b/reson~.c @@ -0,0 +1,156 @@ +/* + * Copyright (c) 1997-1999 Mark Danks. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. + */ + +/* Original code by Miller Puckette */ +/* a non-interpolating reson filter, not very carefully coded... */ +/* 11/29/94 modified to do interpolation - M. Danks */ + +#include "m_pd.h" + +#include + +#define BUFSIZE 4096 + +typedef struct resonctl +{ + float c_freq; + float c_samprate; + float c_feedback; + int c_delayinsamps; + float c_fraction; + int c_phase; + float *c_buf; +} t_resonctl; + +typedef struct sigreson +{ + t_object x_obj; /* header */ + t_resonctl *x_ctl; /* pointer to state */ + t_resonctl x_cspace; /* garage for state when not in a chain */ +} t_sigreson; + +/* the DSP routine -- called for every n samples of input */ +static t_int *cu_reson(t_int *w) +{ + t_float *in1 = (t_float *)(w[1]); + t_float *in2 = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + t_resonctl *x = (t_resonctl *)(w[4]); + int n = (int)(w[5]); + long i; + int writephase = x->c_phase; + for (i = 0; i < n; i++) + { + /* note two tricks: 1. input is read before output + * is written, because the routine might be called + * in-place; + * 2 - a seed of 1E-20 is thrown in to avoid floating + * underflow which slows the calculation down. + */ + int readphase, phase, delayinsamps; + float fraction, f, g, freq, freqtemp; + + float ftemp; + + freq = *in2++; + freqtemp = (freq < 1 ? 1 : freq); + + ftemp = x->c_samprate/freqtemp; + if (ftemp >= BUFSIZE-1) + ftemp = BUFSIZE - 1.f; + else if (ftemp < 1.0) + ftemp = 1.f; + delayinsamps = (int)ftemp; + fraction = ftemp - delayinsamps; + + readphase = writephase - delayinsamps; + phase = readphase & (BUFSIZE-1); + f = x->c_buf[phase] + fraction * + (x->c_buf[(phase-1)& (BUFSIZE-1)] - x->c_buf[phase]); + g = *in1++; + *out++ = x->c_buf[(writephase++) & (BUFSIZE-1)] = + g + x->c_feedback * f + 1E-20f; + } + x->c_phase = writephase & (BUFSIZE-1); + return (w+6); +} + +/* sets the reson frequency */ + +void sigreson_float(t_sigreson *x, t_floatarg f) +{ + float ftemp; + + x->x_ctl->c_freq = (f < 1 ? 1 : f); + + ftemp = x->x_ctl->c_samprate/x->x_ctl->c_freq; + if (ftemp >= BUFSIZE - 1) + ftemp = BUFSIZE - 1.f; + else if (ftemp < 1.0) + ftemp = 1.f; + x->x_ctl->c_delayinsamps = (int)ftemp; + x->x_ctl->c_fraction = ftemp - x->x_ctl->c_delayinsamps; +} + +/* routine which FTS calls to put you on the DSP chain or take you off. */ + +static void sigreson_dsp(t_sigreson *x, t_signal **sp) +{ + x->x_ctl->c_samprate = sp[0]->s_sr; + sigreson_float(x, x->x_ctl->c_freq); + dsp_add(cu_reson, 5, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, + x->x_ctl, sp[0]->s_n); +} + +static void sigreson_ft1(t_sigreson *x, t_floatarg f) /* sets feedback */ +{ + if (f > .99999) f = .99999f; + else if (f < -.99999) f = -.99999f; + x->x_ctl->c_feedback = (float)f; +} + +static void sigreson_ff(t_sigreson *x) /* cleanup on free */ +{ + free(x->x_ctl->c_buf); +} + +static t_class *sigreson_class; + +void *sigreson_new(t_floatarg f, t_floatarg g) +{ + t_sigreson *x = (t_sigreson *)pd_new(sigreson_class); + outlet_new(&x->x_obj, &s_signal); + + /* things in "cspace" are things you'll actually use at DSP time */ + x->x_cspace.c_phase = 0; + if (!(x->x_cspace.c_buf = (float *)malloc(BUFSIZE * sizeof(float)))) + { + error("buffer alloc failed"); + return (0); + } + x->x_cspace.c_samprate = 44100.f; /* just a plausible default */ + + /* control block is in the garage at startup */ + x->x_ctl = &x->x_cspace; + sigreson_float(x, (t_float)f); /* setup params */ + sigreson_ft1(x, g); + /* make a "float" inlet */ + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); + return (x); +} + +void reson_tilde_setup() +{ + sigreson_class = class_new(gensym("reson~"), (t_newmethod)sigreson_new, + (t_method)sigreson_ff, sizeof(t_sigreson), 0, + A_DEFFLOAT, A_DEFFLOAT, 0); + class_addfloat(sigreson_class, (t_method)sigreson_float); + class_addmethod(sigreson_class, (t_method)sigreson_ft1, gensym("ft1"), A_FLOAT, 0); + class_addmethod(sigreson_class, (t_method)nullfn, &s_signal, A_NULL); + class_addmethod(sigreson_class, (t_method)sigreson_dsp, gensym("dsp"), A_NULL); +} + diff --git a/sigdelta.c b/sigdelta.c deleted file mode 100644 index 9b627d9..0000000 --- a/sigdelta.c +++ /dev/null @@ -1,56 +0,0 @@ -#include "m_pd.h" -#include -#ifdef NT -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - -/* ------------------------ delta~ ----------------------------- */ - -/* tilde object to take difference value. */ - -static t_class *delta_class; - -typedef struct _delta -{ - t_object x_obj; - t_sample x_last; -} t_delta; - -static t_int *delta_perform(t_int *w) -{ - t_delta *x = (t_delta *)(w[1]); - t_float *in = (t_float *)(w[2]); - t_float *out = (t_float *)(w[3]); - int n = (int)(w[4]); - while (n--) - { - float f = *(in++); - // *out++ = (f > 0 ? f : -f); - *out++ = (f > x->x_last ? fabs(f - x->x_last) : -fabs(f - x->x_last)); - x->x_last = f; - } - return (w+5); -} - -static void delta_dsp(t_delta *x, t_signal **sp) -{ - dsp_add(delta_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -static void *delta_new(void) -{ - t_delta *x = (t_delta *)pd_new(delta_class); - x->x_last = 0.; - outlet_new(&x->x_obj, gensym("signal")); - return (x); -} - -void delta_tilde_setup(void) -{ - delta_class = class_new(gensym("delta~"), (t_newmethod)delta_new, 0, - sizeof(t_delta), 0, A_DEFFLOAT, 0); - class_addmethod(delta_class, nullfn, gensym("signal"), 0); - class_addmethod(delta_class, (t_method)delta_dsp, gensym("dsp"), 0); - class_sethelpsymbol(delta_class, gensym("delta.pd")); -} diff --git a/utime.c b/utime.c new file mode 100644 index 0000000..429e90d --- /dev/null +++ b/utime.c @@ -0,0 +1,75 @@ +/* + (c) 2002:cxc@web.fm + microtime: seconds since epoch plus microsecs + */ + +#include +#ifdef NT +#include +#else +#include +#endif +#include + +/* ----------------------- utime --------------------- */ + +static t_class *utime_class; + +typedef struct _utime +{ + t_object x_obj; + t_outlet *x_outlet1; + t_outlet *x_outlet2; +} t_utime; + +static void *utime_new(t_symbol *s, int argc, t_atom *argv) { + t_utime *x = (t_utime *)pd_new(utime_class); + x->x_outlet1 = outlet_new(&x->x_obj, &s_float); + x->x_outlet2 = outlet_new(&x->x_obj, &s_float); + return (x); +} + +#ifndef NT +static void utime_bang(t_utime *x) +{ + struct timeval myutime; + struct timezone mytz; + + gettimeofday(&myutime, &mytz); + outlet_float(x->x_outlet2, (t_float)myutime.tv_usec); + outlet_float(x->x_outlet1, (t_float)myutime.tv_sec); +} +#else +static void utime_bang(t_utime *x) +{ + FILETIME myfiletime; + ULARGE_INTEGER ulfiletime, ulSec, uluSec; + + GetSystemTimeAsFileTime(&myfiletime); + ulfiletime.LowPart = myfiletime.dwLowDateTime; + ulfiletime.HighPart = myfiletime.dwHighDateTime; + ulfiletime.QuadPart -= 116444736000000000; // number of 100ns ticks from 1601-01-01 to 1970-01-01 + ulSec.QuadPart = ulfiletime.QuadPart / (10 * 1000 * 1000); // FILETIME uses 100ns ticks + uluSec.QuadPart = (ulfiletime.QuadPart - ulSec.QuadPart * 10 * 1000 * 1000) / 10; // FILETIME uses 100ns ticks + + outlet_float(x->x_outlet2, (t_float)(__int64)ulSec.QuadPart ); + outlet_float(x->x_outlet1, (t_float)(__int64)uluSec.QuadPart); +} +#endif + +static void help_utime(t_utime *x) +{ + post("\n%c utime\t\t:: get the current system time", 70); + post("\noutputs are\t: seconds since epoch / remaining microseconds"); +} + +void utime_setup(void) +{ + utime_class = class_new(gensym("utime"), + (t_newmethod)utime_new, 0, + sizeof(t_utime), 0, A_GIMME, 0); + + class_addbang(utime_class, utime_bang); + + class_addmethod(utime_class, (t_method)help_utime, gensym("help"), 0); +} -- cgit v1.2.1