Update of /cvsroot/pure-data/externals/miXed/cyclone/sickle In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10934/cyclone/sickle
Modified Files: Makefile.objects buffir.c curve.c sickle.c Log Message: various bug-fixes, maxmode, toxy .#args
Index: curve.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/cyclone/sickle/curve.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** curve.c 14 Aug 2003 14:31:59 -0000 1.1 --- curve.c 8 Dec 2004 15:40:12 -0000 1.2 *************** *** 1,3 **** ! /* Copyright (c) 2003 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ --- 1,3 ---- ! /* Copyright (c) 2004 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ *************** *** 8,59 **** #include "common/grow.h" #include "common/loud.h" #include "sickle/sic.h"
//#define CURVE_DEBUG
! /* CHECKED apparently c74's formula was not very carefully tuned. It has 5% ! deviation from the straight line for ccinput=0 (ccinput is user's curve ! control parameter, <0..1>) at half-domain, range=1. It generates nans for ! ccinput > .995. ! ! The formula below generates curves with < .000004% deviation and no nans. ! ! Problem: find a function f : ccinput -> cc, such that the curves will bend ! in a semi-linear way over the ccinput's range of 0..1. The curve function ! is then g(x, p) = (exp(f(p) * x) - 1) / (exp(f(p)) - 1), where x is curve's ! domain, and p is ccinput. If, for example, the points g(0.5, p) are to make ! a semi-linear pattern, then the solution is a function f that minimizes ! the integral of the error function e(p) = sqr(((1-p)/2)-g(.5, p)) over 0..1. ! Until someone does this analytically, we are left with a lame formula, which ! has been tweaked and tested in gnuplot: f(p) = h(p) / (1 - h(p)), where ! h(p) = (((p + 1e-20) * 1.2) ** .41) * .91. The file curve.gp, in the ! sickle's source directory, may come handy, in case there is anyone, who ! fancy tweaking it even further. ! ! To implement this, start from these equations: ! bb * mm ^ npoints = bb + 1 ! (bb ^ 2) * (mm ^ npoints) = ((exp(ff/2) - 1) / (exp(ff) - 1)) ^ 2 ! ! and calculate: ! hh = pow(((ccinput + c1) * c2), c3) * c4 ! ff = hh / (1 - hh) ! eff = exp(ff) - 1 ! gh = (exp(ff * .5) - 1) / eff ! bb = gh * (gh / (1 - (gh + gh))) ! mm = ((exp(ff * (1/npoints)) - 1) / (eff * bb)) + 1 ! ! The loop is: ! for (vv = bb, i = 0; i < n; vv *= mm, i++) ! result = (vv - bb) * (y1 - y0) + y0 ! where y0, y1 are start and destination values ! */ ! ! #define CURVE_C1 1e-20 ! #define CURVE_C2 1.2 ! #define CURVE_C3 0.41 ! #define CURVE_C4 0.91 ! ! #define CURVE_MINCCINPUT -1. ! #define CURVE_MAXCCINPUT 1.
#define CURVE_INISIZE 64 /* LATER rethink */ --- 8,19 ---- #include "common/grow.h" #include "common/loud.h" + #include "common/clc.h" #include "sickle/sic.h"
//#define CURVE_DEBUG
! /* CHECKED apparently c74's formula has not been carefully tuned (yet?). ! It has 5% deviation from the straight line for ccinput = 0 at half-domain, ! range 1, and generates nans for ccinput > .995 (cf comment in clc.h). */
#define CURVE_INISIZE 64 /* LATER rethink */ *************** *** 64,68 **** float s_target; float s_delta; ! int s_npoints; float s_ccinput; double s_bb; --- 24,28 ---- float s_target; float s_delta; ! int s_nhops; float s_ccinput; double s_bb; *************** *** 96,100 **** int dbg_nretargets; int dbg_exitpoint; ! int dbg_npoints; #endif } t_curve; --- 56,60 ---- int dbg_nretargets; int dbg_exitpoint; ! int dbg_nhops; #endif } t_curve; *************** *** 105,144 **** static void curve_cc(t_curve *x, t_curveseg *segp, float f) { ! int npoints = segp->s_delta * x->x_ksr + 0.5; /* LATER rethink */ segp->s_ccinput = f; ! if (npoints > 0) ! { ! double hh, ff, eff, gh; ! segp->s_npoints = npoints; ! if (f < 0) ! { ! if (f < CURVE_MINCCINPUT) ! f = CURVE_MINCCINPUT; ! hh = pow(((CURVE_C1 - f) * CURVE_C2), CURVE_C3) * CURVE_C4; ! ff = hh / (1. - hh); ! eff = exp(ff) - 1.; ! gh = (exp(ff * .5) - 1.) / eff; ! segp->s_bb = gh * (gh / (1. - (gh + gh))); ! segp->s_mm = 1. / (((exp(ff * (1. / (double)npoints)) - 1.) / ! (eff * segp->s_bb)) + 1.); ! } ! else ! { ! if (f > CURVE_MAXCCINPUT) ! f = CURVE_MAXCCINPUT; ! hh = pow(((f + CURVE_C1) * CURVE_C2), CURVE_C3) * CURVE_C4; ! ff = hh / (1. - hh); ! eff = exp(ff) - 1.; ! gh = (exp(ff * .5) - 1.) / eff; ! segp->s_bb = gh * (gh / (1. - (gh + gh))); ! segp->s_mm = ((exp(ff * (1. / (double)npoints)) - 1.) / ! (eff * segp->s_bb)) + 1.; ! } ! } ! else ! { ! segp->s_npoints = 0; ! segp->s_bb = segp->s_mm = 1.; ! } #ifdef CURVE_DEBUG post("%g %g %g %g", --- 65,72 ---- static void curve_cc(t_curve *x, t_curveseg *segp, float f) { ! int nhops = segp->s_delta * x->x_ksr + 0.5; /* LATER rethink */ segp->s_ccinput = f; ! segp->s_nhops = (nhops > 0 ? nhops : 0); ! clccurve_coefs(segp->s_nhops, (double)f, &segp->s_bb, &segp->s_mm); #ifdef CURVE_DEBUG post("%g %g %g %g", *************** *** 153,159 **** post("exit point %d, after %d retarget calls", x->dbg_exitpoint, x->dbg_nretargets); ! post("at value %g, after last %d npoints, with bb %g, mm %g", ! x->x_value, x->dbg_npoints, x->x_bb, x->x_mm); ! x->dbg_nretargets = x->dbg_exitpoint = x->dbg_npoints = 0; #endif } --- 81,87 ---- post("exit point %d, after %d retarget calls", x->dbg_exitpoint, x->dbg_nretargets); ! post("at value %g, after last %d nhops, with bb %g, mm %g", ! x->x_value, x->dbg_nhops, x->x_bb, x->x_mm); ! x->dbg_nretargets = x->dbg_exitpoint = x->dbg_nhops = 0; #endif } *************** *** 178,193 **** float target = x->x_curseg->s_target; float delta = x->x_curseg->s_delta; ! int npoints = x->x_curseg->s_npoints; mm = x->x_curseg->s_mm; if (x->x_curseg->s_ccinput < 0) - { - bb = x->x_curseg->s_bb + 1.; dy = x->x_value - target; - } else - { - bb = x->x_curseg->s_bb; dy = target - x->x_value; - } #ifdef CURVE_DEBUG x->dbg_nretargets++; --- 106,116 ---- float target = x->x_curseg->s_target; float delta = x->x_curseg->s_delta; ! int nhops = x->x_curseg->s_nhops; ! bb = x->x_curseg->s_bb; mm = x->x_curseg->s_mm; if (x->x_curseg->s_ccinput < 0) dy = x->x_value - target; else dy = target - x->x_value; #ifdef CURVE_DEBUG x->dbg_nretargets++; *************** *** 195,199 **** x->x_nsegs--; x->x_curseg++; ! while (npoints <= 0) { curval = x->x_value = target; --- 118,122 ---- x->x_nsegs--; x->x_curseg++; ! while (nhops <= 0) { curval = x->x_value = target; *************** *** 202,217 **** target = x->x_curseg->s_target; delta = x->x_curseg->s_delta; ! npoints = x->x_curseg->s_npoints; mm = x->x_curseg->s_mm; if (x->x_curseg->s_ccinput < 0) - { - bb = x->x_curseg->s_bb + 1.; dy = x->x_value - target; - } else - { - bb = x->x_curseg->s_bb; dy = target - x->x_value; - } x->x_nsegs--; x->x_curseg++; --- 125,135 ---- target = x->x_curseg->s_target; delta = x->x_curseg->s_delta; ! nhops = x->x_curseg->s_nhops; ! bb = x->x_curseg->s_bb; mm = x->x_curseg->s_mm; if (x->x_curseg->s_ccinput < 0) dy = x->x_value - target; else dy = target - x->x_value; x->x_nsegs--; x->x_curseg++; *************** *** 229,233 **** } } ! nxfer = x->x_nleft = npoints; x->x_vv = vv = bb; x->x_bb = bb; --- 147,151 ---- } } ! nxfer = x->x_nleft = nhops; x->x_vv = vv = bb; x->x_bb = bb; *************** *** 238,242 **** x->x_retarget = 0; #ifdef CURVE_DEBUG ! x->dbg_npoints = npoints; #endif } --- 156,160 ---- x->x_retarget = 0; #ifdef CURVE_DEBUG ! x->dbg_nhops = nhops; #endif } *************** *** 423,433 **** static void *curve_new(t_floatarg f1, t_floatarg f2) { - static int initialized = 0; t_curve *x = (t_curve *)pd_new(curve_class); - if (!initialized) - { - curve_coef = CURVE_C2 / exp(CURVE_C3); - initialized = 1; - } x->x_value = x->x_target = f1; x->x_ccinput = f2; --- 341,345 ----
Index: Makefile.objects =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/cyclone/sickle/Makefile.objects,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile.objects 19 Sep 2003 12:19:32 -0000 1.2 --- Makefile.objects 8 Dec 2004 15:40:12 -0000 1.3 *************** *** 6,9 **** --- 6,11 ---- common/grow.o \ common/vefl.o \ + common/clc.o \ + common/lex.o \ common/binport.o \ common/port.o \
Index: sickle.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/cyclone/sickle/sickle.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sickle.c 11 Sep 2003 09:04:32 -0000 1.2 --- sickle.c 8 Dec 2004 15:40:12 -0000 1.3 *************** *** 1,3 **** ! /* Copyright (c) 2002-2003 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ --- 1,3 ---- ! /* Copyright (c) 2002-2004 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ *************** *** 77,80 **** --- 77,85 ---- return; } + if (zgetfn(&pd_objectmaker, gensym("sickle"))) + { + loud_error(0, "sickle is already loaded"); + return; + } if (!zgetfn(&pd_objectmaker, gensym("cyclone"))) post("this is sickle %s, %s %s build",
Index: buffir.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/cyclone/sickle/buffir.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** buffir.c 5 Sep 2003 10:03:46 -0000 1.1 --- buffir.c 8 Dec 2004 15:40:12 -0000 1.2 *************** *** 39,47 **** int newsize, pos = x->x_lohead - x->x_histlo; int oldbytes = x->x_histsize * sizeof(*x->x_histlo); ! static int warned = 0; ! if (!warned) { ! loud_incompatible(buffir_class, "stretching history buffer"); ! warned = 1; } newsize = x->x_histsize * 2; --- 39,50 ---- int newsize, pos = x->x_lohead - x->x_histlo; int oldbytes = x->x_histsize * sizeof(*x->x_histlo); ! if (shared_getmaxcompatibility()) { ! static int warned = 0; ! if (!warned) ! { ! loud_incompatible(buffir_class, "stretching history buffer"); ! warned = 1; ! } } newsize = x->x_histsize * 2; *************** *** 195,198 **** --- 198,202 ---- buffir_clear(x); buffir_setrange(x, f1, f2); + shared_usecompatibility(); } return (x);