diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2005-11-28 16:53:25 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2005-11-28 16:53:25 +0000 |
commit | da1f0065d07250b86b9a761b012987e4825f491f (patch) | |
tree | 6e048a70f8d60e2fdf9d374ec536cab9df10e24a /source/vmax.c |
This commit was generated by cvs2svn to compensate for changes in r4068,svn2git-root
which included commits to RCS files with non-trunk default branches.
svn path=/trunk/externals/smlib/; revision=4069
Diffstat (limited to 'source/vmax.c')
-rw-r--r-- | source/vmax.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/source/vmax.c b/source/vmax.c new file mode 100644 index 0000000..ac56423 --- /dev/null +++ b/source/vmax.c @@ -0,0 +1,52 @@ +#include "defines.h"
+
+/*--------------- vmax ---------------*/
+/* maximum value in a list of float
+ and its location (index)
+*/
+
+static t_class *vmax_class;
+
+typedef struct _vmax
+{
+ t_object x_obj;
+ t_outlet *m_out_maxi;
+} t_vmax;
+
+
+static void vmax_perform(t_vmax *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i;
+ int maxi;
+ float max=-MAXFLOAT;
+ for (i = 0; i < argc; i++)
+ {
+ float f=atom_getfloat(&argv[i]);
+ if (f>max)
+ {
+ max=f;
+ maxi=i;
+ }
+ }
+ outlet_float(x->x_obj.ob_outlet, max);
+ outlet_float(x->m_out_maxi, (float)(maxi+1));
+}
+
+static void *vmax_new( t_float halfDecayTime)
+{
+ t_vmax *x=(t_vmax *)pd_new(vmax_class);
+ outlet_new(&x->x_obj, gensym("float"));
+ x->m_out_maxi=outlet_new(&x->x_obj, gensym("float"));
+ return (void *)x;
+}
+
+void vmax_setup(void)
+{
+ vmax_class = class_new(gensym("vmax"),
+ (t_newmethod)vmax_new, 0,
+ sizeof(t_vmax),
+ CLASS_DEFAULT,
+ 0);
+ class_addlist(vmax_class, (t_method)vmax_perform);
+}
+
|