[PD-cvs] pd/src d_ugen.c,1.3.4.1.2.5.2.11,1.3.4.1.2.5.2.12
Mathieu Bouchard
matju at users.sourceforge.net
Tue Jul 10 07:50:00 CEST 2007
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9908
Modified Files:
Tag: desiredata
d_ugen.c
Log Message:
cleanup
Index: d_ugen.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/d_ugen.c,v
retrieving revision 1.3.4.1.2.5.2.11
retrieving revision 1.3.4.1.2.5.2.12
diff -C2 -d -r1.3.4.1.2.5.2.11 -r1.3.4.1.2.5.2.12
*** d_ugen.c 30 Jun 2007 13:56:06 -0000 1.3.4.1.2.5.2.11
--- d_ugen.c 10 Jul 2007 05:49:58 -0000 1.3.4.1.2.5.2.12
***************
*** 38,49 ****
extern "C" {
! 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);
};
--- 38,46 ----
extern "C" {
! 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);
};
***************
*** 328,332 ****
}
! /* mark the signal "reusable." */
extern "C" void signal_makereusable(t_signal *sig) {
int logn = ilog2(sig->s_vecsize);
--- 325,329 ----
}
! /* mark the signal "reusable." */
extern "C" void signal_makereusable(t_signal *sig) {
int logn = ilog2(sig->s_vecsize);
***************
*** 348,353 ****
if (ugen_loud) post("free %lx: %d", sig, sig->s_isborrowed);
if (sig->s_isborrowed) {
! /* if the signal is borrowed, decrement the borrowed-from signal's
! reference count, possibly marking it reusable too */
t_signal *s2 = sig->s_borrowedfrom;
if ((s2 == sig) || !s2) bug("signal_free");
--- 345,349 ----
if (ugen_loud) post("free %lx: %d", sig, sig->s_isborrowed);
if (sig->s_isborrowed) {
! /* if the signal is borrowed, decrement the borrowed-from signal's reference count, possibly marking it reusable too */
t_signal *s2 = sig->s_borrowedfrom;
if ((s2 == sig) || !s2) bug("signal_free");
***************
*** 364,371 ****
}
! /* reclaim or make an audio signal. If n is zero, return a "borrowed"
! signal whose buffer and size will be obtained later via
! signal_setborrowed(). */
!
t_signal *signal_new(int n, float sr) {
int logn, vecsize = 0;
--- 360,365 ----
}
! /* reclaim or make an audio signal. If n is zero, return a "borrowed"
! signal whose buffer and size will be obtained later via signal_setborrowed(). */
t_signal *signal_new(int n, float sr) {
int logn, vecsize = 0;
***************
*** 516,520 ****
}
! /* first the canvas calls this to create all the boxes... */
extern "C" void ugen_add(t_dspcontext *dc, t_object *obj) {
t_ugenbox *x = (t_ugenbox *)getbytes(sizeof *x);
--- 510,514 ----
}
! /* first the canvas calls this to create all the boxes... */
extern "C" void ugen_add(t_dspcontext *dc, t_object *obj) {
t_ugenbox *x = (t_ugenbox *)getbytes(sizeof *x);
***************
*** 533,542 ****
}
! /* and then this to make all the connections. */
extern "C" void ugen_connect(t_dspcontext *dc, t_object *x1, int outno, t_object *x2, int inno) {
t_ugenbox *u1, *u2;
- t_sigoutlet *uout;
- t_siginlet *uin;
- t_sigoutconnect *oc;
int sigoutno = obj_sigoutletindex(x1, outno);
int siginno = obj_siginletindex(x2, inno);
--- 527,533 ----
}
! /* and then this to make all the connections. */
extern "C" void ugen_connect(t_dspcontext *dc, t_object *x1, int outno, t_object *x2, int inno) {
t_ugenbox *u1, *u2;
int sigoutno = obj_sigoutletindex(x1, outno);
int siginno = obj_siginletindex(x2, inno);
***************
*** 550,561 ****
if (sigoutno < 0 || sigoutno >= u1->nout || siginno >= u2->nin) {
bug("ugen_connect %s %s %d %d (%d %d)",
! class_getname(x1->ob_pd),
! class_getname(x2->ob_pd), sigoutno, siginno, u1->nout,
! u2->nin);
}
! uout = u1->out + sigoutno;
! uin = u2->in + siginno;
/* add a new connection to the outlet's list */
! oc = (t_sigoutconnect *)getbytes(sizeof *oc);
oc->next = uout->connections;
uout->connections = oc;
--- 541,550 ----
if (sigoutno < 0 || sigoutno >= u1->nout || siginno >= u2->nin) {
bug("ugen_connect %s %s %d %d (%d %d)",
! class_getname(x1->ob_pd), class_getname(x2->ob_pd), sigoutno, siginno, u1->nout, u2->nin);
}
! t_sigoutlet *uout = u1->out + sigoutno;
! t_siginlet * uin = u2->in + siginno;
/* add a new connection to the outlet's list */
! t_sigoutconnect *oc = (t_sigoutconnect *)getbytes(sizeof *oc);
oc->next = uout->connections;
uout->connections = oc;
***************
*** 569,576 ****
/* get the index of a ugenbox or -1 if it's not on the list */
static int ugen_index(t_dspcontext *dc, t_ugenbox *x) {
! int ret;
! t_ugenbox *u;
! for (u = dc->ugenlist, ret = 0; u; u = u->next, ret++)
! if (u == x) return ret;
return -1;
}
--- 558,563 ----
/* get the index of a ugenbox or -1 if it's not on the list */
static int ugen_index(t_dspcontext *dc, t_ugenbox *x) {
! int ret=0;
! for (t_ugenbox *u = dc->ugenlist; u; u = u->next, ret++) if (u == x) return ret;
return -1;
}
***************
*** 648,652 ****
else if (u->nin+u->nout==1) post("put %s %d (%lx)", class_getname(u->obj->ob_pd), ugen_index(dc,u),sig[0]);
else if (u->nin+u->nout==2) post("put %s %d (%lx %lx)", class_getname(u->obj->ob_pd), ugen_index(dc,u),sig[0],sig[1]);
! else post("put %s %d (%lx %lx %lx ...)", class_getname(u->obj->ob_pd), ugen_index(dc,u),sig[0],sig[1],sig[2]);
}
/* pass it on and trip anyone whose last inlet was filled */
--- 635,639 ----
else if (u->nin+u->nout==1) post("put %s %d (%lx)", class_getname(u->obj->ob_pd), ugen_index(dc,u),sig[0]);
else if (u->nin+u->nout==2) post("put %s %d (%lx %lx)", class_getname(u->obj->ob_pd), ugen_index(dc,u),sig[0],sig[1]);
! else post("put %s %d (%lx %lx %lx ...)", class_getname(u->obj->ob_pd), ugen_index(dc,u),sig[0],sig[1],sig[2]);
}
/* pass it on and trip anyone whose last inlet was filled */
***************
*** 662,667 ****
s2->s_refcount--;
if (!signal_compatible(s1, s2)) {
! pd_error(u->obj, "%s: incompatible signal inputs",
! class_getname(u->obj->ob_pd));
return;
}
--- 649,653 ----
s2->s_refcount--;
if (!signal_compatible(s1, s2)) {
! pd_error(u->obj, "%s: incompatible signal inputs", class_getname(u->obj->ob_pd));
return;
}
***************
*** 700,704 ****
t_sigoutlet *uout;
t_siginlet *uin;
- t_sigoutconnect *oc, *oc2;
int i, n;
t_block *blk;
--- 686,689 ----
***************
*** 708,714 ****
int period, frequency, phase, vecsize, calcsize;
float srate;
- int chainblockbegin; /* DSP chain onset before block prolog code */
- int chainblockend; /* and after block epilog code */
- int chainafterall; /* and after signal outlet epilog */
int reblock = 0, switched;
int downsample = 1, upsample = 1; /* IOhannes */
--- 693,696 ----
***************
*** 719,726 ****
post("ugen: %s", class_getname(u->obj->ob_pd));
for (uout = u->out, i = 0; i < u->nout; uout++, i++)
! for (oc = uout->connections; oc; oc = oc->next) {
! post("... out %d to %s, index %d, inlet %d", i,
! class_getname(oc->who->obj->ob_pd),
! ugen_index(dc, oc->who), oc->inno);
}
}
--- 701,706 ----
post("ugen: %s", class_getname(u->obj->ob_pd));
for (uout = u->out, i = 0; i < u->nout; uout++, i++)
! for (t_sigoutconnect *oc = uout->connections; oc; oc = oc->next) {
! post("... out %d to %s, index %d, inlet %d", i, class_getname(oc->who->obj->ob_pd), ugen_index(dc, oc->who), oc->inno);
}
}
***************
*** 810,822 ****
if (outsigs) outsigs += dc->ninlets;
if (pd_class(zz) == vinlet_class)
! vinlet_dspprolog((struct _vinlet *)zz,
! 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);
--- 790,800 ----
if (outsigs) outsigs += dc->ninlets;
if (pd_class(zz) == vinlet_class)
! vinlet_dspprolog((struct _vinlet *)zz, 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);
}
! int chainblockbegin = dsp_chainsize; /* DSP chain onset before block prolog code */
if (blk && (reblock || switched)) { /* add the block DSP prolog */
dsp_add(block_prolog, 1, blk);
***************
*** 856,860 ****
/* add block DSP epilog */
if (blk && (reblock || switched)) dsp_add(block_epilog, 1, blk);
! chainblockend = dsp_chainsize;
/* add epilogs for outlets. */
for (u = dc->ugenlist; u; u = u->next) {
--- 834,838 ----
/* add block DSP epilog */
if (blk && (reblock || switched)) dsp_add(block_epilog, 1, blk);
! int chainblockend = dsp_chainsize; /* and after block epilog code */
/* add epilogs for outlets. */
for (u = dc->ugenlist; u; u = u->next) {
***************
*** 863,872 ****
t_signal **iosigs = dc->iosigs;
if (iosigs) iosigs += dc->ninlets;
! voutlet_dspepilog((struct _voutlet *)zz,
! iosigs, vecsize, calcsize, dsp_phase, period, frequency,
downsample, upsample, reblock, switched);
}
}
! chainafterall = dsp_chainsize;
if (blk) {
blk->blocklength = chainblockend - chainblockbegin;
--- 841,849 ----
t_signal **iosigs = dc->iosigs;
if (iosigs) iosigs += dc->ninlets;
! voutlet_dspepilog((struct _voutlet *)zz, iosigs, vecsize, calcsize, dsp_phase, period, frequency,
downsample, upsample, reblock, switched);
}
}
! int chainafterall = dsp_chainsize; /* and after signal outlet epilog */
if (blk) {
blk->blocklength = chainblockend - chainblockbegin;
***************
*** 883,887 ****
while (dc->ugenlist) {
for (uout = dc->ugenlist->out, n = dc->ugenlist->nout; n--; uout++) {
! oc = uout->connections;
while (oc) {
oc2 = oc->next;
--- 860,864 ----
while (dc->ugenlist) {
for (uout = dc->ugenlist->out, n = dc->ugenlist->nout; n--; uout++) {
! t_sigoutconnect *oc = uout->connections, *oc2;
while (oc) {
oc2 = oc->next;
***************
*** 914,921 ****
t_int *downsampling_perform_0(t_int *w) {
! t_float *in = (t_float *)(w[1]); /* original signal */
! t_float *out = (t_float *)(w[2]); /* downsampled signal */
! int down = (int)(w[3]); /* downsampling factor */
! int parent = (int)(w[4]); /* original vectorsize */
int n=parent/down;
while(n--) {
--- 891,898 ----
t_int *downsampling_perform_0(t_int *w) {
! t_float *in = (t_float *)w[1]; /* original signal */
! t_float *out = (t_float *)w[2]; /* downsampled signal */
! int down = int(w[3]); /* downsampling factor */
! int parent = int(w[4]); /* original vectorsize */
int n=parent/down;
while(n--) {
***************
*** 982,987 ****
t_float *in = (t_float *)w[2]; /* original signal */
t_float *out = (t_float *)w[3]; /* upsampled signal */
! const int up = int(w[4]); /* upsampling factor */
! const int parent = int(w[5]); /* original vectorsize */
const int length = parent*up;
int n;
--- 959,964 ----
t_float *in = (t_float *)w[2]; /* original signal */
t_float *out = (t_float *)w[3]; /* upsampled signal */
! const int up = int(w[4]); /* upsampling factor */
! const int parent = int(w[5]); /* original vectorsize */
const int length = parent*up;
int n;
***************
*** 1009,1016 ****
* cool for FFT-data, where you only want to process the significant (1st) part of the vector
*/
! t_float *in = (t_float *)(w[1]); /* original signal */
! t_float *out = (t_float *)(w[2]); /* upsampled signal */
! int up = (int)(w[3]); /* upsampling factor */
! int parent = (int)(w[4]); /* original vectorsize */
int i=parent;
int n=parent*(up-1);
--- 986,993 ----
* cool for FFT-data, where you only want to process the significant (1st) part of the vector
*/
! t_float *in = (t_float *)w[1]; /* original signal */
! t_float *out = (t_float *)w[2]; /* upsampled signal */
! int up = (int)w[3]; /* upsampling factor */
! int parent = (int)w[4]; /* original vectorsize */
int i=parent;
int n=parent*(up-1);
***************
*** 1039,1046 ****
/* dsp-adding */
! void resample_dsp(t_resample *x,
! t_sample* in, int insize,
! t_sample* out, int outsize,
! int method) {
if (insize == outsize) {
bug("nothing to be done");
--- 1016,1020 ----
/* dsp-adding */
! void resample_dsp(t_resample *x, t_sample* in, int insize, t_sample* out, int outsize, int method) {
if (insize == outsize) {
bug("nothing to be done");
***************
*** 1053,1061 ****
}
switch (method) {
! case RESAMPLE_BLOCK:
! dsp_add(downsampling_perform_block, 4, in, out, insize/outsize, insize);
! break;
! default:
! dsp_add(downsampling_perform_0, 4, in, out, insize/outsize, insize);
}
} else { /* upsampling */
--- 1027,1032 ----
}
switch (method) {
! case RESAMPLE_BLOCK: dsp_add(downsampling_perform_block, 4, in, out, insize/outsize, insize); break;
! default: dsp_add(downsampling_perform_0, 4, in, out, insize/outsize, insize);
}
} else { /* upsampling */
***************
*** 1065,1071 ****
}
switch (method) {
! case RESAMPLE_HOLD:
! dsp_add(upsampling_perform_hold, 4, in, out, outsize/insize, insize);
! break;
case RESAMPLE_LINEAR:
if (x->bufsize != 1) {
--- 1036,1040 ----
}
switch (method) {
! case RESAMPLE_HOLD: dsp_add(upsampling_perform_hold, 4, in, out, outsize/insize, insize); break;
case RESAMPLE_LINEAR:
if (x->bufsize != 1) {
***************
*** 1076,1084 ****
dsp_add(upsampling_perform_linear, 5, x, in, out, outsize/insize, insize);
break;
! case RESAMPLE_BLOCK:
! dsp_add(upsampling_perform_block, 4, in, out, outsize/insize, insize);
! break;
! default:
! dsp_add(upsampling_perform_0, 4, in, out, outsize/insize, insize);
}
}
--- 1045,1050 ----
dsp_add(upsampling_perform_linear, 5, x, in, out, outsize/insize, insize);
break;
! case RESAMPLE_BLOCK: dsp_add(upsampling_perform_block, 4, in, out, outsize/insize, insize); break;
! default: dsp_add(upsampling_perform_0, 4, in, out, outsize/insize, insize);
}
}
***************
*** 1105,1109 ****
void resampleto_dsp(t_resample *x, t_sample *out, int insize, int outsize, int method) {
if (insize==outsize) {
! if (x->s_n)free(x->s_vec);
x->s_n = 0;
x->s_vec = out;
--- 1071,1075 ----
void resampleto_dsp(t_resample *x, t_sample *out, int insize, int outsize, int method) {
if (insize==outsize) {
! if (x->s_n) free(x->s_vec);
x->s_n = 0;
x->s_vec = out;
***************
*** 1149,1154 ****
static void samplerate_tilde_setup() {
! samplerate_tilde_class = class_new(gensym("samplerate~"),
! (t_newmethod)samplerate_tilde_new, 0, sizeof(t_samplerate), 0, 0);
class_addbang(samplerate_tilde_class, samplerate_tilde_bang);
}
--- 1115,1119 ----
static void samplerate_tilde_setup() {
! samplerate_tilde_class = class_new(gensym("samplerate~"), (t_newmethod)samplerate_tilde_new, 0, sizeof(t_samplerate), 0, 0);
class_addbang(samplerate_tilde_class, samplerate_tilde_bang);
}
More information about the Pd-cvs
mailing list