diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2004-05-18 21:33:33 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2004-05-18 21:33:33 +0000 |
commit | 577ac6e80ff4f436fbd054291ed7dddbc31bd49a (patch) | |
tree | 6ec69b216dda68d7de38a5eba1851b9d4f1431e6 /src/iemlib1/sigiem_pow4.c |
This commit was generated by cvs2svn to compensate for changes in r1738,svn2git-root
which included commits to RCS files with non-trunk default branches.
svn path=/trunk/externals/iemlib/; revision=1739
Diffstat (limited to 'src/iemlib1/sigiem_pow4.c')
-rw-r--r-- | src/iemlib1/sigiem_pow4.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/iemlib1/sigiem_pow4.c b/src/iemlib1/sigiem_pow4.c new file mode 100644 index 0000000..ae5334c --- /dev/null +++ b/src/iemlib1/sigiem_pow4.c @@ -0,0 +1,86 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2003 */ + +#ifdef NT +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + + +#include "m_pd.h" +#include "iemlib.h" +#include <math.h> +#include <stdio.h> +#include <string.h> + +/* ------------------------ iem_pow4~ ----------------------------- */ + +static t_class *sigiem_pow4_class; + +typedef struct _sigiem_pow4 +{ + t_object x_obj; + float x_exp; + float x_msi; +} t_sigiem_pow4; + +static void sigiem_pow4_ft1(t_sigiem_pow4 *x, t_floatarg f) +{ + x->x_exp = f; +} + +static t_int *sigiem_pow4_perform(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[2]); + t_sigiem_pow4 *x = (t_sigiem_pow4 *)(w[3]); + t_float y=x->x_exp; + t_float f, g; + int n = (int)(w[4])/4; + + while (n--) + { + f = *in; + if(f < 0.01f) + f = 0.01f; + else if(f > 1000.0f) + f = 1000.0f; + g = log(f); + f = exp(g*y); + *out++ = f; + *out++ = f; + *out++ = f; + *out++ = f; + in += 4; + } + return (w+5); +} + +static void sigiem_pow4_dsp(t_sigiem_pow4 *x, t_signal **sp) +{ + dsp_add(sigiem_pow4_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); +} + +static void *sigiem_pow4_new(t_floatarg f) +{ + t_sigiem_pow4 *x = (t_sigiem_pow4 *)pd_new(sigiem_pow4_class); + + x->x_exp = f; + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); + outlet_new(&x->x_obj, gensym("signal")); + x->x_msi = 0; + return (x); +} + +void sigiem_pow4_setup(void) +{ + sigiem_pow4_class = class_new(gensym("iem_pow4~"), (t_newmethod)sigiem_pow4_new, 0, + sizeof(t_sigiem_pow4), 0, A_DEFFLOAT, 0); + class_addcreator((t_newmethod)sigiem_pow4_new, gensym("icot~"), 0); + CLASS_MAINSIGNALIN(sigiem_pow4_class, t_sigiem_pow4, x_msi); + class_addmethod(sigiem_pow4_class, (t_method)sigiem_pow4_dsp, gensym("dsp"), 0); + class_addmethod(sigiem_pow4_class, (t_method)sigiem_pow4_ft1, gensym("ft1"), A_FLOAT, 0); + class_sethelpsymbol(sigiem_pow4_class, gensym("iemhelp/help-iem_pow4~")); +} |