From c2014a0a771e621cec552c6ee88daddcb46d13fe Mon Sep 17 00:00:00 2001 From: "N.N." Date: Mon, 21 Nov 2005 22:16:37 +0000 Subject: cyclone alpha55 (see notes.txt for cyclone and shared) svn path=/trunk/externals/miXed/; revision=4011 --- cyclone/Makefile.sources | 1 + cyclone/build_counter | 4 +-- cyclone/hammer/seq.c | 58 ++++++++++++++++++++++-------- cyclone/notes.txt | 8 +++++ cyclone/sickle/Line.c | 2 +- cyclone/sickle/Makefile.sources | 1 + cyclone/sickle/abs.c | 59 ++++++++++++++++++++++++++++-- cyclone/sickle/allsickles.c | 2 ++ cyclone/sickle/curve.c | 2 +- cyclone/sickle/lores.c | 4 +-- cyclone/sickle/onepole.c | 2 +- cyclone/sickle/overdrive.c | 80 +++++++++++++++++++++++++++++++++++++++++ cyclone/sickle/rampsmooth.c | 8 +++-- cyclone/sickle/reson.c | 4 +-- cyclone/sickle/slide.c | 3 +- cyclone/sickle/svf.c | 4 +-- 16 files changed, 211 insertions(+), 31 deletions(-) create mode 100644 cyclone/sickle/overdrive.c (limited to 'cyclone') diff --git a/cyclone/Makefile.sources b/cyclone/Makefile.sources index 96d3007..a5f40ca 100644 --- a/cyclone/Makefile.sources +++ b/cyclone/Makefile.sources @@ -149,6 +149,7 @@ sickle/minimum.c \ sickle/minmax.c \ sickle/mstosamps.c \ sickle/onepole.c \ +sickle/overdrive.c \ sickle/peakamp.c \ sickle/phasewrap.c \ sickle/pink.c \ diff --git a/cyclone/build_counter b/cyclone/build_counter index 5a0c15d..ab7d6ce 100644 --- a/cyclone/build_counter +++ b/cyclone/build_counter @@ -1,7 +1,7 @@ #define CYCLONE_VERSION "0.1" #define CYCLONE_RELEASE "alpha" -#define CYCLONE_BUILD 54 +#define CYCLONE_BUILD 55 #if 0 -CYCLONE_SNAPSHOT = 0.1-alpha54 +CYCLONE_SNAPSHOT = 0.1-alpha55 #endif diff --git a/cyclone/hammer/seq.c b/cyclone/hammer/seq.c index 38b0769..ce8c0a4 100644 --- a/cyclone/hammer/seq.c +++ b/cyclone/hammer/seq.c @@ -26,6 +26,11 @@ #define SEQ_TICKSPERSEC 48 #define SEQ_MINTICKDELAY 1. /* LATER rethink */ #define SEQ_TICKEPSILON ((double).0001) +#define SEQ_STARTEPSILON .0001 /* if inside: play unmodified */ +#define SEQ_TEMPOEPSILON .0001 /* if inside: pause */ + +#define SEQ_ISRUNNING(x) ((x)->x_prevtime > (double).0001) +#define SEQ_ISPAUSED(x) ((x)->x_prevtime <= (double).0001) enum { SEQ_IDLEMODE, SEQ_RECMODE, SEQ_PLAYMODE, SEQ_SLAVEMODE }; @@ -285,7 +290,7 @@ static void seq_startplayback(t_seq *x, int modechanged) } else { /* CHECKED timescale change */ - if (x->x_prevtime > 0.) /* running state */ + if (SEQ_ISRUNNING(x)) x->x_clockdelay -= clock_gettimesince(x->x_prevtime); x->x_clockdelay *= x->x_newtimescale / x->x_timescale; } @@ -429,7 +434,7 @@ static void seq_tick(t_seq *x) return; clock_delay(x->x_slaveclock, elapsed); seq_settimescale(x, (float)(elapsed * (SEQ_TICKSPERSEC / 1000.))); - if (x->x_prevtime > 0.) + if (SEQ_ISRUNNING(x)) { x->x_clockdelay -= clock_gettimesince(x->x_prevtime); x->x_clockdelay *= x->x_newtimescale / x->x_timescale; @@ -516,14 +521,14 @@ static void seq_append(t_seq *x) static void seq_start(t_seq *x, t_floatarg f) { - if (f < 0) + if (f < -SEQ_STARTEPSILON) { /* FIXME */ seq_setmode(x, SEQ_SLAVEMODE); } else { - seq_settimescale(x, (f == 0 ? 1. : 1024. / f)); + seq_settimescale(x, (f > SEQ_STARTEPSILON ? 1024. / f : 1.)); seq_setmode(x, SEQ_PLAYMODE); /* CHECKED 'start' stops recording */ } } @@ -562,8 +567,7 @@ static void seq_pause(t_seq *x) fittermax_warning(*(t_pd *)x, "'pause' not supported in Max"); warned = 1; } - if (x->x_mode == SEQ_PLAYMODE && - x->x_prevtime > 0.) /* running state */ + if (x->x_mode == SEQ_PLAYMODE && SEQ_ISRUNNING(x)) { x->x_clockdelay -= clock_gettimesince(x->x_prevtime); if (x->x_clockdelay < 0.) @@ -581,8 +585,7 @@ static void seq_continue(t_seq *x) fittermax_warning(*(t_pd *)x, "'continue' not supported in Max"); warned = 1; } - if (x->x_mode == SEQ_PLAYMODE && - x->x_prevtime <= 0.) /* pause state */ + if (x->x_mode == SEQ_PLAYMODE && SEQ_ISPAUSED(x)) { if (x->x_clockdelay < 0.) x->x_clockdelay = 0.; @@ -603,8 +606,8 @@ static void seq_goto(t_seq *x, t_floatarg f1, t_floatarg f2) { t_seqevent *ev; int ndx, nevents = x->x_nevents; - double ms = f1 * 1000. + f2, sum; - if (ms < SEQ_TICKEPSILON) + double ms = (double)f1 * 1000. + f2, sum; + if (ms <= SEQ_TICKEPSILON) ms = 0.; if (x->x_mode != SEQ_PLAYMODE) { @@ -624,7 +627,7 @@ static void seq_goto(t_seq *x, t_floatarg f1, t_floatarg f2) x->x_clockdelay = sum - SEQ_TICKEPSILON - ms; if (x->x_clockdelay < 0.) x->x_clockdelay = 0.; - if (x->x_prevtime > 0.) /* running state */ + if (SEQ_ISRUNNING(x)) { clock_delay(x->x_clock, x->x_clockdelay); x->x_prevtime = clock_getlogicaltime(); @@ -649,17 +652,42 @@ static void seq_scoretime(t_seq *x, t_symbol *s) t_atom aout[2]; double ms, clockdelay = x->x_clockdelay; t_float f1, f2; - if (x->x_prevtime > 0.) /* running state */ + if (SEQ_ISRUNNING(x)) clockdelay -= clock_gettimesince(x->x_prevtime); ms = x->x_nextscoretime - clockdelay / x->x_timescale; - f1 = ms / 1000.; - f2 = ms - f1; + /* Send ms as a pair of floats (f1, f2) = (coarse in sec, fine in msec). + Any ms may then be exactly reconstructed as (double)f1 * 1000. + f2. + Currently, f2 may be negative. LATER consider truncating f1 so that + only significant digits are on (when using 1 ms resolution, a float + stores only up to 8.7 minutes without distortion, 100 ms resolution + gives 14.5 hours of non-distorted floats, etc.) */ + f1 = ms * .001; + f2 = ms - (double)f1 * 1000.; + if (f2 < .001 && f2 > -.001) + f2 = 0.; SETFLOAT(&aout[0], f1); SETFLOAT(&aout[1], f2); pd_list(s->s_thing, &s_list, 2, aout); } } +static void seq_tempo(t_seq *x, t_floatarg f) +{ + static int warned = 0; + if (fittermax_get() && !warned) + { + fittermax_warning(*(t_pd *)x, "'tempo' not supported in Max"); + warned = 1; + } + if (f > SEQ_TEMPOEPSILON) + { + seq_settimescale(x, 1. / f); + if (x->x_mode == SEQ_PLAYMODE) + seq_startplayback(x, 0); + } + /* FIXME else pause, LATER reverse playback if (f < -SEQ_TEMPOEPSILON) */ +} + static void seq_cd(t_seq *x, t_symbol *s) { static int warned = 0; @@ -1206,6 +1234,8 @@ void seq_setup(void) gensym("goto"), A_DEFFLOAT, A_DEFFLOAT, 0); class_addmethod(seq_class, (t_method)seq_scoretime, gensym("scoretime"), A_SYMBOL, 0); + class_addmethod(seq_class, (t_method)seq_tempo, + gensym("tempo"), A_FLOAT, 0); class_addmethod(seq_class, (t_method)seq_cd, gensym("cd"), A_DEFSYM, 0); class_addmethod(seq_class, (t_method)seq_pwd, diff --git a/cyclone/notes.txt b/cyclone/notes.txt index 8ac4f0f..23152f7 100644 --- a/cyclone/notes.txt +++ b/cyclone/notes.txt @@ -4,6 +4,14 @@ TODO for cyclone DONE for cyclone +alpha55 + * new class: overdrive~ + * seq: + . new incompatible message 'tempo': 1-based coef, does not start playback + . fix for double-to-float-pair calc in 'scoretime' and 'goto' + * abs~: performance fix + * slide~, rampsmooth~: bashing denormals + alpha54 * comment: fixing namespace bug, reducing traffic * testmess: optionally filling message with symbols (numbers in hex form 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,14 +1,38 @@ -/* 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 #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; static t_int *abs_perform(t_int *w) +{ + int nblock = (int)(w[1]); + 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]); @@ -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 +#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); } -- cgit v1.2.1