ref: 4f70bc64d136ec816e6a8476429fb1c69be1ffa7
parent: dd56c541b544e4ac9a6e81c1cd367d08b127b2cd
author: Matthew Wang <Matthew@nat-oitwireless-inside-vapornet100-10-8-6-141.princeton.edu>
date: Mon Oct 28 14:46:31 EDT 2019
debugging retune and autotune, removed clip on setting pitch factor
--- a/LEAF/Inc/leaf-effects.h
+++ b/LEAF/Inc/leaf-effects.h
@@ -218,6 +218,7 @@
float* tAutotune_tick (tAutotune* const, float sample);
void tAutotune_setNumVoices (tAutotune* const, int numVoices);
+void tAutotune_setFreqs (tAutotune* const, float f);
void tAutotune_setFreq (tAutotune* const, float f, int voice);
void tAutotune_setTimeConstant (tAutotune* const, float tc);
void tAutotune_setHopSize (tAutotune* const, int hs);
--- a/LEAF/Src/leaf-analysis.c
+++ b/LEAF/Src/leaf-analysis.c
@@ -715,6 +715,7 @@
// modified logarithmic bias function
static void snac_biasbuf(tSNAC* const s)
{
+
int n;
int maxperiod = (int)(s->framesize * (float)SEEK);
float bias = s->biasfactor / log((float)(maxperiod - 4));
--- a/LEAF/Src/leaf-effects.c
+++ b/LEAF/Src/leaf-effects.c
@@ -419,14 +419,20 @@
r->fba = FBA;
tRetune_setTimeConstant(r, DEFTIMECONSTANT);
- tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize);
-
r->inputPeriod = 0.0f;
r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices);
+ r->pitchFactor = (float*) leaf_alloc(sizeof(float) * r->numVoices);
+ r->tickOutput = (float*) leaf_alloc(sizeof(float) * r->numVoices);
for (int i = 0; i < r->numVoices; ++i)
{
r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize);
+ }
+
+ tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize);
+
+ for (int i = 0; i < r->numVoices; ++i)
+ {
tPitchShift_init(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize);
}
}
@@ -439,6 +445,8 @@
tPitchShift_free(&r->ps[i]);
leaf_free(r->outBuffers[i]);
}
+ leaf_free(r->tickOutput);
+ leaf_free(r->pitchFactor);
leaf_free(r->ps);
leaf_free(r->inBuffer);
leaf_free(r->outBuffers);
@@ -463,6 +471,8 @@
tPitchShift_free(&r->ps[i]);
leaf_free(r->outBuffers[i]);
}
+ leaf_free(r->tickOutput);
+ leaf_free(r->pitchFactor);
leaf_free(r->ps);
leaf_free(r->outBuffers);
@@ -470,6 +480,8 @@
r->outBuffers = (float**) leaf_alloc(sizeof(float*) * r->numVoices);
r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices);
+ r->pitchFactor = (float*) leaf_alloc(sizeof(float) * r->numVoices);
+ r->tickOutput = (float*) leaf_alloc(sizeof(float) * r->numVoices);
for (int i = 0; i < r->numVoices; ++i)
{
r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize);
@@ -540,12 +552,20 @@
r->fba = FBA;
tAutotune_setTimeConstant(r, DEFTIMECONSTANT);
- tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize);
+
r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices);
+ r->freq = (float*) leaf_alloc(sizeof(float) * r->numVoices);
+ r->tickOutput = (float*) leaf_alloc(sizeof(float) * r->numVoices);
for (int i = 0; i < r->numVoices; ++i)
{
r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize);
+ }
+
+ tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize);
+
+ for (int i = 0; i < r->numVoices; ++i)
+ {
tPitchShift_init(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize);
}
@@ -560,6 +580,8 @@
tPitchShift_free(&r->ps[i]);
leaf_free(r->outBuffers[i]);
}
+ leaf_free(r->tickOutput);
+ leaf_free(r->freq);
leaf_free(r->ps);
leaf_free(r->inBuffer);
leaf_free(r->outBuffers);
@@ -584,6 +606,8 @@
tPitchShift_free(&r->ps[i]);
leaf_free(r->outBuffers[i]);
}
+ leaf_free(r->tickOutput);
+ leaf_free(r->freq);
leaf_free(r->ps);
leaf_free(r->outBuffers);
@@ -591,6 +615,8 @@
r->outBuffers = (float**) leaf_alloc(sizeof(float*) * r->numVoices);
r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices);
+ r->freq = (float*) leaf_alloc(sizeof(float) * r->numVoices);
+ r->tickOutput = (float*) leaf_alloc(sizeof(float) * r->numVoices);
for (int i = 0; i < r->numVoices; ++i)
{
r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize);
@@ -600,7 +626,7 @@
}
-void tAutotune_setFreq(tAutotune* const r, float f, int voice)
+void tAutotune_setFreqs(tAutotune* const r, float f)
{
for (int i = 0; i < r->numVoices; ++i)
{
@@ -608,6 +634,11 @@
}
}
+void tAutotune_setFreq(tAutotune* const r, float f, int voice)
+{
+ r->freq[voice] = f;
+}
+
void tAutotune_setTimeConstant(tAutotune* const r, float tc)
{
r->timeConstant = tc;
@@ -644,7 +675,7 @@
{
float envout;
- envout = tEnv_tick(&ps->p->env);
+ envout = tEnvPD_tick(&ps->p->env);
if (envout >= 1.0f)
{
@@ -846,8 +877,7 @@
// set pitch factor between 0.25 and 4
void tSOLAD_setPitchFactor(tSOLAD* const w, float pitchfactor)
{
- if(pitchfactor < 0.25) pitchfactor = 0.25;
- else if(pitchfactor > 4.) pitchfactor = 4.;
+ if (pitchfactor <= 0.0f) return;
w->pitchfactor = pitchfactor;
}
--- a/LEAF_JUCEPlugin/Source/MyTest.cpp
+++ b/LEAF_JUCEPlugin/Source/MyTest.cpp
@@ -19,6 +19,8 @@
tNoise noise;
tCycle sine;
tDelay delay;
+tRetune retune;
+tAutotune autotune;
float gain;
float freq;
@@ -39,16 +41,23 @@
tDelay_init(&delay, 44100, 44100);
tDelay_free(&delay); //most basic free test
tDelay_init(&delay, 44100, 44100);
+
+ tRetune_init(&retune, 1, 4096, 2048);
+ tAutotune_init(&autotune, 1, 4096, 2048);
}
float LEAFTest_tick (float input)
{
- tCycle_setFreq(&sine, freq);
- float sample = tCycle_tick(&sine) * 0.1;
- tDelay_setDelay(&delay, dtime);
- sample += tDelay_tick(&delay, sample);
+ float sample = tCycle_tick(&sine);
+ float* retuneOut = tRetune_tick(&retune, sample);
+ float* autotuneOut = tAutotune_tick(&autotune, sample);
+ float r1 = retuneOut[0];
+ //float r2 = retuneOut[1];
+ float a1 = autotuneOut[0];
+ //float a2 = autotuneOut[1];
+ sample = a1;
- return sample;
+ return sample * 0.25f;
}
@@ -57,10 +66,12 @@
void LEAFTest_block (void)
{
float val = getSliderValue("mod freq");
- freq = val * 2000.f;
+ tRetune_setPitchFactor(&retune, val*4.0f + 0.5f, 0);
+ tAutotune_setFreq(&autotune, val*5000.0f + 50.0f, 0);
val = getSliderValue("mod depth");
- dtime = val * 40000.;
+ tRetune_setPitchFactor(&retune, val*4.0f + 0.5f, 1);
+ tAutotune_setFreq(&autotune, val*5000.0f + 50.0f, 1);
}
void LEAFTest_controllerInput (int cnum, float cval)