From 97926eb08cf74f277e522ffb8c7f985457822de3 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Tue, 11 Feb 2003 04:37:35 +0000 Subject: "" svn path=/trunk/; revision=388 --- externals/grill/xsample/source/groove.cpp | 39 +++++++++++++++++-------------- 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'externals/grill/xsample/source/groove.cpp') diff --git a/externals/grill/xsample/source/groove.cpp b/externals/grill/xsample/source/groove.cpp index 62f0c291..60bf617b 100644 --- a/externals/grill/xsample/source/groove.cpp +++ b/externals/grill/xsample/source/groove.cpp @@ -103,8 +103,10 @@ private: virtual V m_signal(I n,S *const *in,S *const *out) { - bufchk(); - posfun(n,in,out); + if(bufchk()) + posfun(n,in,out); + else + zerofun(n,in,out); } FLEXT_CALLBACK_F(m_pos) @@ -195,11 +197,11 @@ xgroove::xgroove(I argc,const t_atom *argv): AddOutFloat("Ending point (rounded to frame)"); // play max AddOutBang("Bang on loop end/rollover"); // loop bang - znbuf = new S *[outchns]; for(I i = 0; i < outchns; ++i) znbuf[i] = new S[0]; - znpos = new S[0]; + znpos = new S[0]; // don't know vector size yet -> m_dsp znidx = new S[0]; + znmul = new S[XZONE_TABLE+1]; m_xshape(); } @@ -304,9 +306,6 @@ V xgroove::m_xshape(I argc,const t_atom *argv) else if(xshparam > 1) xshparam = 1; } - if(znmul) delete[] znmul; - znmul = new S[XZONE_TABLE+1]; - I i; switch(xshape) { case 1: @@ -393,13 +392,11 @@ V xgroove::s_pos_off(I n,S *const *invecs,S *const *outvecs) { S *pos = outvecs[outchns]; - I si; - for(si = 0; si < n; ++si) pos[si] = curpos; + SetSamples(pos,n,curpos); playfun(n,&pos,outvecs); - const F oscl = scale(curpos); - for(si = 0; si < n; ++si) pos[si] = oscl; + SetSamples(pos,n,scale(curpos)); } V xgroove::s_pos_once(I n,S *const *invecs,S *const *outvecs) @@ -427,7 +424,7 @@ V xgroove::s_pos_once(I n,S *const *invecs,S *const *outvecs) playfun(n,&pos,outvecs); - for(I i = 0; i < n; ++i) pos[i] = scale(pos[i]); + arrscale(n,pos,pos); } else s_pos_off(n,invecs,outvecs); @@ -467,7 +464,7 @@ V xgroove::s_pos_loop(I n,S *const *invecs,S *const *outvecs) playfun(n,&pos,outvecs); - for(I i = 0; i < n; ++i) pos[i] = scale(pos[i]); + arrscale(n,pos,pos); } else s_pos_off(n,invecs,outvecs); @@ -523,15 +520,16 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs) playfun(n,&pos,outvecs); - for(I i = 0; i < n; ++i) pos[i] = scale(pos[i]); + arrscale(n,pos,pos); if(inzn) { // only if we were in cross-fade zone playfun(n,&znpos,znbuf); - for(I i = 0; i < n; ++i) znpos[i] = XZONE_TABLE-znidx[i]; - zonefun(znmul,0,XZONE_TABLE+1,1,n,1,1,&znidx,&znidx); - zonefun(znmul,0,XZONE_TABLE+1,1,n,1,1,&znpos,&znpos); + arrscale(n,znidx,znpos,-XZONE_TABLE,-1); + + zonefun(znmul,0,XZONE_TABLE+1,n,1,1,&znidx,&znidx); + zonefun(znmul,0,XZONE_TABLE+1,n,1,1,&znpos,&znpos); for(I o = 0; o < outchns; ++o) { F *ov = outvecs[o],*ob = znbuf[o]; @@ -582,7 +580,7 @@ V xgroove::s_pos_bidir(I n,S *const *invecs,S *const *outvecs) bidir = (I)bd; playfun(n,&pos,outvecs); - for(I i = 0; i < n; ++i) pos[i] = scale(pos[i]); + arrscale(n,pos,pos); } else s_pos_off(n,invecs,outvecs); @@ -614,6 +612,8 @@ V xgroove::s_dsp() SETSIGFUN(posfun,SIGFUN(s_pos_loopzn)); + // linear interpolation should be just ok for fade zone, no? +/* if(interp == xsi_4p) switch(outchns) { case 1: SETSTFUN(zonefun,TMPLSTF(st_play4,1,1)); break; @@ -622,12 +622,14 @@ V xgroove::s_dsp() default: SETSTFUN(zonefun,TMPLSTF(st_play4,1,-1)); } else if(interp == xsi_lin) +*/ switch(outchns) { case 1: SETSTFUN(zonefun,TMPLSTF(st_play2,1,1)); break; case 2: SETSTFUN(zonefun,TMPLSTF(st_play2,1,2)); break; case 4: SETSTFUN(zonefun,TMPLSTF(st_play2,1,4)); break; default: SETSTFUN(zonefun,TMPLSTF(st_play2,1,-1)); } +/* else switch(outchns) { case 1: SETSTFUN(zonefun,TMPLSTF(st_play1,1,1)); break; @@ -635,6 +637,7 @@ V xgroove::s_dsp() case 4: SETSTFUN(zonefun,TMPLSTF(st_play1,1,4)); break; default: SETSTFUN(zonefun,TMPLSTF(st_play1,1,-1)); } +*/ } else SETSIGFUN(posfun,SIGFUN(s_pos_loop)); -- cgit v1.2.1