diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2005-11-19 23:15:44 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2005-11-19 23:15:44 +0000 |
commit | 0f576ee67600ceb2a435fb26b036551ffde8bb74 (patch) | |
tree | fa4cdf924a6569339f9d100477a3005f3718fb58 /externals/grill/xsample/source | |
parent | 21859fabaa92215068d7176e504ac0d59d4301a5 (diff) |
*** empty log message ***
svn path=/trunk/; revision=3981
Diffstat (limited to 'externals/grill/xsample/source')
-rw-r--r-- | externals/grill/xsample/source/groove.cpp | 88 | ||||
-rw-r--r-- | externals/grill/xsample/source/main.cpp | 20 | ||||
-rw-r--r-- | externals/grill/xsample/source/main.h | 12 |
3 files changed, 81 insertions, 39 deletions
diff --git a/externals/grill/xsample/source/groove.cpp b/externals/grill/xsample/source/groove.cpp index d76e3776..2a7cbeec 100644 --- a/externals/grill/xsample/source/groove.cpp +++ b/externals/grill/xsample/source/groove.cpp @@ -341,22 +341,44 @@ void xgroove::s_pos_loop(int n,t_sample *const *invecs,t_sample *const *outvecs) if(plen > 0) { register double o = curpos; - for(int i = 0; i < n; ++i) { - const t_sample spd = speed[i]; // must be first because the vector is reused for output! + if(wrap && smin < 0 && smax >= buf.Frames()) { + for(int i = 0; i < n; ++i) { + const t_sample spd = speed[i]; // must be first because the vector is reused for output! + + // normalize offset + if(!(o < smax)) { // faster than o >= smax + o = fmod(o-smin,plen)+smin; + lpbang = true; + } + else if(o < smin) { + o = fmod(o-smin,plen)+smax; + lpbang = true; + } - // normalize offset - if(!(o < smax)) { // faster than o >= smax - o = fmod(o-smin,plen)+smin; - lpbang = true; - } - else if(o < smin) { - o = fmod(o-smin,plen)+smax; - lpbang = true; - } + // TODO normalize to 0...buf.Frames() + pos[i] = o; + o += spd; + } + } + else { + for(int i = 0; i < n; ++i) { + const t_sample spd = speed[i]; // must be first because the vector is reused for output! + + // normalize offset + if(!(o < smax)) { // faster than o >= smax + o = fmod(o-smin,plen)+smin; + lpbang = true; + } + else if(o < smin) { + o = fmod(o-smin,plen)+smax; + lpbang = true; + } + + pos[i] = o; + o += spd; + } + } - pos[i] = o; - o += spd; - } // normalize and store current playing position setpos(o); @@ -667,13 +689,15 @@ bool xgroove::do_xzone() long lack = CASTINT<long>(ceil((xzone*2.f-(znsmax-znsmin))/2.f)); if(lack > 0) znsmin -= lack,znsmax += lack; - // check buffer limits and shift bounds if necessary - if(znsmin < 0) { - znsmax -= znsmin; - znsmin = 0; - } - if(znsmax > frames) - znsmax = frames; + if(!wrap) { + // check buffer limits and shift bounds if necessary + if(znsmin < 0) { + znsmax -= znsmin; + znsmin = 0; + } + if(znsmax > frames) + znsmax = frames; + } } else if(xfade == xsf_keeplooplen) { // try to keep loop length @@ -689,16 +713,18 @@ bool xgroove::do_xzone() znsmin = curmin-hzone; znsmax = curmax+hzone; - // check buffer limits and shift bounds if necessary - // both cases can't happen because of xzone having been limited above - if(znsmin < 0) { - znsmax -= znsmin; - znsmin = 0; - } - else if(znsmax > frames) { - znsmin -= znsmax-frames; - znsmax = frames; - } + if(!wrap) { + // check buffer limits and shift bounds if necessary + // both cases can't happen because of xzone having been limited above + if(znsmin < 0) { + znsmax -= znsmin; + znsmin = 0; + } + else if(znsmax > frames) { + znsmin -= znsmax-frames; + znsmax = frames; + } + } } else if(xfade == xsf_keeplooppos) { // try to keep loop position and length diff --git a/externals/grill/xsample/source/main.cpp b/externals/grill/xsample/source/main.cpp index df0c1456..c62df461 100644 --- a/externals/grill/xsample/source/main.cpp +++ b/externals/grill/xsample/source/main.cpp @@ -49,7 +49,7 @@ void xsample::setup(t_classid c) } xsample::xsample(): - update(xsc_all), + update(xsc_all),wrap(false), #if FLEXT_SYS == FLEXT_SYS_MAX unitmode(xsu_ms), // Max/MSP defaults to milliseconds #else @@ -168,12 +168,18 @@ void xsample::DoUpdate(unsigned int flags) if(flags&xsc_range && buf.Ok()) { const int f = buf.Frames(); - - if(curmin < 0) curmin = 0; - else if(curmin > f) curmin = f; - - if(curmax > f) curmax = f; - else if(curmax < curmin) curmax = curmin; + + if(!wrap) { + // normalize bounds + if(curmin < 0) curmin = 0; + else if(curmin > f) curmin = f; + + if(curmax > f) curmax = f; + else if(curmax < curmin) curmax = curmin; + } + else + // don't normalize + if(curmax < curmin) curmax = curmin; } if(flags&xsc_units) { diff --git a/externals/grill/xsample/source/main.h b/externals/grill/xsample/source/main.h index 6fb1bd2c..9d9f94b8 100644 --- a/externals/grill/xsample/source/main.h +++ b/externals/grill/xsample/source/main.h @@ -15,7 +15,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #error You need at least flext version 0.5.0 #endif -#define XSAMPLE_VERSION "0.3.1" +#define XSAMPLE_VERSION "0.3.2pre" extern "C++" { @@ -191,6 +191,12 @@ protected: Refresh(); } + void m_wrap(bool w) + { + wrap = w; + Update(xsc_pos|xsc_range,true); + } + void m_min(float mn); void m_max(float mx); @@ -201,6 +207,7 @@ protected: long sclmin; // in samples float sclmul; float s2u; // sample to unit conversion factor + bool wrap; inline float scale(float smp) const { return (smp-sclmin)*sclmul; } @@ -266,6 +273,9 @@ private: FLEXT_ATTRGET_F(s2u) + FLEXT_CALLSET_B(m_wrap) + FLEXT_ATTRGET_B(wrap) + protected: FLEXT_CALLGET_F(mg_min) FLEXT_CALLGET_F(mg_max) |