ref: a899e1ac27ea18e300713f6e49f2ed7541290797
parent: c39e469c76573e0fd129e7f65c7286af82d7702b
parent: c38b5b8fbda3d691abd51b3e10410a95b5b1a10a
author: spiricom <jeff@snyderphonics.com>
date: Tue May 25 15:21:38 EDT 2021
wavetable efficiency fixes
--- a/TestPlugin/Source/MyTest.cpp
+++ b/TestPlugin/Source/MyTest.cpp
@@ -40,6 +40,7 @@
const int numWavetables = 1;
tWaveTable wavetables[numWavetables];
+tSimpleRetune retune;
float gain;
float dtime;
@@ -61,8 +62,11 @@
void LEAFTest_init (float sampleRate, int blockSize)
{
- LEAF_init(&leaf, sampleRate, blockSize, memory, MSIZE, &getRandomFloat);
+ LEAF_init(&leaf, sampleRate, memory, MSIZE, &getRandomFloat);
+ tSimpleRetune_init(&retune, 1, 100, 1200, 2048, &leaf);
+ tSimpleRetune_setMode(&retune, 1);
+
// tWaveTable_init(&wt, __leaf_table_sawtooth[0], 2048, 10000.f, &leaf);
// tWaveTableS_init(&cwt, __leaf_table_sawtooth[0], 2048, 10000.f, &leaf);
@@ -101,6 +105,10 @@
float LEAFTest_tick (float input)
{
+ tSimpleRetune_tuneVoice(&retune, 0, mtof(roundf(ftom(tSimpleRetune_getInputFrequency(&retune)))));
+ return tSimpleRetune_tick(&retune, input);
+
+
float out = 0.0f;
for (int i = 0; i < fmin(loadedAudio.size(), numWavetables); ++i)
{
--- a/leaf/Inc/leaf-effects.h
+++ b/leaf/Inc/leaf-effects.h
@@ -610,6 +610,7 @@
tPitchShift* ps;
+ float* pdBuffer;
float* inBuffer;
float* outBuffer;
int bufSize;
--- a/leaf/Src/leaf-effects.c
+++ b/leaf/Src/leaf-effects.c
@@ -1061,7 +1061,7 @@
w->loopSize = loopSize;
w->pitchfactor = 1.;
- w->delaybuf = (float*) mpool_calloc(sizeof(float) * w->loopSize, m);
+ w->delaybuf = (float*) mpool_calloc(sizeof(float) * (w->loopSize+1), m);
w->timeindex = 0;
w->xfadevalue = -1;
@@ -1095,7 +1095,7 @@
{
float sample = tHighpass_tick(&w->hp, in[0]);
w->delaybuf[0] = sample;
- w->delaybuf[w->loopSize-1] = sample; // copy one sample for interpolation
+ w->delaybuf[w->loopSize] = sample; // copy one sample for interpolation
n--;
i++;
in++;
@@ -1500,6 +1500,7 @@
r->bufSize = bufSize;
r->numVoices = numVoices;
+ r->pdBuffer = (float*) mpool_alloc(sizeof(float) * 2048, m);
r->inBuffer = (float*) mpool_calloc(sizeof(float) * r->bufSize, m);
r->outBuffer = (float*) mpool_calloc(sizeof(float) * r->bufSize, m);
@@ -1510,7 +1511,7 @@
r->minInputFreq = minInputFreq;
r->maxInputFreq = maxInputFreq;
- tDualPitchDetector_initToPool(&r->dp, r->minInputFreq, r->maxInputFreq, r->inBuffer, r->bufSize, mp);
+ tDualPitchDetector_initToPool(&r->dp, r->minInputFreq, r->maxInputFreq, r->pdBuffer, 2048, mp);
for (int i = 0; i < r->numVoices; ++i)
{
@@ -1546,7 +1547,8 @@
float out = r->outBuffer[r->index];
r->outBuffer[r->index] = 0.0f;
- if (++r->index >= r->bufSize)
+ r->index++;
+ if (r->index >= r->bufSize)
{
for (int i = 0; i < r->numVoices; ++i)
{
@@ -1696,7 +1698,8 @@
r->outBuffers[i][r->index] = 0.0f;
}
- if (++r->index >= r->bufSize)
+ r->index++;
+ if (r->index >= r->bufSize)
{
for (int i = 0; i < r->numVoices; ++i)
{