From da1f0065d07250b86b9a761b012987e4825f491f Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 28 Nov 2005 16:53:25 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r4068, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/smlib/; revision=4069 --- source/vnmax.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 source/vnmax.c (limited to 'source/vnmax.c') diff --git a/source/vnmax.c b/source/vnmax.c new file mode 100644 index 0000000..7003f6d --- /dev/null +++ b/source/vnmax.c @@ -0,0 +1,55 @@ +#include "defines.h" + +/*--------------- vnmax ---------------*/ +/* maximum n values in a list of float + and their locations (indices) +*/ + +//// UNCOMPLETE + + +static t_class *vnmax_class; + +typedef struct _vnmax +{ + t_object x_obj; + t_outlet *m_out_maxi; +} t_vnmax; + + +static void vnmax_perform(t_vnmax *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 *vnmax_new( t_float halfDecayTime) +{ + t_vnmax *x=(t_vnmax *)pd_new(vnmax_class); + outlet_new(&x->x_obj, gensym("list")); + x->m_out_maxi=outlet_new(&x->x_obj, gensym("list")); + return (void *)x; +} + +void vnmax_setup(void) +{ + vnmax_class = class_new(gensym("vnmax"), + (t_newmethod)vnmax_new, 0, + sizeof(t_vnmax), + CLASS_DEFAULT, + 0); + class_addlist(vnmax_class, (t_method)vnmax_perform); +} + -- cgit v1.2.1