From 79096fd626b946efd6947fa94ab15d30bf003ba0 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 19 Aug 2010 05:04:28 +0000 Subject: converted to new library template and debianized svn path=/trunk/externals/ekext/; revision=13835 --- list_sum/list_sum-help.pd | 41 ----------- list_sum/list_sum.c | 179 ---------------------------------------------- list_sum/makefile | 105 --------------------------- 3 files changed, 325 deletions(-) delete mode 100644 list_sum/list_sum-help.pd delete mode 100644 list_sum/list_sum.c delete mode 100644 list_sum/makefile (limited to 'list_sum') diff --git a/list_sum/list_sum-help.pd b/list_sum/list_sum-help.pd deleted file mode 100644 index 7259add..0000000 --- a/list_sum/list_sum-help.pd +++ /dev/null @@ -1,41 +0,0 @@ -#N canvas 0 0 707 528 10; -#X obj 84 255 list_sum; -#X floatatom 101 358 0 0 0 3 length - -; -#X floatatom 84 391 0 0 0 3 total - -; -#X msg 150 82 set 2 100; -#X msg 149 98 set 2 498; -#X msg 32 106 clear; -#X msg 149 121 set 5 777; -#X text 215 81 individual elements can be set; -#X text 206 286 list_sum; -#X text 205 327 Edward Kelly 2007; -#X msg 84 55 all 200.5 498 166.3 81.7 94.4; -#X text 84 36 all in the left inlet calculates the sum of its elements. -; -#X msg 173 145 3; -#X msg 173 162 9; -#X msg 211 162 4; -#X msg 211 179 8; -#X text 200 144 max length; -#X text 241 162 wrap value; -#X obj 300 116 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X obj 331 116 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 --1; -#X text 206 301 calculate the sum of elements in a list \, wrapping -the list.; -#X connect 0 0 2 0; -#X connect 0 1 1 0; -#X connect 3 0 0 0; -#X connect 4 0 0 0; -#X connect 5 0 0 0; -#X connect 6 0 0 0; -#X connect 10 0 0 0; -#X connect 12 0 0 1; -#X connect 13 0 0 1; -#X connect 14 0 0 2; -#X connect 15 0 0 2; -#X connect 18 0 13 0; -#X connect 18 0 14 0; -#X connect 19 0 12 0; -#X connect 19 0 15 0; diff --git a/list_sum/list_sum.c b/list_sum/list_sum.c deleted file mode 100644 index fd0d21d..0000000 --- a/list_sum/list_sum.c +++ /dev/null @@ -1,179 +0,0 @@ -/* list_sum - total sum of list values, with setting on each element independently - * Copyright (C) 2007 Edward Kelly - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "m_pd.h" - -static t_class *list_sum_class; - -typedef struct _contents -{ - t_atom list[1024]; -} t_contents; - -typedef struct _list_sum -{ - t_object x_obj; - t_contents contents; - t_float total, highest, maxlen, wrap, reset, accum, remainder, firsttime; - t_outlet *sum, *length; /*, *remains, *diff;*/ -} t_list_sum; - -void list_sum_all(t_list_sum *x, t_symbol *s, int argc, t_atom *argv) -{ - argc = argc < 1024 ? argc : 1024; - int i, j, maxindex; - float current; - x->total = 0; - maxindex = argc > x->maxlen ? x->maxlen-1 : argc-1; - for(i=0;icontents.list[i], current); - if(i<=maxindex) - { - x->total += current; - } - else if (i > maxindex && x->wrap > x->maxlen && i < x->wrap) - { - j = i % (int)x->maxlen; - current = atom_getfloat(argv+j); - x->total += current; - } - } - x->highest = (float)argc-1; - outlet_float(x->length, (float)argc); - outlet_float(x->sum, x->total); -} - -void list_sum_set(t_list_sum *x, t_floatarg element, t_floatarg value) -{ - int i, j, indx, top; - float current; - if(element < 1024) - { - x->total = 0; - float f_indx = element-1; - indx = (int)f_indx; - x->highest = f_indx > x->highest ? f_indx : x->highest; - if(x->wrap <= x->maxlen) - { - top = x->highest >= x->maxlen ? x->maxlen : x->highest + 1; - } - else - { - top = x->highest >= x->wrap ? x->wrap : x->highest + 1; - } - SETFLOAT(&x->contents.list[indx], value); - for(i=0;imaxlen) - { - current = atom_getfloatarg(i, 1024, x->contents.list); - x->total += current; - } - else - { - j = i % (int)x->maxlen; - current = atom_getfloatarg(j, 1024, x->contents.list); - x->total += current; - } - } - outlet_float(x->length, x->highest+1); - outlet_float(x->sum, x->total); - } -} - -//next: list_sum_follow - clock based? -//void list_sum_follow(t_list_sum *x, t_symbol *s, t_floatarg index, t_floatarg value) -//{ -// int i = (int) index; -// if(index == (int)x->reset || x->firsttime == 1) -// { -// x->accum = 0; -// x->remainder = x->total; -// x->firsttime = 0; -// } -// float current = atom_getfloatarg(i, 1024, x->contents.list); -// float diff = value - current; -// x->accum += diff; -// outlet_float(x->diff, x->accum); -// x->remainder -=current; -// outlet_float(x->remains, x->remainder); -//} - - -void list_sum_clear(t_list_sum *x) -{ - int i; - for(i=0;i<1024;i++) - { - SETFLOAT(&x->contents.list[i], 0); - } - x->highest=0; - x->total=0; -} - -void list_sum_print(t_list_sum *x) -{ - int i; - float element; - for(i=0;i<=x->highest;i++) - { - element = atom_getfloatarg(i, 1024, x->contents.list); - post("%d ", element); - } -} - -void *list_sum_new(t_symbol *s, int argc, t_atom *argv) -{ - int i; - t_list_sum *x = (t_list_sum *)pd_new(list_sum_class); - x->total = 0; - x->highest = 0; - x->maxlen = 1024; - x->wrap = 1024; - x->reset = 16; - x->firsttime = 1; - for(i=0;i<1024;i++) - { - SETFLOAT(&x->contents.list[i], 0); - } - floatinlet_new(&x->x_obj, &x->maxlen); - floatinlet_new(&x->x_obj, &x->wrap); - // floatinlet_new(&x->x_obj, &x->reset); - x->sum = outlet_new(&x->x_obj, &s_float); - x->length = outlet_new(&x->x_obj, &s_float); - // x->remains = outlet_new(&x->x_obj, &s_float); - // x->diff = outlet_new(&x->x_obj, &s_float); - return (void *)x; -} - -void list_sum_setup(void) { - list_sum_class = class_new(gensym("list_sum"), - (t_newmethod)list_sum_new, - 0, sizeof(t_list_sum), - 0, A_DEFFLOAT, 0); - post("|<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>|"); - post("|<<>>|"); - post("|<<<<<<<<>>>>>>>>>|"); - - // class_addmethod(list_sum_class, (t_method)list_sum_follow, gensym("follow"), A_DEFFLOAT, A_DEFFLOAT, 0); - class_addmethod(list_sum_class, (t_method)list_sum_all, gensym("all"), A_GIMME, 0); - class_addmethod(list_sum_class, (t_method)list_sum_clear, gensym("clear"), A_DEFFLOAT, 0); - class_addmethod(list_sum_class, (t_method)list_sum_print, gensym("print"), A_DEFFLOAT, 0); - class_addmethod(list_sum_class, (t_method)list_sum_set, gensym("set"), A_DEFFLOAT, A_DEFFLOAT, 0); -} diff --git a/list_sum/makefile b/list_sum/makefile deleted file mode 100644 index 2575b4e..0000000 --- a/list_sum/makefile +++ /dev/null @@ -1,105 +0,0 @@ -current: - echo make pd_linux, pd_nt, pd_irix5, pd_irix6 or pd_darwin, then make install - -clean: ; rm -f *.pd_* *.o - -# ----------------------- NT ----------------------- - -pd_nt: list_sum.dll - -INSTALL_PREFIX="C:\pd\extra" -EXT=dll -.SUFFIXES: .obj .dll - -PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo -VC="D:\Program Files\Microsoft Visual Studio\Vc98" - -PDNTINCLUDE = /I. /I\tcl\include /I..\..\src /I$(VC)\include - -PDNTLDIR = $(VC)\lib -PDNTLIB = $(PDNTLDIR)\libc.lib \ - $(PDNTLDIR)\oldnames.lib \ - $(PDNTLDIR)\kernel32.lib \ - ..\..\bin\pd.lib - -.c.dll: - cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c - link /dll /export:$*_setup $*.obj $(PDNTLIB) - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix5: list_sum.pd_irix5 - -INSTALL_PREFIX=/usr/local -EXT=pd_irix5 -.SUFFIXES: .pd_irix5 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I/usr/local/include - -.c.pd_irix5: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o - rm $*.o - -# ----------------------- IRIX 5.x ----------------------- - -pd_irix6: list_sum.pd_irix6 - -INSTALL_PREFIX=/usr/local -EXT=pd_irix6 -.SUFFIXES: .pd_irix6 - -SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2 - -SGIINCLUDE = -I/usr/local/include - -.c.pd_irix6: - cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c - ld -elf -shared -rdata_shared -o $*.pd_irix6 $*.o - rm $*.o - -# ----------------------- LINUX i386 ----------------------- - -pd_linux: list_sum.pd_linux - -INSTALL_PREFIX=/usr/local -EXT=pd_linux -.SUFFIXES: .pd_linux - -LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer \ - -Wall -W -Wshadow -Wstrict-prototypes -Werror \ - -Wno-unused -Wno-parentheses -Wno-switch - -LINUXINCLUDE = -I/usr/local/include - -.c.pd_linux: - cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - ld --export-dynamic -shared -o $*.pd_linux $*.o -lc -lm - strip --strip-unneeded $*.pd_linux - rm $*.o - -# ----------------------- Mac OSX ----------------------- - -pd_darwin: list_sum.pd_darwin - -INSTALL_PREFIX=/usr/local -EXT=pd_darwin -.SUFFIXES: .pd_darwin - -DARWINCFLAGS = -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes \ - -Wno-unused -Wno-parentheses -Wno-switch - -.c.pd_darwin: - cc $(DARWINCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c - cc -bundle -undefined suppress -flat_namespace -o $*.pd_darwin $*.o - rm -f $*.o - -# ---------------------------------------------- - -install:: - install -d $(INSTALL_PREFIX)/lib/pd/extra -# install -m 644 *.$(EXT) $(INSTALL_PREFIX)/lib/pd/externs - -install -m 644 list_sum.$(EXT) $(INSTALL_PREFIX)/lib/pd/extra - install -m 644 *.pd $(INSTALL_PREFIX)/lib/pd/doc/5.reference -- cgit v1.2.1