From d41e58e6cd71fdacdca69ba78c29d42dc7d330d5 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 20 Nov 2002 17:46:33 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r224, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/maxlib/; revision=225 --- src/listfunnel.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/listfunnel.c (limited to 'src/listfunnel.c') diff --git a/src/listfunnel.c b/src/listfunnel.c new file mode 100644 index 0000000..bd47665 --- /dev/null +++ b/src/listfunnel.c @@ -0,0 +1,82 @@ +/* ------------------------- listfunnel ------------------------------------- */ +/* */ +/* Convert list into two-element lists with source index. */ +/* Written by Olaf Matthes (olaf.matthes@gmx.de) */ +/* Get source at http://www.akustische-kunst.org/puredata/maxlib/ */ +/* */ +/* This program is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version 2 */ +/* of the License, or (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* */ +/* Based on PureData by Miller Puckette and others. */ +/* */ +/* ---------------------------------------------------------------------------- */ + +#include "m_pd.h" +#include +#include + +static char *version = "listfunnel v0.1, written by Olaf Matthes "; + +typedef struct listfunnel +{ + t_object x_ob; + t_outlet *x_outlet; /* result */ +} t_listfunnel; + +static void listfunnel_list(t_listfunnel *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom list[2]; + + for(i = 0; i < argc; i++) + { + SETFLOAT(list, i); + list[1] = argv[i]; // SETFLOAT(list+1, atom_getfloatarg(i, argc, argv)); + outlet_list(x->x_outlet, NULL, 2, list); + } +} + +static void listfunnel_float(t_listfunnel *x, t_floatarg f) +{ + t_atom list[2]; + + SETFLOAT(list, 0); + SETFLOAT(list+1, f); + outlet_list(x->x_outlet, NULL, 2, list); +} + +static t_class *listfunnel_class; + +static void *listfunnel_new(void) +{ + int i; + + t_listfunnel *x = (t_listfunnel *)pd_new(listfunnel_class); + x->x_outlet = outlet_new(&x->x_ob, gensym("float")); + +#ifndef MAXLIB + post(version); +#endif + return (void *)x; +} + +void listfunnel_setup(void) +{ + listfunnel_class = class_new(gensym("listfunnel"), (t_newmethod)listfunnel_new, + 0, sizeof(t_listfunnel), 0, 0, 0); + class_addfloat(listfunnel_class, listfunnel_float); + class_addlist(listfunnel_class, listfunnel_list); + class_sethelpsymbol(listfunnel_class, gensym("maxlib/help-listfunnel.pd")); +} + -- cgit v1.2.1