diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2010-02-10 00:34:05 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2010-02-10 00:34:05 +0000 |
commit | 086e6b358ad45bda0e6a948cfb7ea2d33ab7da5a (patch) | |
tree | b87b0adfbfd8f9b9439d8bf528b63b64f23dce03 /vfmod.c | |
parent | 98e3e1214cf71a62b2de938c9c7e07f6bdd0090c (diff) |
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
Diffstat (limited to 'vfmod.c')
-rw-r--r-- | vfmod.c | 57 |
1 files changed, 57 insertions, 0 deletions
@@ -0,0 +1,57 @@ +#include "defines.h"
+
+/*--------------- vfmod ----------------*/
+/* floating point modulo of a vector */
+
+
+static t_class *vfmod_class;
+
+typedef struct _vfmod
+{
+ t_object x_obj;
+ float m_y;
+} t_vfmod;
+
+
+static void vfmod_perform(t_vfmod *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i;
+ float y;
+ t_atom *ap,*app;
+ ap = (t_atom *)getbytes(sizeof(t_atom)*argc);
+ app=ap;
+ y=x->m_y;
+ if (y==0.0f)
+ y=1.0f;
+ for (i = 0; i < argc; i++)
+ {
+ SETFLOAT(app, (float)fmod(atom_getfloat(argv++),y));
+ app++;
+ }
+ outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap);
+ freebytes(ap,argc);
+}
+
+static void *vfmod_new(t_float y)
+{
+ t_vfmod *x=(t_vfmod *)pd_new(vfmod_class);
+
+ floatinlet_new(&x->x_obj, &x->m_y);
+
+ outlet_new(&x->x_obj, gensym("list"));
+ if (y==0.0f)
+ y=1.0f;
+ x->m_y=y;
+ return (void *)x;
+}
+
+void vfmod_setup(void)
+{
+ vfmod_class = class_new(gensym("vfmod"),
+ (t_newmethod)vfmod_new, 0,
+ sizeof(t_vfmod),
+ CLASS_DEFAULT,
+ A_DEFFLOAT,A_DEFFLOAT,0);
+ class_addlist(vfmod_class, (t_method)vfmod_perform);
+}
+
|