aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/xsample
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/xsample')
-rw-r--r--externals/grill/xsample/source/groove.cpp9
-rwxr-xr-xexternals/grill/xsample/source/inter.h65
-rw-r--r--externals/grill/xsample/source/main.h24
-rwxr-xr-xexternals/grill/xsample/xsample.cwbin279503 -> 279503 bytes
4 files changed, 76 insertions, 22 deletions
diff --git a/externals/grill/xsample/source/groove.cpp b/externals/grill/xsample/source/groove.cpp
index 4759812c..f70846f7 100644
--- a/externals/grill/xsample/source/groove.cpp
+++ b/externals/grill/xsample/source/groove.cpp
@@ -498,6 +498,11 @@ V xgroove::s_pos_loop(I n,S *const *invecs,S *const *outvecs)
S *pos = outvecs[outchns];
BL lpbang = false;
+#ifdef __VEC__
+ // prefetch cache
+ vec_dst(speed,GetPrefetchConstant(1,n>>2,0),0);
+#endif
+
const D smin = curmin,smax = curmax,plen = smax-smin; //curlen;
if(buf && plen > 0) {
@@ -529,6 +534,10 @@ V xgroove::s_pos_loop(I n,S *const *invecs,S *const *outvecs)
else
s_pos_off(n,invecs,outvecs);
+#ifdef __VEC__
+ vec_dss(0);
+#endif
+
if(lpbang) ToOutBang(outchns+3);
}
diff --git a/externals/grill/xsample/source/inter.h b/externals/grill/xsample/source/inter.h
index 3f8ea5f8..d5f2b4ac 100755
--- a/externals/grill/xsample/source/inter.h
+++ b/externals/grill/xsample/source/inter.h
@@ -38,7 +38,7 @@ TMPLDEF V xinter::st_play1(const S *bdt,const I smin,const I smax,const I n,cons
}
else if(oint >= smax) {
// position > last sample ... take only last sample
- fp = bdt+(smax-1)*BCHNS;
+ fp = bdt+(smin == smax?smin:smax-1)*BCHNS;
}
else {
// normal
@@ -116,50 +116,73 @@ TMPLDEF V xinter::st_play4(const S *bdt,const I smin,const I smax,const I n,cons
// position info are frame units
const S *pos = invecs[0];
+
+#ifdef __VEC__
+ // prefetch cache
+ vec_dst(pos,GetPrefetchConstant(1,n>>2,0),0);
+ const int pf = GetPrefetchConstant(BCHNS,1,16*BCHNS);
+#endif
+
S *const *sig = outvecs;
register I si = 0;
// 4-point interpolation
// ---------------------
const I maxo = smax-1; // last sample in play region
+ const S *maxp = bdt+maxo*BCHNS; // pointer to last sample
for(I i = 0; i < n; ++i,++si) {
F o = *(pos++);
- register I oint = (I)o,ointm,oint1,oint2;
+ register I oint = (I)o;
+ register F frac;
+ register const S *fa,*fb,*fc,*fd;
if(oint <= smin) {
if(oint < smin) oint = smin,o = (float)smin;
- // position is first simple
- ointm = smin; // first sample
- oint1 = oint+1;
- oint2 = oint1+1;
+
+ fa = bdt+smin*BCHNS; // position is first sample
+ fb = bdt+oint*BCHNS;
+
+ frac = o-oint;
+ fc = fb+BCHNS;
+ fd = fc+BCHNS;
}
else if(oint >= maxo-2) {
if(oint > maxo) oint = maxo,o = (float)smax;
- ointm = oint-1;
- oint1 = oint >= maxo?maxo:oint+1;
- oint2 = oint1 >= maxo?maxo:oint1+1;
+ frac = o-oint;
+
+ fb = bdt+oint*BCHNS;
+ fa = fb-BCHNS; // CACHE!
+
+ // \TODO what about wrap-around???
+ fc = fb >= maxp?maxp:fb+BCHNS; // ev. CACHE!
+ fd = fc >= maxp?maxp:fc+BCHNS; // ev. CACHE!
}
else {
- ointm = oint-1;
- oint1 = oint+1;
- oint2 = oint1+1;
+ fa = bdt+oint*BCHNS-BCHNS;
+ frac = o-oint;
+ fb = fa+BCHNS;
+#ifdef __VEC__
+ vec_dst(fa,pf,0);
+#endif
+ fc = fb+BCHNS;
+ fd = fc+BCHNS;
}
- register F frac = o-oint;
+ register F f1 = 0.5f*(frac-1.0f);
+ register F f3 = frac*3.0f-1.0f;
- register const S *fa = bdt+ointm*BCHNS;
- register const S *fb = bdt+oint*BCHNS;
- register const S *fc = bdt+oint1*BCHNS;
- register const S *fd = bdt+oint2*BCHNS;
-
for(I ci = 0; ci < OCHNS; ++ci) {
+ const F amdf = (fa[ci]-fd[ci])*frac;
const F cmb = fc[ci]-fb[ci];
- sig[ci][si] = fb[ci] + frac*(
- cmb - 0.5f*(frac-1.0f) * ((fa[ci]-fd[ci]+3.0f*cmb)*frac + (fb[ci]-fa[ci]-cmb))
- );
+ const F bma = fb[ci]-fa[ci];
+ sig[ci][si] = fb[ci] + frac*( cmb - f1 * ( amdf+bma+cmb*f3 ) );
}
}
+
+#ifdef __VEC__
+ vec_dss(0);
+#endif
// clear rest of output channels (if buffer has less channels)
for(I ci = OCHNS; ci < outchns; ++ci) ZeroSamples(sig[ci],n);
diff --git a/externals/grill/xsample/source/main.h b/externals/grill/xsample/source/main.h
index b3b8a499..61c0bf4d 100644
--- a/externals/grill/xsample/source/main.h
+++ b/externals/grill/xsample/source/main.h
@@ -12,7 +12,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define __XSAMPLE_H
-#define XSAMPLE_VERSION "0.3.0pre12"
+#define XSAMPLE_VERSION "0.3.0pre13"
#define FLEXT_ATTRIBUTES 1
@@ -72,6 +72,28 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define STD
#endif
+#ifdef __ALTIVEC__
+#if FLEXT_CPU == FLEXT_CPU_PPC && defined(__MWERKS__)
+ #pragma altivec_model on
+ #include <vBasicOps.h>
+ #include <vectorOps.h>
+#elif FLEXT_CPU == FLEXT_CPU_PPC && defined(__GNUG__)
+ #include <vecLib/vBasicOps.h>
+ #include <vecLib/vectorOps.h>
+#endif
+
+ // Initialize a prefetch constant for use with vec_dst(), vec_dstt(), vec_dstst or vec_dststt
+ // Taken from the "AltiVec tutorial" by Ian Ollmann, Ph.D.
+ inline UInt32 GetPrefetchConstant( int blockSizeInVectors,int blockCount,int blockStride )
+ {
+// FLEXT_ASSERT( blockSizeInVectors > 0 && blockSizeInVectors <= 32 );
+// FLEXT_ASSERT( blockCount > 0 && blockCount <= 256 );
+// FLEXT_ASSERT( blockStride > MIN_SHRT && blockStride <= MAX_SHRT );
+ return ((blockSizeInVectors << 24) & 0x1F000000) |
+ ((blockCount << 16) && 0x00FF0000) |
+ (blockStride & 0xFFFF);
+ }
+#endif
class xsample:
public flext_dsp
diff --git a/externals/grill/xsample/xsample.cw b/externals/grill/xsample/xsample.cw
index 8065e314..2a4c0938 100755
--- a/externals/grill/xsample/xsample.cw
+++ b/externals/grill/xsample/xsample.cw
Binary files differ