From 086e6b358ad45bda0e6a948cfb7ea2d33ab7da5a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 10 Feb 2010 00:34:05 +0000 Subject: re-arranged into libdir and setup with the template Makefile+debian stuff. renabled vv+ and vv- as vvplus and vvminus svn path=/trunk/externals/smlib/; revision=13158 --- vclip.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 vclip.c (limited to 'vclip.c') diff --git a/vclip.c b/vclip.c new file mode 100644 index 0000000..4a11ef5 --- /dev/null +++ b/vclip.c @@ -0,0 +1,58 @@ +#include "defines.h" + +/*--------------- vclip ----------------*/ +/* clips a vector */ + + +static t_class *vclip_class; + +typedef struct _vclip +{ + t_object x_obj; + float m_lo; + float m_hi; +} t_vclip; + + +static void vclip_perform(t_vclip *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + float lo,hi; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + lo=x->m_lo; + hi=x->m_hi; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(argv++); + SETFLOAT(app, (fhi?hi:f))); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vclip_new(t_float lo, t_float hi) +{ + t_vclip *x=(t_vclip *)pd_new(vclip_class); + + floatinlet_new(&x->x_obj, &x->m_lo); + floatinlet_new(&x->x_obj, &x->m_hi); + + outlet_new(&x->x_obj, gensym("list")); + x->m_hi=hi; + x->m_lo=lo; + return (void *)x; +} + +void vclip_setup(void) +{ + vclip_class = class_new(gensym("vclip"), + (t_newmethod)vclip_new, 0, + sizeof(t_vclip), + CLASS_DEFAULT, + A_DEFFLOAT,A_DEFFLOAT,0); + class_addlist(vclip_class, (t_method)vclip_perform); +} + -- cgit v1.2.1