aboutsummaryrefslogtreecommitdiff
path: root/externals/grill
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2004-03-23 03:27:37 +0000
committerThomas Grill <xovo@users.sourceforge.net>2004-03-23 03:27:37 +0000
commitee3e77c91f690444730da3300a8169bba50a8973 (patch)
tree9c59cbbf0b080fbed1d4852a9c804840295ab53f /externals/grill
parent7d48cee76a231c32c67130c28ce65fabaae9f451 (diff)
""
svn path=/trunk/; revision=1469
Diffstat (limited to 'externals/grill')
-rw-r--r--externals/grill/flext/source/flsupport.cpp7
-rw-r--r--externals/grill/xsample/source/groove.cpp32
-rw-r--r--externals/grill/xsample/source/main.cpp82
-rw-r--r--externals/grill/xsample/source/main.h2
4 files changed, 59 insertions, 64 deletions
diff --git a/externals/grill/flext/source/flsupport.cpp b/externals/grill/flext/source/flsupport.cpp
index 543c1235..cc300b95 100644
--- a/externals/grill/flext/source/flsupport.cpp
+++ b/externals/grill/flext/source/flsupport.cpp
@@ -157,12 +157,16 @@ void *flext_root::operator new(size_t bytes)
SYSUNLOCK();
}
+ FLEXT_ASSERT(blk);
+
*(size_t *)blk = bytes;
return blk+sizeof(size_t);
}
void flext_root::operator delete(void *blk)
{
+ FLEXT_ASSERT(blk);
+
char *ori = (char *)blk-sizeof(size_t);
size_t bytes = *(size_t *)ori;
@@ -213,6 +217,7 @@ void *flext_root::NewAligned(size_t bytes,int bitalign)
#endif
SYSUNLOCK();
}
+ FLEXT_ASSERT(blk);
char *ablk = reinterpret_cast<char *>((reinterpret_cast<unsigned long>(blk)+ovh+alignovh) & ~alignovh);
*(char **)(ablk-sizeof(size_t)-sizeof(char *)) = blk;
@@ -222,6 +227,8 @@ void *flext_root::NewAligned(size_t bytes,int bitalign)
void flext_root::FreeAligned(void *blk)
{
+ FLEXT_ASSERT(blk);
+
char *ori = *(char **)((char *)blk-sizeof(size_t)-sizeof(char *));
size_t bytes = *(size_t *)((char *)blk-sizeof(size_t));
diff --git a/externals/grill/xsample/source/groove.cpp b/externals/grill/xsample/source/groove.cpp
index fd8bad65..dc268e91 100644
--- a/externals/grill/xsample/source/groove.cpp
+++ b/externals/grill/xsample/source/groove.cpp
@@ -39,7 +39,7 @@ public:
virtual BL m_reset();
virtual V m_pos(F pos);
- V m_posmod(F pos);
+ inline V m_posmod(F pos) { setposmod(pos?pos/s2u:0); } // motivated by Tim Blechmann
virtual V m_all();
virtual V m_min(F mn);
virtual V m_max(F mx);
@@ -66,10 +66,10 @@ protected:
I bidir;
F _xzone,xzone,xsymm;
- I znsmin,znsmax;
+ L znsmin,znsmax;
I xshape;
F xshparam;
- F znmin,znmax;
+ D znmin,znmax;
BL xkeep;
S **znbuf;
S *znpos,*znmul,*znidx;
@@ -78,16 +78,16 @@ protected:
inline V outputmin() { ToOutFloat(outchns+1,curmin*s2u); }
inline V outputmax() { ToOutFloat(outchns+2,curmax*s2u); }
- inline V setpos(F pos)
+ inline V setpos(D pos)
{
if(pos < znsmin) curpos = znsmin;
else if(pos > znsmax) curpos = znsmax;
else curpos = pos;
}
- inline V setposmod(F pos)
+ inline V setposmod(D pos)
{
- F p = pos-znsmin;
+ D p = pos-znsmin;
if(p >= 0) curpos = znsmin+fmod(p,znsmax-znsmin);
else curpos = znsmax+fmod(p,znsmax-znsmin);
}
@@ -218,7 +218,7 @@ xgroove::xgroove(I argc,const t_atom *argv):
znbuf = new S *[outchns];
for(I i = 0; i < outchns; ++i) znbuf[i] = new S[0];
- znpos = new S[0]; // don't know vector size yet -> m_dsp
+ znpos = new S[0]; // don't know vector size yet -> wait for m_dsp
znidx = new S[0];
znmul = new S[XZONE_TABLE+1];
m_xshape();
@@ -248,9 +248,9 @@ BL xgroove::Init()
V xgroove::m_units(xs_unit mode)
{
- xsample::m_units(mode);
+ xsample::m_units(mode); // calls bufchk()
- m_sclmode();
+ m_sclmode(); // calls bufchk() again.... \todo optimize that!!
outputmin();
outputmax();
}
@@ -276,12 +276,6 @@ V xgroove::m_pos(F pos)
setpos(pos?pos/s2u:0);
}
-// motivated by Tim Blechmann
-V xgroove::m_posmod(F pos)
-{
- setposmod(pos?pos/s2u:0);
-}
-
V xgroove::m_all()
{
xsample::m_all();
@@ -389,7 +383,7 @@ V xgroove::do_xzone()
// desired crossfade points
znmin = znsmin+xzone*xsymm,znmax = znsmax+xzone*(xsymm-1);
// extra space at beginning and end
- F o1 = znmin-xzone,o2 = buf->Frames()-(znmax+xzone);
+ D o1 = znmin-xzone,o2 = buf->Frames()-(znmax+xzone);
if(o1 < 0 || o2 < 0) { // or (o1*o2 < 0)
if(o1+o2 < 0) {
@@ -621,8 +615,8 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs)
S *pos = outvecs[outchns];
BL lpbang = false;
- const F xz = xzone,lmin = znmin,lmax = znmax,lsh = lmax+xz-lmin;
- const F xf = (F)XZONE_TABLE/xz;
+ const F xz = xzone,xf = (F)XZONE_TABLE/xz;
+ const D lmin = znmin,lmax = znmax,lsh = lmax+xz-lmin;
// adapt the playing bounds to the current cross-fade zone
const I smin = znsmin,smax = znsmax,plen = smax-smin; //curlen;
@@ -657,7 +651,7 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs)
if(o < lmin) {
// in early cross-fade zone
- register F inp = xz-(lmin-o); // 0 <= inp < xz
+ register F inp = xz-(F)(lmin-o); // 0 <= inp < xz
znidx[i] = inp*xf;
znpos[i] = lmax+inp;
inzn = true;
diff --git a/externals/grill/xsample/source/main.cpp b/externals/grill/xsample/source/main.cpp
index df2806a6..36edf5fd 100644
--- a/externals/grill/xsample/source/main.cpp
+++ b/externals/grill/xsample/source/main.cpp
@@ -101,12 +101,11 @@ I xsample::m_set(I argc,const t_atom *argv)
BL xsample::m_refresh()
{
-// bufchk();
-
BL ret;
if(buf->Set()) { s_dsp(); ret = true; } // channel count may have changed
else ret = false;
+ // realize positions... 2 times bufchk()!!
m_min((F)curmin*s2u); // also checks pos
m_max((F)curmax*s2u); // also checks pos
@@ -115,12 +114,11 @@ BL xsample::m_refresh()
BL xsample::m_reset()
{
-// bufchk();
-
BL ret;
if(buf->Set()) { s_dsp(); ret = true; } // channel count may have changed
else ret = false;
+ // now... 4 times bufchk()!! \todo get rid of that
m_units();
m_sclmode();
m_min(0);
@@ -136,49 +134,48 @@ V xsample::m_loadbang()
V xsample::m_units(xs_unit mode)
{
- if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed)
-
if(mode != xsu__) unitmode = mode;
- switch(unitmode) {
- case xsu_sample: // samples
- s2u = 1;
- break;
- case xsu_buffer: // buffer size
- s2u = 1.f/buf->Frames();
- break;
- case xsu_ms: // ms
- s2u = 1000.f/Samplerate();
- break;
- case xsu_s: // s
- s2u = 1.f/Samplerate();
- break;
- default:
- post("%s: Unknown unit mode",thisName());
- }
+
+ if(bufchk())
+ switch(unitmode) {
+ case xsu_sample: // samples
+ s2u = 1;
+ break;
+ case xsu_buffer: // buffer size
+ s2u = 1.f/buf->Frames();
+ break;
+ case xsu_ms: // ms
+ s2u = 1000.f/Samplerate();
+ break;
+ case xsu_s: // s
+ s2u = 1.f/Samplerate();
+ break;
+ default:
+ post("%s: Unknown unit mode",thisName());
+ }
}
V xsample::m_sclmode(xs_sclmd mode)
{
- if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed)
-
if(mode != xss__) sclmode = mode;
- switch(sclmode) {
- case 0: // samples/units
- sclmin = 0; sclmul = s2u;
- break;
- case 1: // samples/units from recmin to recmax
- sclmin = curmin; sclmul = s2u;
- break;
- case 2: // unity between 0 and buffer size
- sclmin = 0; sclmul = buf->Frames()?1.f/buf->Frames():0;
- break;
- case 3: // unity between recmin and recmax
-// sclmin = curmin; sclmul = curlen?1.f/curlen:0;
- sclmin = curmin; sclmul = curmin != curmax?1.f/(curmax-curmin):0;
- break;
- default:
- post("%s: Unknown scale mode",thisName());
- }
+
+ if(bufchk())
+ switch(sclmode) {
+ case 0: // samples/units
+ sclmin = 0; sclmul = s2u;
+ break;
+ case 1: // samples/units from recmin to recmax
+ sclmin = curmin; sclmul = s2u;
+ break;
+ case 2: // unity between 0 and buffer size
+ sclmin = 0; sclmul = buf->Frames()?1.f/buf->Frames():0;
+ break;
+ case 3: // unity between recmin and recmax
+ sclmin = curmin; sclmul = curmin != curmax?1.f/(curmax-curmin):0;
+ break;
+ default:
+ post("%s: Unknown scale mode",thisName());
+ }
}
V xsample::m_min(F mn)
@@ -189,7 +186,6 @@ V xsample::m_min(F mn)
if(mn < 0) mn = 0;
else if(mn > curmax) mn = (F)curmax;
curmin = (I)(mn+.5);
-// curlen = curmax-curmin;
m_sclmode();
}
@@ -202,7 +198,6 @@ V xsample::m_max(F mx)
if(mx > buf->Frames()) mx = (F)buf->Frames();
else if(mx < curmin) mx = (F)curmin;
curmax = (I)(mx+.5);
-// curlen = curmax-curmin;
m_sclmode();
}
@@ -211,7 +206,6 @@ V xsample::m_all()
{
if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed)
-// curlen = (curmax = buf->Frames())-(curmin = 0);
curmin = 0; curmax = buf->Frames();
m_sclmode();
}
diff --git a/externals/grill/xsample/source/main.h b/externals/grill/xsample/source/main.h
index fd1b7304..15dee169 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.0pre17"
+#define XSAMPLE_VERSION "0.3.0pre18"
#define FLEXT_ATTRIBUTES 1