commit bd861c4e7af4398ec6472f4855e87cc01e0aea74 from: Sven M. Hallberg date: Mon Oct 23 15:21:31 2023 UTC add raised inverted cosine (ric) shape This is the sigmoid function (1 - cos(pi t)) / 2. Also rename "icos" to "cos" to avoid confusion. commit - 722fc85f05ae31a6d84079104fb5b93dafa1a243 commit + bd861c4e7af4398ec6472f4855e87cc01e0aea74 blob - 3f21008a02ae9a02df856b627a7a27d51da7faa5 blob + b1a1a579da6402e4aa92a262b573481040e38dc1 --- cw.c +++ cw.c @@ -37,7 +37,8 @@ struct shape { const char *name; rampfun_t *fun; } sha { "lin", ramp_lin }, /* linear ramp */ { "sqr", ramp_sqr }, /* square function (parabola) */ { "sin", ramp_sin }, /* quarter sine wave */ - { "icos", ramp_icos }, /* inverted cosine */ + { "cos", ramp_cos }, /* quarter cosine wave */ + { "ric", ramp_ric }, /* raised inverted cosine (sigmoid half wave) */ { "exp", ramp_exp }, /* exponential ramp */ { NULL, NULL } }; @@ -103,12 +104,18 @@ ramp_sin(double k) } double -ramp_icos(double k) +ramp_cos(double k) { return 1 - cos(M_PI_2 * k); } double +ramp_ric(double k) +{ + return (1 - cos(M_PI * k)) / 2; +} + +double ramp_exp(double k) { return exp(1 - 1 / k); blob - a93e9bd903c317a83707d0cdf8113abc5f9409b6 blob + 2d3d791bba1a28abbb2bbd1057c0f377f037a8f0 --- cw.h +++ cw.h @@ -3,7 +3,7 @@ /* envelope shapes - ramp functions (0, 1) -> (0, 1) */ typedef double rampfun_t(double); -rampfun_t ramp_lin, ramp_sqr, ramp_sin, ramp_icos, ramp_exp; +rampfun_t ramp_lin, ramp_sqr, ramp_sin, ramp_cos, ramp_ric, ramp_exp; void cwinit(void); void cwstart(void);