Commit 9705e683 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

port garray_resize_long from Pd Vanilla

Pd Vanilla commit 98b4959f03f0fd9acfd7c117d8061589504c89e6
parent ae8549ea
......@@ -1283,7 +1283,7 @@ static void soundfiler_read(t_soundfiler *x, t_symbol *s,
{
int vecsize;
garray_resize(garrays[i], finalsize);
garray_resize_long(garrays[i], finalsize);
/* for sanity's sake let's clear the save-in-patch flag here */
garray_setsaveit(garrays[i], 0);
garray_getfloatwords(garrays[i], &vecsize,
......
......@@ -698,7 +698,7 @@ void garray_arraydialog(t_garray *x, t_symbol *s, int argc, t_atom *argv)
template_findbyname(x->x_scalar->sc_template),
gensym("style"), x->x_scalar->sc_vec, 1);*/
int size;
long size;
t_symbol *argname = sharptodollar(name);
t_array *a = garray_getarray(x);
t_template *scalartemplate;
......@@ -757,7 +757,7 @@ void garray_arraydialog(t_garray *x, t_symbol *s, int argc, t_atom *argv)
x->x_style = style;
if (size != a->a_n)
{
garray_resize(x, size);
garray_resize_long(x, size);
}
else
{
......@@ -1680,7 +1680,7 @@ static void garray_const(t_garray *x, t_floatarg g)
}
/* sum of Fourier components; called from routines below */
static void garray_dofo(t_garray *x, int npoints, t_float dcval,
static void garray_dofo(t_garray *x, long npoints, t_float dcval,
int nsin, t_float *vsin, int sineflag)
{
double phase, phaseincr, fj;
......@@ -1696,7 +1696,7 @@ static void garray_dofo(t_garray *x, int npoints, t_float dcval,
if (npoints != (1 << ilog2(npoints)))
post("%s: rounding to %d points", array->a_templatesym->s_name,
(npoints = (1<<ilog2(npoints))));
garray_resize(x, npoints + 3);
garray_resize_long(x, npoints + 3);
phaseincr = 2. * 3.14159 / npoints;
for (i = 0, phase = -phaseincr; i < array->a_n; i++, phase += phaseincr)
{
......@@ -1716,7 +1716,8 @@ static void garray_dofo(t_garray *x, int npoints, t_float dcval,
static void garray_sinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv)
{
t_float *svec;
int npoints, i;
long npoints;
int i;
if (argc < 2)
{
error("sinesum: %s: need number of points and partial strengths",
......@@ -1739,7 +1740,8 @@ static void garray_sinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv)
static void garray_cosinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv)
{
t_float *svec;
int npoints, i;
long npoints;
int i;
if (argc < 2)
{
error("sinesum: %s: need number of points and partial strengths",
......@@ -1956,10 +1958,11 @@ int garray_ambigendian(void)
return (c==0);
}
void garray_resize(t_garray *x, t_floatarg f)
void garray_resize_long(t_garray *x, long n)
{
t_array *array = garray_getarray(x);
int n = (f < 1 ? 1 : f);
if (n < 1)
n = 1;
//fprintf(stderr,"garray_resize %d\n", n);
array_resize(array, n);
garray_fittograph(x, n, 1);/*template_getfloat(
......@@ -1970,6 +1973,12 @@ void garray_resize(t_garray *x, t_floatarg f)
canvas_update_dsp();
}
/* float version to use as Pd method */
void garray_resize(t_garray *x, t_floatarg f)
{
garray_resize_long(x, f);
}
static void garray_print(t_garray *x)
{
t_array *array = garray_getarray(x);
......
......@@ -673,7 +673,8 @@ EXTERN t_float garray_get(t_garray *x, t_symbol *s, t_int indx);
EXTERN void garray_redraw(t_garray *x);
EXTERN int garray_npoints(t_garray *x);
EXTERN char *garray_vec(t_garray *x);
EXTERN void garray_resize(t_garray *x, t_floatarg f);
EXTERN void garray_resize(t_garray *x, t_floatarg f); /* avoid; use this: */
EXTERN void garray_resize_long(t_garray *x, long n); /* better version */
EXTERN void garray_usedindsp(t_garray *x);
EXTERN void garray_setsaveit(t_garray *x, int saveit);
EXTERN t_glist *garray_getglist(t_garray *x);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment