ref: ad69b23d21b20df735bb9fb2bccad7ab0c907f07
parent: 0659ec34571cfa3b83fc8c4a9719f75ff4126ec2
author: mulshine <mulshine@princeton.edu>
date: Tue May 14 12:37:30 EDT 2019
Changes to sampler.
--- a/LEAF/Inc/leaf-globals.h
+++ b/LEAF/Inc/leaf-globals.h
@@ -25,13 +25,13 @@
float invSampleRate;
int blockSize;
- /*
+
float* sinewave;
float* sawtooth[11];
float* square[11];
float* triangle[11];
- */
+
float (*random)(void);
} LEAF;
@@ -57,7 +57,7 @@
// Feel free to change to suit memory constraints or desired delay max length / functionality.
-
+#define TALKBOX_BUFFER_LENGTH 1600 // Every talkbox instance introduces 5 buffers of this size
union unholy_t { /* a union between a float and an integer */
float f;
--- a/LEAF/Inc/leaf-sample.h
+++ b/LEAF/Inc/leaf-sample.h
@@ -77,6 +77,7 @@
float idx;
float inc;
+ float last;
float iinc;
int8_t dir;
int8_t flip;
--- a/LEAF/Src/leaf-sample.c
+++ b/LEAF/Src/leaf-sample.c
@@ -141,8 +141,13 @@
float tSampler_tick (tSampler* const p)
{
- if (p->active == 0 || (p->len < 4)) return 0.f;
-
+ if (p->active == 0) return 0.f;
+
+ if ((p->inc == 0.0f) || (p->len < 4))
+ {
+ return p->last;
+ }
+
float sample = 0.f;
float cfxsample = 0.f;
int numsamps;
@@ -177,9 +182,9 @@
if (dir > 0)
{
// FORWARD NORMAL SAMPLE
- int i1 = idx-1;
- int i3 = idx+1;
- int i4 = idx+2;
+ int i1 = ((idx-1) + p->len) % p->len;
+ int i3 = (idx+1) % p->len;
+ int i4 = (idx+2) % p->len;
sample = LEAF_interpolate_hermite (buff[i1],
buff[idx],
@@ -198,11 +203,11 @@
{
// CROSSFADE SAMPLE
float idxx = p->idx - p->len;
- int cdx = (int)(idxx);
+ int cdx = ((int)(idxx) + p->len) % p->len;
- i1 = cdx-1;
- i3 = cdx+1;
- i4 = cdx+2;
+ i1 = ((cdx-1) + p->len) % p->len;
+ i3 = (cdx+1) % p->len;
+ i4 = (cdx+2) % p->len;
cfxsample = LEAF_interpolate_hermite (buff[i1],
buff[cdx],
@@ -217,9 +222,9 @@
else
{
// REVERSE
- int i1 = idx+1;
- int i3 = idx-1;
- int i4 = idx-2;
+ int i1 = (idx+1) % p->len;
+ int i3 = ((idx-1) + p->len) % p->len;
+ int i4 = ((idx-2) + p->len) % p->len;
sample = LEAF_interpolate_hermite (buff[i1],
buff[idx],
@@ -235,12 +240,12 @@
{
// CROSSFADE SAMPLE
float idxx = p->idx + p->len + 1.f;
- int cdx = (int)(idxx);
+ int cdx = ((int)(idxx)) % p->len;
alpha = idxx - cdx;
- i1 = cdx+1;
- i3 = cdx-1;
- i4 = cdx-2;
+ i1 = (cdx+1) % p->len;
+ i3 = ((cdx-1) + p->len) % p->len;
+ i4 = ((cdx-2) + p->len) % p->len;
cfxsample = LEAF_interpolate_hermite (buff[i1],
buff[cdx],
@@ -323,7 +328,9 @@
}
}
- return sample;
+ p->last = sample;
+
+ return p->last;
}
void tSampler_setSample (tSampler* const p, tBuffer* s)
binary files a/LEAF_JUCEPlugin/.DS_Store b/LEAF_JUCEPlugin/.DS_Store differ