[PD-cvs] pd/src d_ugen.c,1.3.4.1.2.5.2.1,1.3.4.1.2.5.2.2
Mathieu Bouchard
matju at users.sourceforge.net
Fri Dec 8 08:23:31 CET 2006
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2630
Modified Files:
Tag: desiredata
d_ugen.c
Log Message:
0.40
Index: d_ugen.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/d_ugen.c,v
retrieving revision 1.3.4.1.2.5.2.1
retrieving revision 1.3.4.1.2.5.2.2
diff -C2 -d -r1.3.4.1.2.5.2.1 -r1.3.4.1.2.5.2.2
*** d_ugen.c 8 Dec 2006 04:46:18 -0000 1.3.4.1.2.5.2.1
--- d_ugen.c 8 Dec 2006 07:23:28 -0000 1.3.4.1.2.5.2.2
***************
*** 32,47 ****
t_sample *obj_findsignalscalar(t_object *x, int m);
static int ugen_loud;
EXTERN_STRUCT _vinlet;
EXTERN_STRUCT _voutlet;
void vinlet_dspprolog(struct _vinlet *x, t_signal **parentsigs,
! int myvecsize, int phase, int period, int frequency, int downsample, int upsample /* IOhannes */, int reblock,
! int switched);
void voutlet_dspprolog(struct _voutlet *x, t_signal **parentsigs,
! int myvecsize, int phase, int period, int frequency, int downsample, int upsample /* IOhannes */, int reblock,
! int switched);
void voutlet_dspepilog(struct _voutlet *x, t_signal **parentsigs,
! int myvecsize, int phase, int period, int frequency, int downsample, int upsample /* IOhannes */, int reblock,
! int switched);
t_int *zero_perform(t_int *w) /* zero out a vector */
--- 32,49 ----
t_sample *obj_findsignalscalar(t_object *x, int m);
static int ugen_loud;
+ static t_int *dsp_chain;
+ static int dsp_chainsize;
EXTERN_STRUCT _vinlet;
EXTERN_STRUCT _voutlet;
void vinlet_dspprolog(struct _vinlet *x, t_signal **parentsigs,
! int myvecsize, int calcsize, int phase, int period, int frequency,
! int downsample, int upsample, int reblock, int switched);
void voutlet_dspprolog(struct _voutlet *x, t_signal **parentsigs,
! int myvecsize, int calcsize, int phase, int period, int frequency,
! int downsample, int upsample, int reblock, int switched);
void voutlet_dspepilog(struct _voutlet *x, t_signal **parentsigs,
! int myvecsize, int calcsize, int phase, int period, int frequency,
! int downsample, int upsample, int reblock, int switched);
t_int *zero_perform(t_int *w) /* zero out a vector */
***************
*** 119,128 ****
{
t_object x_obj;
! int x_vecsize;
int x_overlap;
int x_phase; /* from 0 to period-1; when zero we run the block */
int x_period; /* submultiple of containing canvas */
int x_frequency; /* supermultiple of comtaining canvas */
! int x_count;
int x_blocklength; /* length of dspchain for this block */
int x_epiloglength; /* length of epilog */
--- 121,132 ----
{
t_object x_obj;
! int x_vecsize; /* size of audio signals in this block */
! int x_calcsize; /* number of samples actually to compute */
int x_overlap;
int x_phase; /* from 0 to period-1; when zero we run the block */
int x_period; /* submultiple of containing canvas */
int x_frequency; /* supermultiple of comtaining canvas */
! int x_count; /* number of times parent block has called us */
! int x_chainonset; /* beginning of code in DSP chain */
int x_blocklength; /* length of dspchain for this block */
int x_epiloglength; /* length of epilog */
***************
*** 132,136 ****
int x_upsample; /* IOhannes: upsampling-factor */
int x_downsample; /* IOhannes: downsampling-factor */
!
} t_block;
--- 136,140 ----
int x_upsample; /* IOhannes: upsampling-factor */
int x_downsample; /* IOhannes: downsampling-factor */
! int x_return; /* stop right after this block (for one-shots) */
} t_block;
***************
*** 138,142 ****
t_floatarg fupsample);
! static void *block_new(t_floatarg fvecsize, t_floatarg foverlap,
t_floatarg fupsample) /* IOhannes */
{
--- 142,146 ----
t_floatarg fupsample);
! static void *block_new(t_floatarg fcalcsize, t_floatarg foverlap,
t_floatarg fupsample) /* IOhannes */
{
***************
*** 147,165 ****
x->x_switched = 0;
x->x_switchon = 1;
! block_set(x, fvecsize, foverlap, fupsample);
return (x);
}
! static void block_set(t_block *x, t_floatarg fvecsize, t_floatarg foverlap,
t_floatarg fupsample)
{
int upsample, downsample; /* IOhannes */
! int vecsize = fvecsize;
int overlap = foverlap;
int dspstate = canvas_suspend_dsp();
if (overlap < 1)
overlap = 1;
! if (vecsize < 0)
! vecsize = 0; /* this means we'll get it from parent later. */
/* IOhannes { */
--- 151,170 ----
x->x_switched = 0;
x->x_switchon = 1;
! block_set(x, fcalcsize, foverlap, fupsample);
return (x);
}
! static void block_set(t_block *x, t_floatarg fcalcsize, t_floatarg foverlap,
t_floatarg fupsample)
{
int upsample, downsample; /* IOhannes */
! int calcsize = fcalcsize;
int overlap = foverlap;
int dspstate = canvas_suspend_dsp();
+ int vecsize;
if (overlap < 1)
overlap = 1;
! if (calcsize < 0)
! calcsize = 0; /* this means we'll get it from parent later. */
/* IOhannes { */
***************
*** 174,177 ****
--- 179,189 ----
/* } IOhannes */
+ /* vecsize is smallest power of 2 large enough to hold calcsize */
+ if (calcsize)
+ {
+ if ((vecsize = (1 << ilog2(calcsize))) != calcsize)
+ vecsize *= 2;
+ }
+ else vecsize = 0;
if (vecsize && (vecsize != (1 << ilog2(vecsize))))
{
***************
*** 198,201 ****
--- 210,214 ----
+ x->x_calcsize = calcsize;
x->x_vecsize = vecsize;
x->x_overlap = overlap;
***************
*** 221,224 ****
--- 234,252 ----
x->x_switchon = (f != 0);
}
+
+ static void block_bang(t_block *x)
+ {
+ if (x->x_switched && !x->x_switchon)
+ {
+ t_int *ip;
+ x->x_return = 1;
+ for (ip = dsp_chain + x->x_chainonset; ip; )
+ ip = (*(t_perfroutine)(*ip))(ip);
+ x->x_return = 0;
+ }
+ else pd_error(x, "bang to block~ or on-state switch~ has no effect");
+ }
+
+
#define PROLOGCALL 2
#define EPILOGCALL 2
***************
*** 250,253 ****
--- 278,283 ----
t_block *x = (t_block *)w[1];
int count = x->x_count - 1;
+ if (x->x_return)
+ return (0);
if (!x->x_reblock)
return (w + x->x_epiloglength + EPILOGCALL);
***************
*** 276,285 ****
class_addmethod(block_class, (t_method)block_dsp, gensym("dsp"), 0);
class_addfloat(block_class, block_float);
}
/* ------------------ DSP call list ----------------------- */
! static t_int *dsp_chain;
! static int dsp_chainsize;
void dsp_add(t_perfroutine f, int n, ...)
--- 306,318 ----
class_addmethod(block_class, (t_method)block_dsp, gensym("dsp"), 0);
class_addfloat(block_class, block_float);
+ class_addbang(block_class, block_bang);
}
/* ------------------ DSP call list ----------------------- */
! static t_int dsp_done(t_int *w)
! {
! return (0);
! }
void dsp_add(t_perfroutine f, int n, ...)
***************
*** 295,299 ****
dsp_chain[dsp_chainsize + i] = va_arg(ap, t_int);
va_end(ap);
! dsp_chain[newsize-1] = 0;
dsp_chainsize = newsize;
}
--- 328,332 ----
dsp_chain[dsp_chainsize + i] = va_arg(ap, t_int);
va_end(ap);
! dsp_chain[newsize-1] = (t_int)dsp_done;
dsp_chainsize = newsize;
}
***************
*** 309,313 ****
for (i = 0; i < n; i++)
dsp_chain[dsp_chainsize + i] = vec[i];
! dsp_chain[newsize-1] = 0;
dsp_chainsize = newsize;
}
--- 342,346 ----
for (i = 0; i < n; i++)
dsp_chain[dsp_chainsize + i] = vec[i];
! dsp_chain[newsize-1] = (t_int)dsp_done;
dsp_chainsize = newsize;
}
***************
*** 318,322 ****
{
t_int *ip;
! for (ip = dsp_chain; *ip; ) ip = (*(t_perfroutine)(*ip))(ip);
dsp_phase++;
}
--- 351,355 ----
{
t_int *ip;
! for (ip = dsp_chain; ip; ) ip = (*(t_perfroutine)(*ip))(ip);
dsp_phase++;
}
***************
*** 355,361 ****
{
#ifndef VECTORALIGNMENT
! t_freebytes(sig->s_vec, sig->s_n * sizeof (*sig->s_vec));
#else
! freealignedbytes(sig->s_vec, sig->s_n * sizeof (*sig->s_vec));
#endif
}
--- 388,394 ----
{
#ifndef VECTORALIGNMENT
! t_freebytes(sig->s_vec, sig->s_vecsize * sizeof (*sig->s_vec));
#else
! freealignedbytes(sig->s_vec, sig->s_vecsize * sizeof (*sig->s_vec));
#endif
}
***************
*** 370,374 ****
void signal_makereusable(t_signal *sig)
{
! int logn = ilog2(sig->s_n);
#if 1
t_signal *s5;
--- 403,407 ----
void signal_makereusable(t_signal *sig)
{
! int logn = ilog2(sig->s_vecsize);
#if 1
t_signal *s5;
***************
*** 420,424 ****
t_signal *signal_new(int n, float sr)
{
! int logn, n2;
t_signal *ret, **whichlist;
t_sample *fp;
--- 453,457 ----
t_signal *signal_new(int n, float sr)
{
! int logn, n2, vecsize = 0;
t_signal *ret, **whichlist;
t_sample *fp;
***************
*** 426,431 ****
if (n)
{
! if (n != (1 << logn))
! bug("signal buffer not a power of 2");
if (logn > MAXLOGSIG)
bug("signal buffer too large");
--- 459,464 ----
if (n)
{
! if ((vecsize = (1<<logn)) != n)
! vecsize *= 2;
if (logn > MAXLOGSIG)
bug("signal buffer too large");
***************
*** 445,452 ****
{
#ifndef VECTORALIGNMENT
! ret->s_vec = (t_sample *)getbytes(n * sizeof (*ret->s_vec));
#else
/* T.Grill - make signal vectors aligned! */
! ret->s_vec = (t_sample *)getalignedbytes(n * sizeof (*ret->s_vec));
#endif
ret->s_isborrowed = 0;
--- 478,485 ----
{
#ifndef VECTORALIGNMENT
! ret->s_vec = (t_sample *)getbytes(vecsize * sizeof (*ret->s_vec));
#else
/* T.Grill - make signal vectors aligned! */
! ret->s_vec = (t_sample *)getalignedbytes(vecsize * sizeof (*ret->s_vec));
#endif
ret->s_isborrowed = 0;
***************
*** 461,464 ****
--- 494,498 ----
}
ret->s_n = n;
+ ret->s_vecsize = vecsize;
ret->s_sr = sr;
ret->s_refcount = 0;
***************
*** 482,485 ****
--- 516,520 ----
sig->s_vec = sig2->s_vec;
sig->s_n = sig2->s_n;
+ sig->s_vecsize = sig2->s_vecsize;
}
***************
*** 534,538 ****
t_signal **dc_iosigs;
float dc_srate;
! int dc_vecsize;
char dc_toplevel; /* true if "iosigs" is invalid. */
char dc_reblock; /* true if we have to reblock inlets/outlets */
--- 569,574 ----
t_signal **dc_iosigs;
float dc_srate;
! int dc_vecsize; /* vector size, power of two */
! int dc_calcsize; /* number of elements to calculate */
char dc_toplevel; /* true if "iosigs" is invalid. */
char dc_reblock; /* true if we have to reblock inlets/outlets */
***************
*** 564,568 ****
ugen_sortno++;
dsp_chain = (t_int *)getbytes(sizeof(*dsp_chain));
! dsp_chain[0] = 0;
dsp_chainsize = 1;
if (ugen_currentcontext) bug("ugen_start");
--- 600,604 ----
ugen_sortno++;
dsp_chain = (t_int *)getbytes(sizeof(*dsp_chain));
! dsp_chain[0] = (t_int)dsp_done;
dsp_chainsize = 1;
if (ugen_currentcontext) bug("ugen_start");
***************
*** 861,865 ****
float parent_srate;
int parent_vecsize;
! int period, frequency, phase, vecsize;
float srate;
int chainblockbegin; /* DSP chain onset before block prolog code */
--- 897,901 ----
float parent_srate;
int parent_vecsize;
! int period, frequency, phase, vecsize, calcsize;
float srate;
int chainblockbegin; /* DSP chain onset before block prolog code */
***************
*** 915,918 ****
--- 951,957 ----
if (vecsize == 0)
vecsize = parent_vecsize;
+ calcsize = blk->x_calcsize;
+ if (calcsize == 0)
+ calcsize = vecsize;
realoverlap = blk->x_overlap;
if (realoverlap > vecsize) realoverlap = vecsize;
***************
*** 944,947 ****
--- 983,987 ----
srate = parent_srate;
vecsize = parent_vecsize;
+ calcsize = (parent_context ? parent_context->dc_calcsize : vecsize);
downsample = upsample = 1;/* IOhannes */
period = frequency = 1;
***************
*** 954,957 ****
--- 994,998 ----
dc->dc_srate = srate;
dc->dc_vecsize = vecsize;
+ dc->dc_calcsize = calcsize;
/* if we're reblocking or switched, we now have to create output
***************
*** 998,1014 ****
if (pd_class(zz) == vinlet_class)
vinlet_dspprolog((struct _vinlet *)zz,
! dc->dc_iosigs, vecsize, dsp_phase, period, frequency,
! downsample, upsample, /* IOhannes */
! reblock, switched);
else if (pd_class(zz) == voutlet_class)
voutlet_dspprolog((struct _voutlet *)zz,
! outsigs, vecsize, dsp_phase, period, frequency,
! downsample, upsample, /* IOhannes */
! reblock, switched);
}
chainblockbegin = dsp_chainsize;
if (blk && (reblock || switched)) /* add the block DSP prolog */
dsp_add(block_prolog, 1, blk);
/* Initialize for sorting */
--- 1039,1056 ----
if (pd_class(zz) == vinlet_class)
vinlet_dspprolog((struct _vinlet *)zz,
! dc->dc_iosigs, vecsize, calcsize, dsp_phase, period, frequency,
! downsample, upsample, reblock, switched);
else if (pd_class(zz) == voutlet_class)
voutlet_dspprolog((struct _voutlet *)zz,
! outsigs, vecsize, calcsize, dsp_phase, period, frequency,
! downsample, upsample, reblock, switched);
}
chainblockbegin = dsp_chainsize;
if (blk && (reblock || switched)) /* add the block DSP prolog */
+ {
dsp_add(block_prolog, 1, blk);
+ blk->x_chainonset = dsp_chainsize - 1;
+ }
/* Initialize for sorting */
***************
*** 1077,1083 ****
if (iosigs) iosigs += dc->dc_ninlets;
voutlet_dspepilog((struct _voutlet *)zz,
! iosigs, vecsize, dsp_phase, period, frequency,
! downsample, upsample, /* IOhannes */
! reblock, switched);
}
}
--- 1119,1124 ----
if (iosigs) iosigs += dc->dc_ninlets;
voutlet_dspepilog((struct _voutlet *)zz,
! iosigs, vecsize, calcsize, dsp_phase, period, frequency,
! downsample, upsample, reblock, switched);
}
}
More information about the Pd-cvs
mailing list