ref: 9cb36a1965a989fd17f8efee6a0655d79a0f2a76
parent: e3276feeb7fa0502053337c63041220d01369da3
author: Matthew Wang <mjw7@princeton.edu>
date: Tue Feb 4 12:30:09 EST 2020
fix incorrect init ordering in livingstring
--- a/LEAF/Src/leaf-effects.c
+++ b/LEAF/Src/leaf-effects.c
@@ -1268,12 +1268,12 @@
void tAutotune_free(tAutotune* const rt)
{
_tAutotune* r = *rt;
- tPeriodDetection_free(&r->pd);
for (int i = 0; i < r->numVoices; ++i)
{
tPitchShift_free(&r->ps[i]);
leaf_free(r->outBuffers[i]);
}
+ tPeriodDetection_free(&r->pd);
leaf_free(r->tickOutput);
leaf_free(r->freq);
leaf_free(r->ps);
@@ -1311,12 +1311,12 @@
{
_tMempool* m = *mp;
_tAutotune* r = *rt;
- tPeriodDetection_freeFromPool(&r->pd, mp);
for (int i = 0; i < r->numVoices; ++i)
{
tPitchShift_freeFromPool(&r->ps[i], mp);
mpool_free(r->outBuffers[i], &m->pool);
}
+ tPeriodDetection_freeFromPool(&r->pd, mp);
mpool_free(r->tickOutput, &m->pool);
mpool_free(r->freq, &m->pool);
mpool_free(r->ps, &m->pool);
--- a/LEAF/Src/leaf-physical.c
+++ b/LEAF/Src/leaf-physical.c
@@ -555,8 +555,6 @@
p->decay = decay;
p->prepIndex = prepIndex;
p->levMode = levMode;
- tLivingString_setFreq(pl, freq);
- tLivingString_setPickPos(pl, pickPos);
}
void tLivingString_init(tLivingString* const pl, float freq, float pickPos, float prepIndex,
@@ -564,9 +562,11 @@
float levStrength, int levMode)
{
_tLivingString* p = *pl = (_tLivingString*) leaf_alloc(sizeof(_tLivingString));
-
+
tExpSmooth_init(&p->wlSmooth, leaf.sampleRate/freq, 0.01); // smoother for string wavelength (not freq, to avoid expensive divisions)
tExpSmooth_init(&p->ppSmooth, pickPos, 0.01); // smoother for pick position
+ tLivingString_setFreq(pl, freq);
+ tLivingString_setPickPos(pl, pickPos);
tLinearDelay_init(&p->delLF,p->waveLengthInSamples, 2400);
tLinearDelay_init(&p->delUF,p->waveLengthInSamples, 2400);
tLinearDelay_init(&p->delUB,p->waveLengthInSamples, 2400);
@@ -614,6 +614,8 @@
tExpSmooth_initToPool(&p->wlSmooth, leaf.sampleRate/freq, 0.01, mp); // smoother for string wavelength (not freq, to avoid expensive divisions)
tExpSmooth_initToPool(&p->ppSmooth, pickPos, 0.01, mp); // smoother for pick position
+ tLivingString_setFreq(pl, freq);
+ tLivingString_setPickPos(pl, pickPos);
tLinearDelay_initToPool(&p->delLF,p->waveLengthInSamples, 2400, mp);
tLinearDelay_initToPool(&p->delUF,p->waveLengthInSamples, 2400, mp);
tLinearDelay_initToPool(&p->delUB,p->waveLengthInSamples, 2400, mp);