aboutsummaryrefslogtreecommitdiff
path: root/cyclone/sickle
diff options
context:
space:
mode:
Diffstat (limited to 'cyclone/sickle')
-rw-r--r--cyclone/sickle/Line.c2
-rw-r--r--cyclone/sickle/Makefile.sources1
-rw-r--r--cyclone/sickle/abs.c59
-rw-r--r--cyclone/sickle/allsickles.c2
-rw-r--r--cyclone/sickle/curve.c2
-rw-r--r--cyclone/sickle/lores.c4
-rw-r--r--cyclone/sickle/onepole.c2
-rw-r--r--cyclone/sickle/overdrive.c80
-rw-r--r--cyclone/sickle/rampsmooth.c8
-rw-r--r--cyclone/sickle/reson.c4
-rw-r--r--cyclone/sickle/slide.c3
-rw-r--r--cyclone/sickle/svf.c4
12 files changed, 156 insertions, 15 deletions
diff --git a/cyclone/sickle/Line.c b/cyclone/sickle/Line.c
index eb8be26..4a8eccd 100644
--- a/cyclone/sickle/Line.c
+++ b/cyclone/sickle/Line.c
@@ -70,7 +70,7 @@ static t_int *line_perform(t_int *w)
float curval = x->x_value;
float inc = x->x_inc;
float biginc = x->x_biginc;
- if (PD_BADFLOAT(curval)) /* LATER rethink */
+ if (PD_BIGORSMALL(curval)) /* LATER rethink */
curval = x->x_value = 0;
retarget:
if (x->x_retarget)
diff --git a/cyclone/sickle/Makefile.sources b/cyclone/sickle/Makefile.sources
index c66b33e..ce8b493 100644
--- a/cyclone/sickle/Makefile.sources
+++ b/cyclone/sickle/Makefile.sources
@@ -50,6 +50,7 @@ minimum.c \
minmax.c \
mstosamps.c \
onepole.c \
+overdrive.c \
peakamp.c \
peek.c \
phasewrap.c \
diff --git a/cyclone/sickle/abs.c b/cyclone/sickle/abs.c
index cde26a5..777b891 100644
--- a/cyclone/sickle/abs.c
+++ b/cyclone/sickle/abs.c
@@ -1,10 +1,23 @@
-/* Copyright (c) 2002-2003 krzYszcz and others.
+/* Copyright (c) 2002-2005 krzYszcz and others.
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+#include <math.h>
#include "m_pd.h"
#include "sickle/sic.h"
+/* some random tests (average percentage in load meter and top):
+ gcc 3.3.5 -O6, p4 2.66GHz, 4500 copies: perform 56, perf8 57, perf0 94
+ gcc 3.3.5 -O6, p4 2.66GHz, 9000 copies: perform 118, perf8 123, perf0 194
+ vc 6.0 /O2, p3 800Mhz, 750 copies: perform 61, perf8 56, perf0 82 */
+#ifdef KRZYSZCZ
+//#define ABS_TEST
+#endif
+
+#ifdef ABS_TEST
+#include "common/fitter.h"
+#endif
+
typedef t_sic t_abs;
static t_class *abs_class;
@@ -14,6 +27,17 @@ static t_int *abs_perform(t_int *w)
t_float *in = (t_float *)(w[2]);
t_float *out = (t_float *)(w[3]);
while (nblock--)
+ *out++ = fabsf(*in++);
+ return (w + 4);
+}
+
+#ifdef ABS_TEST
+static t_int *abs_perf0(t_int *w)
+{
+ int nblock = (int)(w[1]);
+ t_float *in = (t_float *)(w[2]);
+ t_float *out = (t_float *)(w[3]);
+ while (nblock--)
{
float f = *in++;
*out++ = (f >= 0 ? f : -f);
@@ -21,9 +45,37 @@ static t_int *abs_perform(t_int *w)
return (w + 4);
}
+static t_int *abs_perf8(t_int *w)
+{
+ int nblock = (int)(w[1])>>3;
+ t_float *in = (t_float *)(w[2]);
+ t_float *out = (t_float *)(w[3]);
+ while (nblock--)
+ {
+ *out++ = fabsf(*in++);
+ *out++ = fabsf(*in++);
+ *out++ = fabsf(*in++);
+ *out++ = fabsf(*in++);
+ *out++ = fabsf(*in++);
+ *out++ = fabsf(*in++);
+ *out++ = fabsf(*in++);
+ *out++ = fabsf(*in++);
+ }
+ return (w + 4);
+}
+#endif
+
static void abs_dsp(t_abs *x, t_signal **sp)
{
- dsp_add(abs_perform, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
+#ifdef ABS_TEST
+ t_symbol *tst = fitter_getsymbol(gensym("test"));
+ if (tst == gensym("unroll"))
+ dsp_add(abs_perf8, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
+ else if (tst == gensym("branch"))
+ dsp_add(abs_perf0, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
+ else
+#endif
+ dsp_add(abs_perform, 3, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
}
static void *abs_new(void)
@@ -39,4 +91,7 @@ void abs_tilde_setup(void)
(t_newmethod)abs_new, 0,
sizeof(t_abs), 0, 0);
sic_setup(abs_class, abs_dsp, SIC_FLOATTOSIGNAL);
+#ifdef ABS_TEST
+ fitter_setup(abs_class, 0);
+#endif
}
diff --git a/cyclone/sickle/allsickles.c b/cyclone/sickle/allsickles.c
index b8432d5..6c1141e 100644
--- a/cyclone/sickle/allsickles.c
+++ b/cyclone/sickle/allsickles.c
@@ -51,6 +51,7 @@ void minimum_tilde_setup(void);
void minmax_tilde_setup(void);
void mstosamps_tilde_setup(void);
void onepole_tilde_setup(void);
+void overdrive_tilde_setup(void);
void peakamp_tilde_setup(void);
void peek_tilde_setup(void);
void phasewrap_tilde_setup(void);
@@ -131,6 +132,7 @@ void allsickles_setup(void)
minmax_tilde_setup();
mstosamps_tilde_setup();
onepole_tilde_setup();
+ overdrive_tilde_setup();
peakamp_tilde_setup();
peek_tilde_setup();
phasewrap_tilde_setup();
diff --git a/cyclone/sickle/curve.c b/cyclone/sickle/curve.c
index 730dd0d..669dd14 100644
--- a/cyclone/sickle/curve.c
+++ b/cyclone/sickle/curve.c
@@ -100,7 +100,7 @@ static t_int *curve_perform(t_int *w)
double mm = x->x_mm;
float dy = x->x_dy;
float y0 = x->x_y0;
- if (PD_BADFLOAT(curval)) /* LATER rethink */
+ if (PD_BIGORSMALL(curval)) /* LATER rethink */
curval = x->x_value = 0;
retarget:
if (x->x_retarget)
diff --git a/cyclone/sickle/lores.c b/cyclone/sickle/lores.c
index 9449947..937f3b1 100644
--- a/cyclone/sickle/lores.c
+++ b/cyclone/sickle/lores.c
@@ -74,8 +74,8 @@ static t_int *lores_perform(t_int *w)
ynm1 = yn;
}
/* LATER rethink */
- x->x_ynm1 = (PD_BADFLOAT(ynm1) ? 0. : ynm1);
- x->x_ynm2 = (PD_BADFLOAT(ynm2) ? 0. : ynm2);
+ x->x_ynm1 = (PD_BIGORSMALL(ynm1) ? 0. : ynm1);
+ x->x_ynm2 = (PD_BIGORSMALL(ynm2) ? 0. : ynm2);
return (w + 7);
}
diff --git a/cyclone/sickle/onepole.c b/cyclone/sickle/onepole.c
index f06b581..0772c80 100644
--- a/cyclone/sickle/onepole.c
+++ b/cyclone/sickle/onepole.c
@@ -98,7 +98,7 @@ static t_int *onepole_perform(t_int *w)
specifically: a1=b0-1 => a1 in [-.9999 .. -.01] => lowpass (stable) */
while (nblock--)
*out++ = ynm1 = b0 * (*xin++ - ynm1) + ynm1;
- x->x_ynm1 = (PD_BADFLOAT(ynm1) ? 0. : ynm1);
+ x->x_ynm1 = (PD_BIGORSMALL(ynm1) ? 0. : ynm1);
return (w + 6);
}
diff --git a/cyclone/sickle/overdrive.c b/cyclone/sickle/overdrive.c
new file mode 100644
index 0000000..1625dd4
--- /dev/null
+++ b/cyclone/sickle/overdrive.c
@@ -0,0 +1,80 @@
+/* Copyright (c) 2005 krzYszcz and others.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+#include <math.h>
+#include "m_pd.h"
+#include "sickle/sic.h"
+
+/* FIXME this is unnecessary in vc > 6.0 and darwin? */
+#if defined(MSW) || defined(MACOSX)
+#define powf pow
+#endif
+
+typedef struct _overdrive
+{
+ t_sic x_sic;
+ float x_drivefactor;
+} t_overdrive;
+
+static t_class *overdrive_class;
+
+/* CHECKED this is redundant (a design flaw), LATER fitter-optionally use
+ float-to-signal conversion. */
+static void overdrive_float(t_overdrive *x, t_float f)
+{
+ x->x_drivefactor = f;
+}
+
+static void overdrive_ft1(t_overdrive *x, t_floatarg f)
+{
+ x->x_drivefactor = f;
+}
+
+/* CHECKED negative parameter values may cause output to go out of bounds */
+static t_int *overdrive_perform(t_int *w)
+{
+ float df = *(t_float *)(w[1]);
+ int nblock = (int)(w[2]);
+ t_float *in = (t_float *)(w[3]);
+ t_float *out = (t_float *)(w[4]);
+ while (nblock--)
+ {
+ float f = *in++;
+ if (f >= 1.) /* CHECKED incompatible (garbage for sig~ 1.) */
+ *out++ = 1.; /* CHECKED constant for > 1. */
+ else if (f > 0.)
+ *out++ = 1. - powf(1. - f, df); /* CHECKED */
+ else if (f > -1.) /* CHECKED incompatible (garbage for sig~ -1.) */
+ *out++ = powf(1. + f, df) - 1.; /* CHECKED */
+ else
+ *out++ = -1.; /* CHECKED constant for < -1. */
+ }
+ return (w + 5);
+}
+
+static void overdrive_dsp(t_overdrive *x, t_signal **sp)
+{
+ dsp_add(overdrive_perform, 4, &x->x_drivefactor,
+ sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
+}
+
+static void *overdrive_new(t_floatarg f)
+{
+ t_overdrive *x = (t_overdrive *)pd_new(overdrive_class);
+ x->x_drivefactor = f;
+ inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1"));
+ outlet_new((t_object *)x, &s_signal);
+ return (x);
+}
+
+void overdrive_tilde_setup(void)
+{
+ overdrive_class = class_new(gensym("overdrive~"),
+ (t_newmethod)overdrive_new, 0,
+ sizeof(t_overdrive), 0, A_DEFFLOAT, 0);
+ /* CHECKED no float-to-signal conversion */
+ sic_setup(overdrive_class, overdrive_dsp, overdrive_float);
+ class_addmethod(overdrive_class, (t_method)overdrive_ft1,
+ gensym("ft1"), A_FLOAT, 0);
+}
diff --git a/cyclone/sickle/rampsmooth.c b/cyclone/sickle/rampsmooth.c
index c2023d8..848e304 100644
--- a/cyclone/sickle/rampsmooth.c
+++ b/cyclone/sickle/rampsmooth.c
@@ -3,8 +3,10 @@
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
#include "m_pd.h"
+#include "shared.h"
#include "sickle/sic.h"
+/* LATER select the mode fitter-optionally */
#define RAMPSMOOTH_GEOMETRIC /* geometric series (same as slide~) CHECKED */
#ifndef RAMPSMOOTH_GEOMETRIC
#define RAMPSMOOTH_LINEAR
@@ -82,8 +84,8 @@ static t_int *rampsmooth_perform(t_int *w)
}
else *out++ = target;
}
- x->x_last = last;
- x->x_target = target;
+ x->x_last = (PD_BIGORSMALL(last) ? 0. : last);
+ x->x_target = (PD_BIGORSMALL(target) ? 0. : target);
x->x_incr = incr;
x->x_nleft = nleft;
return (w + 5);
@@ -120,7 +122,7 @@ static t_int *rampsmooth_perform(t_int *w)
}
*out++ = last = f;
}
- x->x_last = last;
+ x->x_last = (PD_BIGORSMALL(last) ? 0. : last);
return (w + 5);
}
#endif
diff --git a/cyclone/sickle/reson.c b/cyclone/sickle/reson.c
index b072b32..40969c7 100644
--- a/cyclone/sickle/reson.c
+++ b/cyclone/sickle/reson.c
@@ -82,8 +82,8 @@ static t_int *reson_perform(t_int *w)
x->x_xnm1 = xnm1;
x->x_xnm2 = xnm2;
/* LATER rethink */
- x->x_ynm1 = (PD_BADFLOAT(ynm1) ? 0. : ynm1);
- x->x_ynm2 = (PD_BADFLOAT(ynm2) ? 0. : ynm2);
+ x->x_ynm1 = (PD_BIGORSMALL(ynm1) ? 0. : ynm1);
+ x->x_ynm2 = (PD_BIGORSMALL(ynm2) ? 0. : ynm2);
return (w + 8);
}
diff --git a/cyclone/sickle/slide.c b/cyclone/sickle/slide.c
index 92001b2..9846b94 100644
--- a/cyclone/sickle/slide.c
+++ b/cyclone/sickle/slide.c
@@ -3,6 +3,7 @@
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
#include "m_pd.h"
+#include "shared.h"
#include "sickle/sic.h"
#define SLIDE_DEFUP 1.
@@ -48,7 +49,7 @@ static t_int *slide_perform(t_int *w)
}
*out++ = last;
}
- x->x_last = last;
+ x->x_last = (PD_BIGORSMALL(last) ? 0. : last);
return (w + 7);
}
diff --git a/cyclone/sickle/svf.c b/cyclone/sickle/svf.c
index 5bc0458..74fcf99 100644
--- a/cyclone/sickle/svf.c
+++ b/cyclone/sickle/svf.c
@@ -113,8 +113,8 @@ static t_int *svf_perform(t_int *w)
band -= band * band * band * SVF_DRIVE;
}
/* LATER rethink */
- x->x_band = (PD_BADFLOAT(band) ? 0. : band);
- x->x_low = (PD_BADFLOAT(low) ? 0. : low);
+ x->x_band = (PD_BIGORSMALL(band) ? 0. : band);
+ x->x_low = (PD_BIGORSMALL(low) ? 0. : low);
return (w + 10);
}