aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/xsample
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2003-07-21 02:37:30 +0000
committerThomas Grill <xovo@users.sourceforge.net>2003-07-21 02:37:30 +0000
commit44d97258734b898c3cb0f8cdfd199352de2bfc2d (patch)
treecfd4b290bf99188fed99834c45f418236707ea04 /externals/grill/xsample
parentcd0dbb399460d8c6e28a07c726bc914cfcda5ab3 (diff)
""
svn path=/trunk/; revision=782
Diffstat (limited to 'externals/grill/xsample')
-rw-r--r--externals/grill/xsample/source/groove.cpp99
-rwxr-xr-xexternals/grill/xsample/source/inter.h4
-rw-r--r--externals/grill/xsample/source/main.h2
3 files changed, 100 insertions, 5 deletions
diff --git a/externals/grill/xsample/source/groove.cpp b/externals/grill/xsample/source/groove.cpp
index 41f2248b..4759812c 100644
--- a/externals/grill/xsample/source/groove.cpp
+++ b/externals/grill/xsample/source/groove.cpp
@@ -93,7 +93,11 @@ private:
DEFSIGFUN(s_pos_off);
DEFSIGFUN(s_pos_once);
+ DEFSIGFUN(s_pos_c_once);
+ DEFSIGFUN(s_pos_a_once);
DEFSIGFUN(s_pos_loop);
+ DEFSIGFUN(s_pos_c_loop);
+ DEFSIGFUN(s_pos_a_loop);
DEFSIGFUN(s_pos_loopzn);
DEFSIGFUN(s_pos_bidir);
@@ -132,7 +136,7 @@ private:
};
-FLEXT_LIB_DSP_V("xgroove~",xgroove)
+FLEXT_LIB_DSP_V("xgroove~",xgroove)
V xgroove::setup(t_classid c)
@@ -419,7 +423,7 @@ V xgroove::s_pos_once(I n,S *const *invecs,S *const *outvecs)
S *pos = outvecs[outchns];
BL lpbang = false;
- const I smin = curmin,smax = curmax,plen = smax-smin; //curlen;
+ const D smin = curmin,smax = curmax,plen = smax-smin; //curlen;
if(buf && plen > 0) {
register D o = curpos;
@@ -446,6 +450,48 @@ V xgroove::s_pos_once(I n,S *const *invecs,S *const *outvecs)
if(lpbang) ToOutBang(outchns+3);
}
+// \TODO optimize that for spd = const!
+V xgroove::s_pos_c_once(I n,S *const *invecs,S *const *outvecs)
+{
+ const S spd = *invecs[0];
+ S *pos = outvecs[outchns];
+ BL lpbang = false;
+
+ const D smin = curmin,smax = curmax,plen = smax-smin; //curlen;
+
+ if(buf && plen > 0) {
+ register D o = curpos;
+
+ for(I i = 0; i < n; ++i) {
+ if(o >= smax) { o = smax; lpbang = true; }
+ else if(o < smin) { o = smin; lpbang = true; }
+
+ pos[i] = o;
+ o += spd;
+ }
+ // normalize and store current playing position
+ setpos(o);
+
+ playfun(n,&pos,outvecs);
+
+ arrscale(n,pos,pos);
+ }
+ else
+ s_pos_off(n,invecs,outvecs);
+
+ if(lpbang) ToOutBang(outchns+3);
+}
+
+V xgroove::s_pos_a_once(I n,S *const *invecs,S *const *outvecs)
+{
+ const S *speed = invecs[0];
+ if(speed[0] == speed[n-1])
+ // assume constant speed
+ s_pos_c_once(n,invecs,outvecs);
+ else
+ s_pos_once(n,invecs,outvecs);
+}
+
V xgroove::s_pos_loop(I n,S *const *invecs,S *const *outvecs)
{
const S *speed = invecs[0];
@@ -486,6 +532,55 @@ V xgroove::s_pos_loop(I n,S *const *invecs,S *const *outvecs)
if(lpbang) ToOutBang(outchns+3);
}
+// \TODO optimize that for spd = const!
+V xgroove::s_pos_c_loop(I n,S *const *invecs,S *const *outvecs)
+{
+ const S spd = *invecs[0];
+ S *pos = outvecs[outchns];
+ BL lpbang = false;
+
+ const D smin = curmin,smax = curmax,plen = smax-smin; //curlen;
+
+ if(buf && plen > 0) {
+ register D o = curpos;
+
+ for(I i = 0; i < n; ++i) {
+ // 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;
+ }
+ // normalize and store current playing position
+ setpos(o);
+
+ playfun(n,&pos,outvecs);
+
+ arrscale(n,pos,pos);
+ }
+ else
+ s_pos_off(n,invecs,outvecs);
+
+ if(lpbang) ToOutBang(outchns+3);
+}
+
+V xgroove::s_pos_a_loop(I n,S *const *invecs,S *const *outvecs)
+{
+ const S *speed = invecs[0];
+ if(speed[0] == speed[n-1])
+ // assume constant speed
+ s_pos_c_loop(n,invecs,outvecs);
+ else
+ s_pos_loop(n,invecs,outvecs);
+}
+
V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs)
{
const S *speed = invecs[0];
diff --git a/externals/grill/xsample/source/inter.h b/externals/grill/xsample/source/inter.h
index 602bfd49..3f8ea5f8 100755
--- a/externals/grill/xsample/source/inter.h
+++ b/externals/grill/xsample/source/inter.h
@@ -128,14 +128,14 @@ TMPLDEF V xinter::st_play4(const S *bdt,const I smin,const I smax,const I n,cons
register I oint = (I)o,ointm,oint1,oint2;
if(oint <= smin) {
- if(oint < smin) oint = smin,o = smin;
+ if(oint < smin) oint = smin,o = (float)smin;
// position is first simple
ointm = smin; // first sample
oint1 = oint+1;
oint2 = oint1+1;
}
else if(oint >= maxo-2) {
- if(oint > maxo) oint = maxo,o = smax;
+ if(oint > maxo) oint = maxo,o = (float)smax;
ointm = oint-1;
oint1 = oint >= maxo?maxo:oint+1;
oint2 = oint1 >= maxo?maxo:oint1+1;
diff --git a/externals/grill/xsample/source/main.h b/externals/grill/xsample/source/main.h
index 6dce2711..b3b8a499 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.0pre11"
+#define XSAMPLE_VERSION "0.3.0pre12"
#define FLEXT_ATTRIBUTES 1