aboutsummaryrefslogtreecommitdiff
path: root/mean~.c
diff options
context:
space:
mode:
Diffstat (limited to 'mean~.c')
-rw-r--r--mean~.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/mean~.c b/mean~.c
index 223152a..f5a0481 100644
--- a/mean~.c
+++ b/mean~.c
@@ -19,7 +19,7 @@ typedef struct _cxmean
t_object x_obj;
t_symbol *x_arrayname;
t_float x_mean;
- float *x_vec;
+ t_word *x_vec;
t_float f;
int x_nsampsintab;
} t_cxmean;
@@ -44,7 +44,7 @@ static void cxmean_set(t_cxmean *x, t_symbol *s)
x->x_arrayname->s_name);
x->x_vec = 0;
}
- else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec))
+ else if (!garray_getfloatwords(a, &x->x_nsampsintab, &x->x_vec))
{
error("%s: bad template for mean~", x->x_arrayname->s_name);
x->x_vec = 0;
@@ -62,20 +62,21 @@ static void cxmean_mean(t_cxmean *x)
// t_float *bl;
t_garray *a;
int cnt;
- t_float *fp;
+ t_word *fp;
t_float xz = 0.;
cnt = 0;
if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) {
pd_error(x, "%s: no such table", x->x_arrayname->s_name);
}
- garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec);
+ garray_getfloatwords(a,&x->x_nsampsintab,&x->x_vec);
fp = x->x_vec;
while(cnt < x->x_nsampsintab) {
- //post("cxc/mean.c: %f",*fp++);
- xz += *fp++;
+ t_float f = fp++->w_float;
+ //post("cxc/mean.c: %f",f);
+ xz += f;
cnt++;
}
#ifdef DEBUG
@@ -118,7 +119,7 @@ typedef struct _cxavgdev
t_object x_obj;
t_symbol *x_arrayname;
t_float x_avgdev;
- float *x_vec;
+ t_word *x_vec;
t_float f;
int x_nsampsintab;
} t_cxavgdev;
@@ -143,7 +144,7 @@ static void cxavgdev_set(t_cxavgdev *x, t_symbol *s)
x->x_arrayname->s_name);
x->x_vec = 0;
}
- else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec))
+ else if (!garray_getfloatwords(a, &x->x_nsampsintab, &x->x_vec))
{
error("%s: bad template for mean~", x->x_arrayname->s_name);
x->x_vec = 0;
@@ -161,7 +162,7 @@ static void cxavgdev_float(t_cxavgdev *x, t_float f)
// t_float *bl;
t_garray *a;
int cnt;
- t_float *fp;
+ t_word *fp;
t_float xz = 0.;
t_float tz = 0.;
@@ -169,12 +170,12 @@ static void cxavgdev_float(t_cxavgdev *x, t_float f)
if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) {
pd_error(x, "%s: no such table", x->x_arrayname->s_name);
}
- garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec);
+ garray_getfloatwords(a,&x->x_nsampsintab,&x->x_vec);
fp = x->x_vec;
while(cnt < x->x_nsampsintab) {
- tz = *fp++;
+ tz = fp++->w_float;
tz = fabs(tz - f);
xz += tz;
#ifdef DEBUG
@@ -222,7 +223,7 @@ typedef struct _cxstddev
t_object x_obj;
t_symbol *x_arrayname;
t_float x_stddev;
- float *x_vec;
+ t_word *x_vec;
t_float f;
int x_nsampsintab;
} t_cxstddev;
@@ -247,7 +248,7 @@ static void cxstddev_set(t_cxstddev *x, t_symbol *s)
x->x_arrayname->s_name);
x->x_vec = 0;
}
- else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec))
+ else if (!garray_getfloatwords(a, &x->x_nsampsintab, &x->x_vec))
{
error("%s: bad template for mean~", x->x_arrayname->s_name);
x->x_vec = 0;
@@ -265,7 +266,7 @@ static void cxstddev_float(t_cxstddev *x, t_float f)
// t_float *bl;
t_garray *a;
int cnt;
- t_float *fp;
+ t_word *fp;
t_float xz = 0.;
t_float tz = 0.;
@@ -273,12 +274,12 @@ static void cxstddev_float(t_cxstddev *x, t_float f)
if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) {
pd_error(x, "%s: no such table", x->x_arrayname->s_name);
}
- garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec);
+ garray_getfloatwords(a,&x->x_nsampsintab,&x->x_vec);
fp = x->x_vec;
while(cnt < x->x_nsampsintab) {
- tz = *fp++;
+ tz = fp++->w_float;
tz = pow(tz - f,2); // power of 2
xz += tz;
#ifdef DEBUG
@@ -323,7 +324,7 @@ typedef struct _mean_tilde
t_object x_obj;
t_symbol *x_arrayname;
t_float x_mean;
- float *x_vec;
+ t_word *x_vec;
t_float f;
int x_nsampsintab;
} t_mean_tilde;
@@ -341,14 +342,13 @@ static t_int *mean_tilde_perform(t_int *w)
{
t_mean_tilde *x = (t_mean_tilde *)(w[1]);
//t_float *out = (t_float *)(w[3]),
- t_float *fp;
//// t_float *in = (t_float *)(w[2]);
//// *out = *in;
int n = (int)(w[2]);
t_float xz = 0.;
- fp = x->x_vec;
+ t_word * fp = x->x_vec;
while(n--) {
- xz += abs(*fp++);
+ xz += abs(fp++->w_float);
//post("cxc/mean.c: %d : %f : %f",n,xz,fp);
}
x->x_mean = (t_float)(xz / n);
@@ -368,7 +368,7 @@ static void mean_tilde_set(t_mean_tilde *x, t_symbol *s)
x->x_arrayname->s_name);
x->x_vec = 0;
}
- else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec))
+ else if (!garray_getfloatwords(a, &x->x_nsampsintab, &x->x_vec))
{
error("%s: bad template for mean~", x->x_arrayname->s_name);
x->x_vec = 0;
@@ -394,20 +394,20 @@ static void mean_tilde_mean(t_mean_tilde *x)
// t_float *bl;
t_garray *a;
int cnt;
- t_float *fp;
+ t_word *fp;
t_float xz = 0.;
cnt = 0;
if(!(a = (t_garray *)pd_findbyclass(x->x_arrayname,garray_class))) {
pd_error(x, "%s: no such table", x->x_arrayname->s_name);
}
- garray_getfloatarray(a,&x->x_nsampsintab,&x->x_vec);
+ garray_getfloatwords(a,&x->x_nsampsintab,&x->x_vec);
fp = x->x_vec;
while(cnt < x->x_nsampsintab) {
//post("cxc/mean.c: %f",*fp++);
- xz += *fp++;
+ xz += fp++->w_float;
cnt++;
}
#ifdef DEBUG