aboutsummaryrefslogtreecommitdiff
path: root/src/tab_sum.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tab_sum.c')
-rw-r--r--src/tab_sum.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/tab_sum.c b/src/tab_sum.c
index 9f41733..8054803 100644
--- a/src/tab_sum.c
+++ b/src/tab_sum.c
@@ -1,20 +1,23 @@
/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */
+iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 */
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
/* -------------------------- tab_sum ------------------------------ */
+/* sum = 0.0f; */
+/* for(i=0; i<x_size_src1; i++) */
+/* sum += x_beg_mem_src1[i]; */
typedef struct _tab_sum
{
t_object x_obj;
int x_size_src1;
int x_offset_src1;
- t_float *x_beg_mem_src1;
+ iemarray_t *x_beg_mem_src1;
t_symbol *x_sym_scr1;
void *x_bang_out;
void *x_sum_out;
@@ -31,7 +34,7 @@ static void tab_sum_bang(t_tab_sum *x)
{
int i, n;
int ok_src;
- t_float *vec_src;
+ iemarray_t *vec_src;
t_float sum=0.0f;
ok_src = iem_tab_check_arrays(gensym("tab_sum"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
@@ -43,9 +46,7 @@ static void tab_sum_bang(t_tab_sum *x)
if(n)
{
for(i=0; i<n; i++)
- {
- sum += vec_src[i];
- }
+ sum += iemarray_getfloat(vec_src, i);
outlet_float(x->x_sum_out, sum);
outlet_bang(x->x_bang_out);
}
@@ -57,7 +58,7 @@ static void tab_sum_list(t_tab_sum *x, t_symbol *s, int argc, t_atom *argv)
int beg_src;
int i, n;
int ok_src;
- t_float *vec_src;
+ iemarray_t *vec_src;
t_float sum=0.0f;
if((argc >= 2) &&
@@ -79,9 +80,7 @@ static void tab_sum_list(t_tab_sum *x, t_symbol *s, int argc, t_atom *argv)
if(n)
{
for(i=0; i<n; i++)
- {
- sum += vec_src[i];
- }
+ sum += iemarray_getfloat(vec_src, i);
outlet_float(x->x_sum_out, sum);
outlet_bang(x->x_bang_out);
}