diff options
author | N.N. <krzyszcz@users.sourceforge.net> | 2003-08-14 14:32:00 +0000 |
---|---|---|
committer | N.N. <krzyszcz@users.sourceforge.net> | 2003-08-14 14:32:00 +0000 |
commit | a0f8c026117d1bbe094894d614136efea4b65c97 (patch) | |
tree | 26fe6a8efad5dddc42a5986084606fddbf1e057a /cyclone/sickle/sampstoms.c | |
parent | 053845e60bc1f6143e7c50aa10069a18405c2161 (diff) |
10 new sickle classes
svn path=/trunk/externals/miXed/; revision=846
Diffstat (limited to 'cyclone/sickle/sampstoms.c')
-rw-r--r-- | cyclone/sickle/sampstoms.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/cyclone/sickle/sampstoms.c b/cyclone/sickle/sampstoms.c new file mode 100644 index 0000000..36b686c --- /dev/null +++ b/cyclone/sickle/sampstoms.c @@ -0,0 +1,55 @@ +/* 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. */ + +#include "m_pd.h" +#include "sickle/sic.h" + +typedef struct _sampstoms +{ + t_sic x_sic; + float x_rcpksr; + t_outlet *x_floatout; +} t_sampstoms; + +static t_class *sampstoms_class; + +static void sampstoms_float(t_sampstoms *x, t_float f) +{ + outlet_float(x->x_floatout, f * x->x_rcpksr); +} + +static t_int *sampstoms_perform(t_int *w) +{ + t_sampstoms *x = (t_sampstoms *)(w[1]); + int nblock = (int)(w[2]); + t_float *in = (t_float *)(w[3]); + t_float *out = (t_float *)(w[4]); + float rcpksr = x->x_rcpksr; + while (nblock--) *out++ = *in++ * rcpksr; + return (w + 5); +} + +static void sampstoms_dsp(t_sampstoms *x, t_signal **sp) +{ + x->x_rcpksr = 1000. / sp[0]->s_sr; + dsp_add(sampstoms_perform, 4, x, + sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec); +} + +static void *sampstoms_new(void) +{ + t_sampstoms *x = (t_sampstoms *)pd_new(sampstoms_class); + x->x_rcpksr = 1000. / sys_getsr(); /* LATER rethink */ + outlet_new((t_object *)x, &s_signal); + x->x_floatout = outlet_new((t_object *)x, &s_float); + return (x); +} + +void sampstoms_tilde_setup(void) +{ + sampstoms_class = class_new(gensym("sampstoms~"), + (t_newmethod)sampstoms_new, 0, + sizeof(t_sampstoms), 0, 0); + sic_setup(sampstoms_class, sampstoms_dsp, sampstoms_float); +} |