shithub: leaf

Download patch

ref: 7618da1b969d617ad1e339fcabcf3a73afb33ceb
parent: b0581564da7738318ea9f7805fb2bd3b0b73bcc4
author: Matthew Wang <mjw7@princeton.edu>
date: Wed Feb 5 09:43:59 EST 2020

Revert changes since "shared static init functions for use in init and initToPool"
This reverts commit to before 7156be01b28b4d4c7d688277a6db209526c5b43d.

--- a/LEAF/Inc/leaf-reverb.h
+++ b/LEAF/Inc/leaf-reverb.h
@@ -31,8 +31,6 @@
         
         float inv_441;
         
-        int lengths[4];
-        
         tDelay allpassDelays[2];
         tDelay combDelay;
         float allpassCoeff;
@@ -65,8 +63,6 @@
         float mix, t60;
         
         float inv_sr, inv_441;
-        
-        int lengths[15];
         
         tLinearDelay allpassDelays[8];
         tLinearDelay combDelays[6];
--- a/LEAF/Inc/leaf-sampling.h
+++ b/LEAF/Inc/leaf-sampling.h
@@ -124,6 +124,8 @@
     void    tSampler_setStart           (tSampler* const, int32_t start);
     void    tSampler_setEnd             (tSampler* const, int32_t end);
 
+    static void handleStartEndChange    (tSampler* const sp);
+
     void 	tSampler_setCrossfadeLength (tSampler* const sp, uint32_t length);
     
     void    tSampler_setRate            (tSampler* const, float rate);
--- a/LEAF/Src/leaf-analysis.c
+++ b/LEAF/Src/leaf-analysis.c
@@ -21,9 +21,10 @@
 //===========================================================================
 /* Envelope Follower */
 //===========================================================================
-static void    envelopefollower_init(tEnvelopeFollower* const ef, float attackThreshold, float decayCoeff)
+
+void    tEnvelopeFollower_init(tEnvelopeFollower* const ef, float attackThreshold, float decayCoeff)
 {
-    _tEnvelopeFollower* e = *ef;
+    _tEnvelopeFollower* e = *ef = (_tEnvelopeFollower*) leaf_alloc(sizeof(_tEnvelopeFollower));
     
     e->y = 0.0f;
     e->a_thresh = attackThreshold;
@@ -30,15 +31,10 @@
     e->d_coeff = decayCoeff;
 }
 
-void    tEnvelopeFollower_init(tEnvelopeFollower* const ef, float attackThreshold, float decayCoeff)
-{
-    *ef = (_tEnvelopeFollower*) leaf_alloc(sizeof(_tEnvelopeFollower));
-    envelopefollower_init(ef, attackThreshold, decayCoeff);
-}
-
 void tEnvelopeFollower_free(tEnvelopeFollower* const ef)
 {
     _tEnvelopeFollower* e = *ef;
+    
     leaf_free(e);
 }
 
@@ -45,8 +41,11 @@
 void    tEnvelopeFollower_initToPool    (tEnvelopeFollower* const ef, float attackThreshold, float decayCoeff, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *ef = (_tEnvelopeFollower*) mpool_alloc(sizeof(_tEnvelopeFollower), &m->pool);
-    envelopefollower_init(ef, attackThreshold, decayCoeff);
+    _tEnvelopeFollower* e = *ef = (_tEnvelopeFollower*) mpool_alloc(sizeof(_tEnvelopeFollower), &m->pool);
+    
+    e->y = 0.0f;
+    e->a_thresh = attackThreshold;
+    e->d_coeff = decayCoeff;
 }
 
 void    tEnvelopeFollower_freeFromPool  (tEnvelopeFollower* const ef, tMempool* const mp)
@@ -53,6 +52,7 @@
 {
     _tMempool* m = *mp;
     _tEnvelopeFollower* e = *ef;
+    
     mpool_free(e, &m->pool);
 }
 
@@ -89,9 +89,9 @@
 //===========================================================================
 /* Power Follower */
 //===========================================================================
-static void    powerfollower_init(tPowerFollower* const pf, float factor)
+void    tPowerFollower_init(tPowerFollower* const pf, float factor)
 {
-    _tPowerFollower* p = *pf;
+    _tPowerFollower* p = *pf = (_tPowerFollower*) leaf_alloc(sizeof(_tPowerFollower));
     
     p->curr=0.0f;
     p->factor=factor;
@@ -98,15 +98,10 @@
     p->oneminusfactor=1.0f-factor;
 }
 
-void    tPowerFollower_init(tPowerFollower* const pf, float factor)
-{
-    *pf = (_tPowerFollower*) leaf_alloc(sizeof(_tPowerFollower));
-    powerfollower_init(pf, factor);
-}
-
 void tPowerFollower_free(tPowerFollower* const pf)
 {
     _tPowerFollower* p = *pf;
+    
     leaf_free(p);
 }
 
@@ -113,8 +108,11 @@
 void    tPowerFollower_initToPool   (tPowerFollower* const pf, float factor, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *pf = (_tPowerFollower*) mpool_alloc(sizeof(_tPowerFollower), &m->pool);
-    powerfollower_init(pf, factor);
+    _tPowerFollower* p = *pf = (_tPowerFollower*) mpool_alloc(sizeof(_tPowerFollower), &m->pool);
+    
+    p->curr=0.0f;
+    p->factor=factor;
+    p->oneminusfactor=1.0f-factor;
 }
 
 void    tPowerFollower_freeFromPool (tPowerFollower* const pf, tMempool* const mp)
@@ -121,6 +119,7 @@
 {
     _tMempool* m = *mp;
     _tPowerFollower* p = *pf;
+    
     mpool_free(p, &m->pool);
 }
 
@@ -154,9 +153,10 @@
 //===========================================================================
 /* ---------------- env~ - simple envelope follower. ----------------- */
 //===========================================================================
-static void envpd_init(tEnvPD* const xpd, int ws, int hs, int bs)
+
+void tEnvPD_init(tEnvPD* const xpd, int ws, int hs, int bs)
 {
-    _tEnvPD* x = *xpd;
+    _tEnvPD* x = *xpd = (_tEnvPD*) leaf_allocAndClear(sizeof(_tEnvPD));
     
     int period = hs, npoints = ws;
     
@@ -196,15 +196,10 @@
     // ~ ~ ~ ~ ~ ~ ~ ~
 }
 
-void tEnvPD_init(tEnvPD* const xpd, int ws, int hs, int bs)
-{
-    *xpd = (_tEnvPD*) leaf_allocAndClear(sizeof(_tEnvPD));
-    envpd_init(xpd, ws, hs, bs);
-}
-
 void tEnvPD_free (tEnvPD* const xpd)
 {
     _tEnvPD* x = *xpd;
+    
     leaf_free(x);
 }
 
@@ -211,8 +206,44 @@
 void    tEnvPD_initToPool       (tEnvPD* const xpd, int ws, int hs, int bs, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *xpd = (_tEnvPD*) mpool_allocAndClear(sizeof(_tEnvPD), &m->pool);
-    envpd_init(xpd, ws, hs, bs);
+    _tEnvPD* x = *xpd = (_tEnvPD*) mpool_allocAndClear(sizeof(_tEnvPD), &m->pool);
+    
+    int period = hs, npoints = ws;
+    
+    int i;
+    
+    if (npoints < 1) npoints = 1024;
+    if (period < 1) period = npoints/2;
+    if (period < npoints / MAXOVERLAP + 1)
+        period = npoints / MAXOVERLAP + 1;
+    
+    x->x_npoints = npoints;
+    x->x_phase = 0;
+    x->x_period = period;
+    
+    x->windowSize = npoints;
+    x->hopSize = period;
+    x->blockSize = bs;
+    
+    for (i = 0; i < MAXOVERLAP; i++) x->x_sumbuf[i] = 0;
+    for (i = 0; i < npoints; i++)
+        x->buf[i] = (1.0f - cosf((2 * PI * i) / npoints))/npoints;
+    for (; i < npoints+INITVSTAKEN; i++) x->buf[i] = 0;
+    
+    x->x_f = 0;
+    
+    x->x_allocforvs = INITVSTAKEN;
+    
+    // ~ ~ ~ dsp ~ ~ ~
+    if (x->x_period % x->blockSize)
+    {
+        x->x_realperiod = x->x_period + x->blockSize - (x->x_period % x->blockSize);
+    }
+    else
+    {
+        x->x_realperiod = x->x_period;
+    }
+    // ~ ~ ~ ~ ~ ~ ~ ~
 }
 
 void    tEnvPD_freeFromPool     (tEnvPD* const xpd, tMempool* const mp)
@@ -219,6 +250,7 @@
 {
     _tMempool* m = *mp;
     _tEnvPD* x = *xpd;
+    
     mpool_free(x, &m->pool);
 }
 
@@ -426,9 +458,11 @@
 /******************************************************************************/
 /******************************** constructor, destructor *********************/
 /******************************************************************************/
-static void snac_init(tSNAC* const snac, int overlaparg)
+
+
+void tSNAC_init(tSNAC* const snac, int overlaparg)
 {
-    _tSNAC* s = *snac;
+    _tSNAC* s = *snac = (_tSNAC*) leaf_allocAndClear(sizeof(_tSNAC));
     
     s->biasfactor = DEFBIAS;
     s->timeindex = 0;
@@ -438,18 +472,13 @@
     s->minrms = DEFMINRMS;
     s->framesize = SNAC_FRAME_SIZE;
     
-    snac_biasbuf(snac);
-    tSNAC_setOverlap(snac, overlaparg);
-}
-
-void tSNAC_init(tSNAC* const snac, int overlaparg)
-{
-    _tSNAC* s = *snac = (_tSNAC*) leaf_allocAndClear(sizeof(_tSNAC));
     s->inputbuf = (float*) leaf_allocAndClear(sizeof(float) * SNAC_FRAME_SIZE);
     s->processbuf = (float*) leaf_allocAndClear(sizeof(float) * (SNAC_FRAME_SIZE * 2));
     s->spectrumbuf = (float*) leaf_allocAndClear(sizeof(float) * (SNAC_FRAME_SIZE / 2));
     s->biasbuf = (float*) leaf_allocAndClear(sizeof(float) * SNAC_FRAME_SIZE);
-    snac_init(snac, overlaparg);
+    
+    snac_biasbuf(snac);
+    tSNAC_setOverlap(snac, overlaparg);
 }
 
 void tSNAC_free(tSNAC* const snac)
@@ -467,11 +496,22 @@
 {
     _tMempool* m = *mp;
     _tSNAC* s = *snac = (_tSNAC*) mpool_alloc(sizeof(_tSNAC), &m->pool);
+    
+    s->biasfactor = DEFBIAS;
+    s->timeindex = 0;
+    s->periodindex = 0;
+    s->periodlength = 0.;
+    s->fidelity = 0.;
+    s->minrms = DEFMINRMS;
+    s->framesize = SNAC_FRAME_SIZE;
+
     s->inputbuf = (float*) mpool_allocAndClear(sizeof(float) * SNAC_FRAME_SIZE, &m->pool);
     s->processbuf = (float*) mpool_allocAndClear(sizeof(float) * (SNAC_FRAME_SIZE * 2), &m->pool);
     s->spectrumbuf = (float*) mpool_allocAndClear(sizeof(float) * (SNAC_FRAME_SIZE / 2), &m->pool);
     s->biasbuf = (float*) mpool_allocAndClear(sizeof(float) * SNAC_FRAME_SIZE, &m->pool);
-    snac_init(snac, overlaparg);
+    
+    snac_biasbuf(snac);
+    tSNAC_setOverlap(snac, overlaparg);
 }
 
 void    tSNAC_freeFromPool  (tSNAC* const snac, tMempool* const mp)
@@ -478,6 +518,7 @@
 {
     _tMempool* m = *mp;
     _tSNAC* s = *snac;
+    
     mpool_free(s->inputbuf, &m->pool);
     mpool_free(s->processbuf, &m->pool);
     mpool_free(s->spectrumbuf, &m->pool);
@@ -797,9 +838,9 @@
 //===========================================================================
 // PERIODDETECTION
 //===========================================================================
-static void    perioddetection_init    (tPeriodDetection* const pd, float* in, float* out, int bufSize, int frameSize)
+void    tPeriodDetection_init    (tPeriodDetection* const pd, float* in, float* out, int bufSize, int frameSize)
 {
-    _tPeriodDetection* p = *pd;
+    _tPeriodDetection* p = *pd = (_tPeriodDetection*) leaf_allocAndClear(sizeof(_tPeriodDetection));
     
     p->inBuffer = in;
     p->outBuffer = out;
@@ -814,22 +855,18 @@
     p->windowSize = DEFWINDOWSIZE;
     p->fba = FBA;
     
+    tEnvPD_init(&p->env, p->windowSize, p->hopSize, p->frameSize);
+    
+    tSNAC_init(&p->snac, DEFOVERLAP);
+    
     p->timeConstant = DEFTIMECONSTANT;
     p->radius = expf(-1000.0f * p->hopSize * leaf.invSampleRate / p->timeConstant);
 }
 
-void    tPeriodDetection_init    (tPeriodDetection* const pd, float* in, float* out, int bufSize, int frameSize)
-{
-    _tPeriodDetection* p = *pd = (_tPeriodDetection*) leaf_allocAndClear(sizeof(_tPeriodDetection));
-    perioddetection_init(pd, in, out, bufSize, frameSize);
-    
-    tEnvPD_init(&p->env, p->windowSize, p->hopSize, p->frameSize);
-    tSNAC_init(&p->snac, DEFOVERLAP);
-}
-
 void tPeriodDetection_free (tPeriodDetection* const pd)
 {
     _tPeriodDetection* p = *pd;
+    
     tEnvPD_free(&p->env);
     tSNAC_free(&p->snac);
     leaf_free(p);
@@ -839,10 +876,26 @@
 {
     _tMempool* m = *mp;
     _tPeriodDetection* p = *pd = (_tPeriodDetection*) mpool_allocAndClear(sizeof(_tPeriodDetection), &m->pool);
-    perioddetection_init(pd, in, out, bufSize, frameSize);
     
+    p->inBuffer = in;
+    p->outBuffer = out;
+    p->bufSize = bufSize;
+    p->frameSize = frameSize;
+    p->framesPerBuffer = p->bufSize / p->frameSize;
+    p->curBlock = 1;
+    p->lastBlock = 0;
+    p->index = 0;
+    
+    p->hopSize = DEFHOPSIZE;
+    p->windowSize = DEFWINDOWSIZE;
+    p->fba = FBA;
+    
     tEnvPD_initToPool(&p->env, p->windowSize, p->hopSize, p->frameSize, mp);
+    
     tSNAC_initToPool(&p->snac, DEFOVERLAP, mp);
+    
+    p->timeConstant = DEFTIMECONSTANT;
+    p->radius = expf(-1000.0f * p->hopSize * leaf.invSampleRate / p->timeConstant);
 }
 
 void    tPeriodDetection_freeFromPool       (tPeriodDetection* const pd, tMempool* const mp)
@@ -849,6 +902,7 @@
 {
     _tMempool* m = *mp;
     _tPeriodDetection* p = *pd;
+    
     tEnvPD_freeFromPool(&p->env, mp);
     tSNAC_freeFromPool(&p->snac, mp);
     mpool_free(p, &m->pool);
--- a/LEAF/Src/leaf-delay.c
+++ b/LEAF/Src/leaf-delay.c
@@ -19,31 +19,31 @@
 #endif
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Delay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-static void    delay_init (tDelay* const dl, uint32_t delay, uint32_t maxDelay)
+void    tDelay_init (tDelay* const dl, uint32_t delay, uint32_t maxDelay)
 {
-    _tDelay* d = *dl;
+    _tDelay* d = *dl = (_tDelay*) leaf_alloc(sizeof(_tDelay));
     
     d->maxDelay = maxDelay;
+    
     d->delay = delay;
+    
+    d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay);
+    
     d->inPoint = 0;
     d->outPoint = 0;
+    
     d->lastIn = 0.0f;
     d->lastOut = 0.0f;
+    
     d->gain = 1.0f;
     
     tDelay_setDelay(dl, d->delay);
 }
 
-void    tDelay_init (tDelay* const dl, uint32_t delay, uint32_t maxDelay)
-{
-    _tDelay* d = *dl = (_tDelay*) leaf_alloc(sizeof(_tDelay));
-    d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay);
-    delay_init(dl, delay, maxDelay);
-}
-
 void tDelay_free(tDelay* const dl)
 {
     _tDelay* d = *dl;
+    
     leaf_free(d->buff);
     leaf_free(d);
 }
@@ -52,8 +52,22 @@
 {
     _tMempool* m = *mp;
     _tDelay* d = *dl = (_tDelay*) mpool_alloc(sizeof(_tDelay), &m->pool);
+    
+    d->maxDelay = maxDelay;
+    
+    d->delay = delay;
+    
     d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, &m->pool);
-    delay_init(dl, delay, maxDelay);
+    
+    d->inPoint = 0;
+    d->outPoint = 0;
+    
+    d->lastIn = 0.0f;
+    d->lastOut = 0.0f;
+    
+    d->gain = 1.0f;
+    
+    tDelay_setDelay(dl, d->delay);
 }
 
 void        tDelay_freeFromPool (tDelay* const dl, tMempool* const mp)
@@ -60,6 +74,7 @@
 {
     _tMempool* m = *mp;
     _tDelay* d = *dl;
+    
     mpool_free(d->buff, &m->pool);
     mpool_free(d, &m->pool);
 }
@@ -162,19 +177,23 @@
 }
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ LinearDelay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-static void   lineardelay_init (tLinearDelay* const dl, float delay, uint32_t maxDelay)
+void   tLinearDelay_init (tLinearDelay* const dl, float delay, uint32_t maxDelay)
 {
-    _tLinearDelay* d = *dl;
+    _tLinearDelay* d = *dl = (_tLinearDelay*) leaf_alloc(sizeof(_tLinearDelay));
     
     d->maxDelay = maxDelay;
-    
+
     if (delay > maxDelay)   d->delay = maxDelay;
     else if (delay < 0.0f)  d->delay = 0.0f;
     else                    d->delay = delay;
     
+    d->buff = (float*) leaf_allocAndClear(sizeof(float) * maxDelay);
+    
     d->gain = 1.0f;
+    
     d->lastIn = 0.0f;
     d->lastOut = 0.0f;
+
     d->inPoint = 0;
     d->outPoint = 0;
     
@@ -181,16 +200,10 @@
     tLinearDelay_setDelay(dl, d->delay);
 }
 
-void   tLinearDelay_init (tLinearDelay* const dl, float delay, uint32_t maxDelay)
-{
-    _tLinearDelay* d = *dl = (_tLinearDelay*) leaf_alloc(sizeof(_tLinearDelay));
-    d->buff = (float*) leaf_allocAndClear(sizeof(float) * maxDelay);
-    lineardelay_init(dl, delay, maxDelay);
-}
-
 void tLinearDelay_free(tLinearDelay* const dl)
 {
     _tLinearDelay* d = *dl;
+    
     leaf_free(d->buff);
     leaf_free(d);
 }
@@ -199,8 +212,24 @@
 {
     _tMempool* m = *mp;
     _tLinearDelay* d = *dl = (_tLinearDelay*) mpool_alloc(sizeof(_tLinearDelay), &m->pool);
-    d->buff = (float*) mpool_allocAndClear(sizeof(float) * maxDelay, &m->pool);
-    lineardelay_init(dl, delay, maxDelay);
+    
+    d->maxDelay = maxDelay;
+    
+    if (delay > maxDelay)   d->delay = maxDelay;
+    else if (delay < 0.0f)  d->delay = 0.0f;
+    else                    d->delay = delay;
+    
+    d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, &m->pool);
+    
+    d->gain = 1.0f;
+    
+    d->lastIn = 0.0f;
+    d->lastOut = 0.0f;
+    
+    d->inPoint = 0;
+    d->outPoint = 0;
+    
+    tLinearDelay_setDelay(dl, d->delay);
 }
 
 void    tLinearDelay_freeFromPool(tLinearDelay* const dl, tMempool* const mp)
@@ -207,6 +236,7 @@
 {
     _tMempool* m = *mp;
     _tLinearDelay* d = *dl;
+    
     mpool_free(d->buff, &m->pool);
     mpool_free(d, &m->pool);
 }
@@ -218,6 +248,8 @@
 	{
 		d->buff[i] = 0;
 	}
+
+
 }
 
 float   tLinearDelay_tick (tLinearDelay* const dl, float input)
@@ -361,37 +393,38 @@
 }
 
 
+
+
+
 /// Hermite Interpolated Delay
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ LinearDelay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-static void   hermitedelay_init (tHermiteDelay* const dl, float delay, uint32_t maxDelay)
+void   tHermiteDelay_init (tHermiteDelay* const dl, float delay, uint32_t maxDelay)
 {
-    _tHermiteDelay* d = *dl;
-    
+	_tHermiteDelay* d = *dl = (_tHermiteDelay*) leaf_alloc(sizeof(_tHermiteDelay));
+
     d->maxDelay = maxDelay;
-    
+
     if (delay > maxDelay)   d->delay = maxDelay;
     else if (delay < 0.0f)  d->delay = 0.0f;
     else                    d->delay = delay;
 
+    d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay);
+
     d->gain = 1.0f;
+
     d->lastIn = 0.0f;
     d->lastOut = 0.0f;
+
     d->inPoint = 0;
     d->outPoint = 0;
-    
+
     tHermiteDelay_setDelay(dl, d->delay);
 }
 
-void   tHermiteDelay_init (tHermiteDelay* const dl, float delay, uint32_t maxDelay)
-{
-	_tHermiteDelay* d = *dl = (_tHermiteDelay*) leaf_alloc(sizeof(_tHermiteDelay));
-    d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay);
-    hermitedelay_init(dl, delay, maxDelay);
-}
-
 void tHermiteDelay_free(tHermiteDelay* const dl)
 {
 	_tHermiteDelay* d = *dl;
+
     leaf_free(d->buff);
     leaf_free(d);
 }
@@ -400,8 +433,24 @@
 {
     _tMempool* m = *mp;
     _tHermiteDelay* d = *dl = (_tHermiteDelay*) mpool_alloc(sizeof(_tHermiteDelay), &m->pool);
+
+    d->maxDelay = maxDelay;
+
+    if (delay > maxDelay)   d->delay = maxDelay;
+    else if (delay < 0.0f)  d->delay = 0.0f;
+    else                    d->delay = delay;
+
     d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, &m->pool);
-    hermitedelay_init(dl, delay, maxDelay);
+
+    d->gain = 1.0f;
+
+    d->lastIn = 0.0f;
+    d->lastOut = 0.0f;
+
+    d->inPoint = 0;
+    d->outPoint = 0;
+
+    tHermiteDelay_setDelay(dl, d->delay);
 }
 
 void    tHermiteDelay_freeFromPool(tHermiteDelay* const dl, tMempool* const mp)
@@ -408,6 +457,7 @@
 {
     _tMempool* m = *mp;
     _tHermiteDelay* d = *dl;
+
     mpool_free(d->buff, &m->pool);
     mpool_free(d, &m->pool);
 }
@@ -420,6 +470,8 @@
 	{
 		d->buff[i] = 0;
 	}
+
+
 }
 
 float   tHermiteDelay_tick (tHermiteDelay* const dl, float input)
@@ -564,10 +616,14 @@
     return d->gain;
 }
 
+
+
+
+
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ AllpassDelay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-static void  allpass_init (tAllpassDelay* const dl, float delay, uint32_t maxDelay)
+void  tAllpassDelay_init (tAllpassDelay* const dl, float delay, uint32_t maxDelay)
 {
-    _tAllpassDelay* d = *dl;
+    _tAllpassDelay* d = *dl = (_tAllpassDelay*) leaf_alloc(sizeof(_tAllpassDelay));
     
     d->maxDelay = maxDelay;
     
@@ -575,25 +631,25 @@
     else if (delay < 0.0f)  d->delay = 0.0f;
     else                    d->delay = delay;
     
+    d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay);
+    
     d->gain = 1.0f;
+    
     d->lastIn = 0.0f;
     d->lastOut = 0.0f;
+    
     d->inPoint = 0;
     d->outPoint = 0;
+    
     tAllpassDelay_setDelay(dl, d->delay);
+    
     d->apInput = 0.0f;
 }
 
-void  tAllpassDelay_init (tAllpassDelay* const dl, float delay, uint32_t maxDelay)
-{
-    _tAllpassDelay* d = *dl = (_tAllpassDelay*) leaf_alloc(sizeof(_tAllpassDelay));
-    d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay);
-    allpass_init(dl, delay, maxDelay);
-}
-
 void tAllpassDelay_free(tAllpassDelay* const dl)
 {
     _tAllpassDelay* d = *dl;
+    
     leaf_free(d->buff);
     leaf_free(d);
 }
@@ -602,8 +658,26 @@
 {
     _tMempool* m = *mp;
     _tAllpassDelay* d = *dl = (_tAllpassDelay*) mpool_alloc(sizeof(_tAllpassDelay), &m->pool);
+    
+    d->maxDelay = maxDelay;
+    
+    if (delay > maxDelay)   d->delay = maxDelay;
+    else if (delay < 0.0f)  d->delay = 0.0f;
+    else                    d->delay = delay;
+    
     d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, &m->pool);
-    allpass_init(dl, delay, maxDelay);
+    
+    d->gain = 1.0f;
+    
+    d->lastIn = 0.0f;
+    d->lastOut = 0.0f;
+    
+    d->inPoint = 0;
+    d->outPoint = 0;
+    
+    tAllpassDelay_setDelay(dl, d->delay);
+    
+    d->apInput = 0.0f;
 }
 
 void    tAllpassDelay_freeFromPool(tAllpassDelay* const dl, tMempool* const mp)
@@ -610,6 +684,7 @@
 {
     _tMempool* m = *mp;
     _tAllpassDelay* d = *dl;
+    
     mpool_free(d->buff, &m->pool);
     mpool_free(d, &m->pool);
 }
@@ -740,14 +815,19 @@
 }
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ TapeDelay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-static void   tapedelay_init (tTapeDelay* const dl, float delay, uint32_t maxDelay)
+void   tTapeDelay_init (tTapeDelay* const dl, float delay, uint32_t maxDelay)
 {
-    _tTapeDelay* d = *dl;
+    _tTapeDelay* d = *dl = (_tTapeDelay*) leaf_alloc(sizeof(_tTapeDelay));
     
     d->maxDelay = maxDelay;
+
+    d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay);
+    
     d->gain = 1.0f;
+    
     d->lastIn = 0.0f;
     d->lastOut = 0.0f;
+    
     d->idx = 0.0f;
     d->inc = 1.0f;
     d->inPoint = 0;
@@ -755,16 +835,10 @@
     tTapeDelay_setDelay(dl, delay);
 }
 
-void   tTapeDelay_init (tTapeDelay* const dl, float delay, uint32_t maxDelay)
-{
-    _tTapeDelay* d = *dl = (_tTapeDelay*) leaf_alloc(sizeof(_tTapeDelay));
-    d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay);
-    tapedelay_init(dl, delay, maxDelay);
-}
-
 void tTapeDelay_free(tTapeDelay* const dl)
 {
     _tTapeDelay* d = *dl;
+    
     leaf_free(d->buff);
     leaf_free(d);
 }
@@ -773,8 +847,21 @@
 {
     _tMempool* m = *mp;
     _tTapeDelay* d = *dl = (_tTapeDelay*) mpool_alloc(sizeof(_tTapeDelay), &m->pool);
+    
+    d->maxDelay = maxDelay;
+    
     d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, &m->pool);
-    tapedelay_init(dl, delay, maxDelay);
+    
+    d->gain = 1.0f;
+    
+    d->lastIn = 0.0f;
+    d->lastOut = 0.0f;
+    
+    d->idx = 0.0f;
+    d->inc = 1.0f;
+    d->inPoint = 0;
+    
+    tTapeDelay_setDelay(dl, delay);
 }
 
 void    tTapeDelay_freeFromPool(tTapeDelay* const dl, tMempool* const mp)
@@ -781,6 +868,7 @@
 {
     _tMempool* m = *mp;
     _tTapeDelay* d = *dl;
+    
     mpool_free(d->buff, &m->pool);
     mpool_free(d, &m->pool);
 }
@@ -814,8 +902,8 @@
     
     if (d->idx >= d->maxDelay) d->idx = 0.0f;
 
-    if (d->lastOut) return d->lastOut;
-    else return 0.0f;
+    if (d->lastOut)
+    return d->lastOut;
 }
 
 void  tTapeDelay_incrementInPoint(tTapeDelay* const dl)
--- a/LEAF/Src/leaf-distortion.c
+++ b/LEAF/Src/leaf-distortion.c
@@ -25,9 +25,10 @@
 // Sample-Rate reducer
 //============================================================================================================
 
-static void samplereducer_init(tSampleReducer* const sr)
+
+void tSampleReducer_init(tSampleReducer* const sr)
 {
-    _tSampleReducer* s = *sr;
+    _tSampleReducer* s = *sr = (_tSampleReducer*) leaf_alloc(sizeof(_tSampleReducer));
     
     s->invRatio = 1.0f;
     s->hold = 0.0f;
@@ -34,15 +35,10 @@
     s->count = 0;
 }
 
-void tSampleReducer_init(tSampleReducer* const sr)
-{
-    *sr = (_tSampleReducer*) leaf_alloc(sizeof(_tSampleReducer));
-    samplereducer_init(sr);
-}
-
 void    tSampleReducer_free    (tSampleReducer* const sr)
 {
     _tSampleReducer* s = *sr;
+    
     leaf_free(s);
 }
 
@@ -49,8 +45,11 @@
 void    tSampleReducer_initToPool   (tSampleReducer* const sr, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *sr = (_tSampleReducer*) mpool_alloc(sizeof(_tSampleReducer), &m->pool);
-    samplereducer_init(sr);
+    _tSampleReducer* s = *sr = (_tSampleReducer*) mpool_alloc(sizeof(_tSampleReducer), &m->pool);
+    
+    s->invRatio = 1.0f;
+    s->hold = 0.0f;
+    s->count = 0;
 }
 
 void    tSampleReducer_freeFromPool (tSampleReducer* const sr, tMempool* const mp)
@@ -57,6 +56,7 @@
 {
     _tMempool* m = *mp;
     _tSampleReducer* s = *sr;
+    
     mpool_free(s, &m->pool);
 }
 
@@ -85,9 +85,10 @@
 //============================================================================================================
 // Oversampler
 //============================================================================================================
-static void oversampler_init(tOversampler* const osr, int ratio, oBool extraQuality)
+// Latency is equal to the phase length (numTaps / ratio)
+void tOversampler_init(tOversampler* const osr, int ratio, oBool extraQuality)
 {
-    _tOversampler* os = *osr;
+    _tOversampler* os = *osr = (_tOversampler*) leaf_alloc(sizeof(_tOversampler));
     
     uint8_t offset = 0;
     if (extraQuality) offset = 6;
@@ -99,17 +100,6 @@
         os->numTaps = firNumTaps[idx];
         os->phaseLength = os->numTaps / os->ratio;
         os->pCoeffs = (float*) firCoeffs[idx];
-    }
-}
-
-// Latency is equal to the phase length (numTaps / ratio)
-void tOversampler_init(tOversampler* const osr, int ratio, oBool extraQuality)
-{
-    _tOversampler* os = *osr = (_tOversampler*) leaf_alloc(sizeof(_tOversampler));
-    oversampler_init(osr, ratio, extraQuality);
-    if (ratio == 2 || ratio == 4  ||
-        ratio == 8 || ratio == 16 ||
-        ratio == 32 || ratio == 64) {
         os->upState = leaf_alloc(sizeof(float) * os->numTaps * 2);
         os->downState = leaf_alloc(sizeof(float) * os->numTaps * 2);
     }
@@ -118,6 +108,7 @@
 void tOversampler_free(tOversampler* const osr)
 {
     _tOversampler* os = *osr;
+    
     leaf_free(os->upState);
     leaf_free(os->downState);
     leaf_free(os);
@@ -127,10 +118,17 @@
 {
     _tMempool* m = *mp;
     _tOversampler* os = *osr = (_tOversampler*) mpool_alloc(sizeof(_tOversampler), &m->pool);
-    oversampler_init(osr, ratio, extraQuality);
+    
+    uint8_t offset = 0;
+    if (extraQuality) offset = 6;
     if (ratio == 2 || ratio == 4  ||
         ratio == 8 || ratio == 16 ||
         ratio == 32 || ratio == 64) {
+        os->ratio = ratio;
+        int idx = (int)(log2f(os->ratio))-1+offset;
+        os->numTaps = firNumTaps[idx];
+        os->phaseLength = os->numTaps / os->ratio;
+        os->pCoeffs = (float*) firCoeffs[idx];
         os->upState = mpool_alloc(sizeof(float) * os->numTaps * 2, &m->pool);
         os->downState = mpool_alloc(sizeof(float) * os->numTaps * 2, &m->pool);
     }
@@ -140,6 +138,7 @@
 {
     _tMempool* m = *mp;
     _tOversampler* os = *osr;
+    
     mpool_free(os->upState, &m->pool);
     mpool_free(os->downState, &m->pool);
     mpool_free(os, &m->pool);
@@ -347,40 +346,39 @@
 //============================================================================================================
 // WAVEFOLDER
 //============================================================================================================
+
+
 //from the paper: Virtual Analog Model of the Lockhart Wavefolder
 //by Fabián Esqueda, Henri Pöntynen, Julian D. Parker and Stefan Bilbao
-static void lockhartwavefolder_init(tLockhartWavefolder* const wf)
+
+void tLockhartWavefolder_init(tLockhartWavefolder* const wf)
 {
-    _tLockhartWavefolder* w = *wf;
+    _tLockhartWavefolder* w = *wf = (_tLockhartWavefolder*) leaf_alloc(sizeof(_tLockhartWavefolder));
     
     w->Ln1 = 0.0;
     w->Fn1 = 0.0;
     w->xn1 = 0.0f;
-    
+
     w->RL = 7.5e3;
     w->R = 15e3;
     w->VT = 26e-3;
     w->Is = 10e-16;
-    
+
     w->a = 2.0*w->RL/w->R;
     w->b = (w->R+2.0*w->RL)/(w->VT*w->R);
     w->d = (w->RL*w->Is)/w->VT;
     w->half_a = 0.5 * w->a;
     w->longthing = (0.5*w->VT/w->b);
-    
+
+
     // Antialiasing error threshold
     w->thresh = 10e-10;
 }
 
-void tLockhartWavefolder_init(tLockhartWavefolder* const wf)
-{
-    *wf = (_tLockhartWavefolder*) leaf_alloc(sizeof(_tLockhartWavefolder));
-    lockhartwavefolder_init(wf);
-}
-
 void tLockhartWavefolder_free(tLockhartWavefolder* const wf)
 {
     _tLockhartWavefolder* w = *wf;
+    
     leaf_free(w);
 }
 
@@ -387,8 +385,26 @@
 void    tLockhartWavefolder_initToPool   (tLockhartWavefolder* const wf, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *wf = (_tLockhartWavefolder*) mpool_alloc(sizeof(_tLockhartWavefolder), &m->pool);
-    lockhartwavefolder_init(wf);
+    _tLockhartWavefolder* w = *wf = (_tLockhartWavefolder*) mpool_alloc(sizeof(_tLockhartWavefolder), &m->pool);
+    
+    w->Ln1 = 0.0;
+    w->Fn1 = 0.0;
+    w->xn1 = 0.0f;
+    
+    w->RL = 7.5e3;
+    w->R = 15e3;
+    w->VT = 26e-3;
+    w->Is = 10e-16;
+    
+    w->a = 2.0*w->RL/w->R;
+    w->b = (w->R+2.0*w->RL)/(w->VT*w->R);
+    w->d = (w->RL*w->Is)/w->VT;
+    w->half_a = 0.5 * w->a;
+    w->longthing = (0.5*w->VT/w->b);
+    
+    
+    // Antialiasing error threshold
+    w->thresh = 10e-10;
 }
 
 void    tLockhartWavefolder_freeFromPool (tLockhartWavefolder* const wf, tMempool* const mp)
@@ -395,6 +411,7 @@
 {
     _tMempool* m = *mp;
     _tLockhartWavefolder* w = *wf;
+    
     mpool_free(w, &m->pool);
 }
 
@@ -471,24 +488,19 @@
 // CRUSHER
 //============================================================================================================
 #define SCALAR 5000.f
-static void    crusher_init    (tCrusher* const cr)
+
+void    tCrusher_init    (tCrusher* const cr)
 {
-    _tCrusher* c = *cr;
+    _tCrusher* c = *cr = (_tCrusher*) leaf_alloc(sizeof(_tCrusher));
     
     c->op = 4;
     c->div = SCALAR;
     c->rnd = 0.25f;
     c->srr = 0.25f;
+    tSampleReducer_init(&c->sReducer);
     c->gain = (c->div / SCALAR) * 0.7f + 0.3f;
 }
 
-void    tCrusher_init    (tCrusher* const cr)
-{
-    _tCrusher* c = *cr = (_tCrusher*) leaf_alloc(sizeof(_tCrusher));
-    crusher_init(cr);
-    tSampleReducer_init(&c->sReducer);
-}
-
 void    tCrusher_free    (tCrusher* const cr)
 {
     _tCrusher* c = *cr;
@@ -500,8 +512,13 @@
 {
     _tMempool* m = *mp;
     _tCrusher* c = *cr = (_tCrusher*) mpool_alloc(sizeof(_tCrusher), &m->pool);
-    crusher_init(cr);
+    
+    c->op = 4;
+    c->div = SCALAR;
+    c->rnd = 0.25f;
+    c->srr = 0.25f;
     tSampleReducer_initToPool(&c->sReducer, mp);
+    c->gain = (c->div / SCALAR) * 0.7f + 0.3f;
 }
 
 void    tCrusher_freeFromPool (tCrusher* const cr, tMempool* const mp)
--- a/LEAF/Src/leaf-dynamics.c
+++ b/LEAF/Src/leaf-dynamics.c
@@ -19,9 +19,31 @@
 //==============================================================================
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Compressor ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-static void    compressor_init(tCompressor* const comp)
+
+/*
+ tCompressor*    tCompressorInit(int tauAttack, int tauRelease)
+ {
+ tCompressor* c = &leaf.tCompressorRegistry[leaf.registryIndex[T_COMPRESSOR]++];
+ 
+ c->tauAttack = tauAttack;
+ c->tauRelease = tauRelease;
+ 
+ c->x_G[0] = 0.0f, c->x_G[1] = 0.0f,
+ c->y_G[0] = 0.0f, c->y_G[1] = 0.0f,
+ c->x_T[0] = 0.0f, c->x_T[1] = 0.0f,
+ c->y_T[0] = 0.0f, c->y_T[1] = 0.0f;
+ 
+ c->T = 0.0f; // Threshold
+ c->R = 1.0f; // compression Ratio
+ c->M = 0.0f; // decibel Make-up gain
+ c->W = 0.0f; // decibel Width of knee transition
+ 
+ return c;
+ }
+ */
+void    tCompressor_init(tCompressor* const comp)
 {
-    _tCompressor* c = *comp;
+    _tCompressor* c = *comp = (_tCompressor*) leaf_alloc(sizeof(_tCompressor));
     
     c->tauAttack = 100;
     c->tauRelease = 100;
@@ -34,15 +56,10 @@
     c->W = 1.0f; // decibel Make-up gain
 }
 
-void    tCompressor_init(tCompressor* const comp)
-{
-    *comp = (_tCompressor*) leaf_alloc(sizeof(_tCompressor));
-    compressor_init(comp);
-}
-
 void tCompressor_free(tCompressor* const comp)
 {
     _tCompressor* c = *comp;
+    
     leaf_free(c);
 }
 
@@ -49,8 +66,17 @@
 void    tCompressor_initToPool  (tCompressor* const comp, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *comp = (_tCompressor*) mpool_alloc(sizeof(_tCompressor), &m->pool);
-    compressor_init(comp);
+    _tCompressor* c = *comp = (_tCompressor*) mpool_alloc(sizeof(_tCompressor), &m->pool);
+    
+    c->tauAttack = 100;
+    c->tauRelease = 100;
+    
+    c->isActive = OFALSE;
+    
+    c->T = 0.0f; // Threshold
+    c->R = 0.5f; // compression Ratio
+    c->M = 3.0f; // decibel Width of knee transition
+    c->W = 1.0f; // decibel Make-up gain
 }
 
 void    tCompressor_freeFromPool(tCompressor* const comp, tMempool* const mp)
@@ -57,6 +83,7 @@
 {
     _tMempool* m = *mp;
     _tCompressor* c = *comp;
+    
     mpool_free(c, &m->pool);
 }
 
@@ -110,26 +137,22 @@
 }
 
 /* Feedback Leveler */
-static void    feedbackleveler_init(tFeedbackLeveler* const fb, float targetLevel, float factor, float strength, int mode)
-{
-    _tFeedbackLeveler* p = *fb;
-    
-    p->curr = 0.0f;
-    p->targetLevel = targetLevel;
-    p->mode = mode;
-    p->strength = strength;
-}
 
 void    tFeedbackLeveler_init(tFeedbackLeveler* const fb, float targetLevel, float factor, float strength, int mode)
 {
     _tFeedbackLeveler* p = *fb = (_tFeedbackLeveler*) leaf_alloc(sizeof(_tFeedbackLeveler));
-    feedbackleveler_init(fb, targetLevel, factor, strength, mode);
+    
+    p->curr=0.0f;
+    p->targetLevel=targetLevel;
     tPowerFollower_init(&p->pwrFlw,factor);
+    p->mode=mode;
+    p->strength=strength;
 }
 
 void tFeedbackLeveler_free(tFeedbackLeveler* const fb)
 {
     _tFeedbackLeveler* p = *fb;
+    
     tPowerFollower_free(&p->pwrFlw);
     leaf_free(p);
 }
@@ -138,8 +161,12 @@
 {
     _tMempool* m = *mp;
     _tFeedbackLeveler* p = *fb = (_tFeedbackLeveler*) mpool_alloc(sizeof(_tFeedbackLeveler), &m->pool);
-    feedbackleveler_init(fb, targetLevel, factor, strength, mode);
-    tPowerFollower_initToPool(&p->pwrFlw, factor, mp);
+    
+    p->curr=0.0f;
+    p->targetLevel=targetLevel;
+    tPowerFollower_initToPool(&p->pwrFlw,factor, mp);
+    p->mode=mode;
+    p->strength=strength;
 }
 
 void    tFeedbackLeveler_freeFromPool   (tFeedbackLeveler* const fb, tMempool* const mp)
@@ -146,6 +173,7 @@
 {
     _tMempool* m = *mp;
     _tFeedbackLeveler* p = *fb;
+    
     tPowerFollower_freeFromPool(&p->pwrFlw, mp);
     mpool_free(p, &m->pool);
 }
--- a/LEAF/Src/leaf-effects.c
+++ b/LEAF/Src/leaf-effects.c
@@ -18,13 +18,17 @@
 
 #endif
 
+
+
 //============================================================================================================
 // TALKBOX
 //============================================================================================================
-static void talkbox_init(tTalkbox* const voc, int bufsize)
+
+void tTalkbox_init(tTalkbox* const voc, int bufsize)
 {
-    _tTalkbox* v = *voc;
     
+    _tTalkbox* v = *voc = (_tTalkbox*) leaf_alloc(sizeof(_tTalkbox));
+    
     v->param[0] = 0.5f;  //wet
     v->param[1] = 0.0f;  //dry
     v->param[2] = 0; // Swap
@@ -32,29 +36,26 @@
     
     v->bufsize = bufsize;
     
+    v->car0 =   (float*) leaf_alloc(sizeof(float) * v->bufsize);
+    v->car1 =   (float*) leaf_alloc(sizeof(float) * v->bufsize);
+    v->window = (float*) leaf_alloc(sizeof(float) * v->bufsize);
+    v->buf0 =   (float*) leaf_alloc(sizeof(float) * v->bufsize);
+    v->buf1 =   (float*) leaf_alloc(sizeof(float) * v->bufsize);
+    
     tTalkbox_update(voc);
     tTalkbox_suspend(voc);
 }
 
-void tTalkbox_init(tTalkbox* const voc, int bufsize)
-{
-    _tTalkbox* v = *voc = (_tTalkbox*) leaf_alloc(sizeof(_tTalkbox));
-    v->car0 =   (float*) leaf_alloc(sizeof(float) * bufsize);
-    v->car1 =   (float*) leaf_alloc(sizeof(float) * bufsize);
-    v->window = (float*) leaf_alloc(sizeof(float) * bufsize);
-    v->buf0 =   (float*) leaf_alloc(sizeof(float) * bufsize);
-    v->buf1 =   (float*) leaf_alloc(sizeof(float) * bufsize);
-    talkbox_init(voc, bufsize);
-}
-
 void tTalkbox_free(tTalkbox* const voc)
 {
     _tTalkbox* v = *voc;
+    
     leaf_free(v->buf1);
     leaf_free(v->buf0);
     leaf_free(v->window);
     leaf_free(v->car1);
     leaf_free(v->car0);
+    
     leaf_free(v);
 }
 
@@ -62,12 +63,22 @@
 {
     _tMempool* m = *mp;
     _tTalkbox* v = *voc = (_tTalkbox*) mpool_alloc(sizeof(_tTalkbox), &m->pool);
-    v->car0 =   (float*) mpool_alloc(sizeof(float) * bufsize, &m->pool);
-    v->car1 =   (float*) mpool_alloc(sizeof(float) * bufsize, &m->pool);
-    v->window = (float*) mpool_alloc(sizeof(float) * bufsize, &m->pool);
-    v->buf0 =   (float*) mpool_alloc(sizeof(float) * bufsize, &m->pool);
-    v->buf1 =   (float*) mpool_alloc(sizeof(float) * bufsize, &m->pool);
-    talkbox_init(voc, bufsize);
+    
+    v->param[0] = 0.5f;  //wet
+    v->param[1] = 0.0f;  //dry
+    v->param[2] = 0; // Swap
+    v->param[3] = 1.0f;  //quality
+    
+    v->bufsize = bufsize;
+    
+    v->car0 =   (float*) mpool_alloc(sizeof(float) * v->bufsize, &m->pool);
+    v->car1 =   (float*) mpool_alloc(sizeof(float) * v->bufsize, &m->pool);
+    v->window = (float*) mpool_alloc(sizeof(float) * v->bufsize, &m->pool);
+    v->buf0 =   (float*) mpool_alloc(sizeof(float) * v->bufsize, &m->pool);
+    v->buf1 =   (float*) mpool_alloc(sizeof(float) * v->bufsize, &m->pool);
+    
+    tTalkbox_update(voc);
+    tTalkbox_suspend(voc);
 }
 
 void    tTalkbox_freeFromPool   (tTalkbox* const voc, tMempool* const mp)
@@ -74,11 +85,13 @@
 {
     _tMempool* m = *mp;
     _tTalkbox* v = *voc;
+    
     mpool_free(v->buf1, &m->pool);
     mpool_free(v->buf0, &m->pool);
     mpool_free(v->window, &m->pool);
     mpool_free(v->car1, &m->pool);
     mpool_free(v->car0, &m->pool);
+    
     mpool_free(v, &m->pool);
 }
 
@@ -266,9 +279,9 @@
 // VOCODER
 //============================================================================================================
 
-static void   vocoder_init        (tVocoder* const voc)
+void   tVocoder_init        (tVocoder* const voc)
 {
-    _tVocoder* v = *voc;
+    _tVocoder* v = *voc = (_tVocoder*) leaf_alloc(sizeof(_tVocoder));
     
     v->param[0] = 0.33f;  //input select
     v->param[1] = 0.50f;  //output dB
@@ -282,15 +295,10 @@
     tVocoder_update(voc);
 }
 
-void   tVocoder_init        (tVocoder* const voc)
-{
-    *voc = (_tVocoder*) leaf_alloc(sizeof(_tVocoder));
-    vocoder_init(voc);
-}
-
 void tVocoder_free (tVocoder* const voc)
 {
     _tVocoder* v = *voc;
+    
     leaf_free(v);
 }
 
@@ -297,8 +305,18 @@
 void    tVocoder_initToPool     (tVocoder* const voc, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *voc = (_tVocoder*) mpool_alloc(sizeof(_tVocoder), &m->pool);
-    vocoder_init(voc);
+    _tVocoder* v = *voc = (_tVocoder*) mpool_alloc(sizeof(_tVocoder), &m->pool);
+    
+    v->param[0] = 0.33f;  //input select
+    v->param[1] = 0.50f;  //output dB
+    v->param[2] = 0.40f;  //hi thru
+    v->param[3] = 0.40f;  //hi band
+    v->param[4] = 0.16f;  //envelope
+    v->param[5] = 0.55f;  //filter q
+    v->param[6] = 0.6667f;//freq range
+    v->param[7] = 0.33f;  //num bands
+    
+    tVocoder_update(voc);
 }
 
 void    tVocoder_freeFromPool   (tVocoder* const voc, tMempool* const mp)
@@ -305,6 +323,7 @@
 {
     _tMempool* m = *mp;
     _tVocoder* v = *voc;
+    
     mpool_free(v, &m->pool);
 }
 
@@ -854,9 +873,9 @@
     return (p->fba == 0 && (p->max > 60 && p->deltamax > 6)) ? 1 : 0;
 }
 
-static void pitchshift_init (tPitchShift* const psr, tPeriodDetection* pd, float* out, int bufSize)
+void tPitchShift_init (tPitchShift* const psr, tPeriodDetection* pd, float* out, int bufSize)
 {
-    _tPitchShift* ps = *psr;
+    _tPitchShift* ps = *psr = (_tPitchShift*) leaf_allocAndClear(sizeof(_tPitchShift));
     _tPeriodDetection* p = *pd;
     
     ps->p = pd;
@@ -870,20 +889,17 @@
     ps->index = 0;
     ps->pitchFactor = 1.0f;
     
-    tSOLAD_setPitchFactor(&ps->sola, DEFPITCHRATIO);
-}
-
-void tPitchShift_init (tPitchShift* const psr, tPeriodDetection* pd, float* out, int bufSize)
-{
-    _tPitchShift* ps = *psr = (_tPitchShift*) leaf_allocAndClear(sizeof(_tPitchShift));
     tSOLAD_init(&ps->sola);
+    
     tHighpass_init(&ps->hp, HPFREQ);
-    pitchshift_init(psr, pd, out, bufSize);
+    
+    tSOLAD_setPitchFactor(&ps->sola, DEFPITCHRATIO);
 }
 
 void tPitchShift_free(tPitchShift* const psr)
 {
     _tPitchShift* ps = *psr;
+    
     tSOLAD_free(&ps->sola);
     tHighpass_free(&ps->hp);
     leaf_free(ps);
@@ -892,10 +908,27 @@
 void    tPitchShift_initToPool      (tPitchShift* const psr, tPeriodDetection* const pd, float* out, int bufSize, tMempool* const mp)
 {
     _tMempool* m = *mp;
+
     _tPitchShift* ps = *psr = (_tPitchShift*) mpool_allocAndClear(sizeof(_tPitchShift), &m->pool);
+
+    _tPeriodDetection* p = *pd;
+    
+    ps->p = pd;
+    
+    ps->outBuffer = out;
+    ps->bufSize = bufSize;
+    ps->frameSize = p->frameSize;
+    ps->framesPerBuffer = ps->bufSize / ps->frameSize;
+    ps->curBlock = 1;
+    ps->lastBlock = 0;
+    ps->index = 0;
+    ps->pitchFactor = 1.0f;
+    
     tSOLAD_initToPool(&ps->sola, mp);
+    
     tHighpass_initToPool(&ps->hp, HPFREQ, mp);
-    pitchshift_init(psr, pd, out, bufSize);
+    
+    tSOLAD_setPitchFactor(&ps->sola, DEFPITCHRATIO);
 }
 
 void    tPitchShift_freeFromPool    (tPitchShift* const psr, tMempool* const mp)
@@ -902,6 +935,7 @@
 {
     _tMempool* m = *mp;
     _tPitchShift* ps = *psr;
+    
     tSOLAD_freeFromPool(&ps->sola, mp);
     tHighpass_freeFromPool(&ps->hp, mp);
     mpool_free(ps, &m->pool);
@@ -1023,14 +1057,18 @@
 //============================================================================================================
 // RETUNE
 //============================================================================================================
-static void retune_init(tRetune* const rt, int numVoices, int bufSize, int frameSize)
+
+void tRetune_init(tRetune* const rt, int numVoices, int bufSize, int frameSize)
 {
-    _tRetune* r = *rt;
+    _tRetune* r = *rt = (_tRetune*) leaf_allocAndClear(sizeof(_tRetune));
     
     r->bufSize = bufSize;
     r->frameSize = frameSize;
     r->numVoices = numVoices;
-
+    
+    r->inBuffer = (float*) leaf_allocAndClear(sizeof(float) * r->bufSize);
+    r->outBuffers = (float**) leaf_allocAndClear(sizeof(float*) * r->numVoices);
+    
     r->hopSize = DEFHOPSIZE;
     r->windowSize = DEFWINDOWSIZE;
     r->fba = FBA;
@@ -1037,16 +1075,7 @@
     tRetune_setTimeConstant(rt, DEFTIMECONSTANT);
     
     r->inputPeriod = 0.0f;
-}
-
-void tRetune_init(tRetune* const rt, int numVoices, int bufSize, int frameSize)
-{
-    _tRetune* r = *rt = (_tRetune*) leaf_allocAndClear(sizeof(_tRetune));
-    retune_init(rt, numVoices, bufSize, frameSize);
     
-    r->inBuffer = (float*) leaf_allocAndClear(sizeof(float) * r->bufSize);
-    r->outBuffers = (float**) leaf_allocAndClear(sizeof(float*) * r->numVoices);
-    
     r->ps = (tPitchShift*) leaf_allocAndClear(sizeof(tPitchShift) * r->numVoices);
     r->pitchFactor = (float*) leaf_allocAndClear(sizeof(float) * r->numVoices);
     r->tickOutput = (float*) leaf_allocAndClear(sizeof(float) * r->numVoices);
@@ -1066,6 +1095,7 @@
 void tRetune_free(tRetune* const rt)
 {
     _tRetune* r = *rt;
+    
     tPeriodDetection_free(&r->pd);
     for (int i = 0; i < r->numVoices; ++i)
     {
@@ -1084,10 +1114,20 @@
 {
     _tMempool* m = *mp;
     _tRetune* r = *rt = (_tRetune*) mpool_alloc(sizeof(_tRetune), &m->pool);
-    retune_init(rt, numVoices, bufSize, frameSize);
     
+    r->bufSize = bufSize;
+    r->frameSize = frameSize;
+    r->numVoices = numVoices;
+    
     r->inBuffer = (float*) mpool_allocAndClear(sizeof(float) * r->bufSize, &m->pool);
     r->outBuffers = (float**) mpool_allocAndClear(sizeof(float*) * r->numVoices, &m->pool);
+    
+    r->hopSize = DEFHOPSIZE;
+    r->windowSize = DEFWINDOWSIZE;
+    r->fba = FBA;
+    tRetune_setTimeConstant(rt, DEFTIMECONSTANT);
+    
+    r->inputPeriod = 0.0f;
 
     r->ps = (tPitchShift*) mpool_allocAndClear(sizeof(tPitchShift) * r->numVoices, &m->pool);
     r->pitchFactor = (float*) mpool_allocAndClear(sizeof(float) * r->numVoices, &m->pool);
@@ -1109,6 +1149,7 @@
 {
     _tMempool* m = *mp;
     _tRetune* r = *rt;
+    
     tPeriodDetection_freeFromPool(&r->pd, mp);
     for (int i = 0; i < r->numVoices; ++i)
     {
@@ -1162,6 +1203,8 @@
         r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize);
         tPitchShift_init(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize);
     }
+    
+    
 }
 
 void tRetune_setPitchFactors(tRetune* const rt, float pf)
@@ -1225,30 +1268,24 @@
 // AUTOTUNE
 //============================================================================================================
 
-static void autotune_init(tAutotune* const rt, int numVoices, int bufSize, int frameSize)
+void tAutotune_init(tAutotune* const rt, int numVoices, int bufSize, int frameSize)
 {
-    _tAutotune* r = *rt;
+    _tAutotune* r = *rt = (_tAutotune*) leaf_alloc(sizeof(_tAutotune));
     
     r->bufSize = bufSize;
     r->frameSize = frameSize;
     r->numVoices = numVoices;
     
+    r->inBuffer = (float*) leaf_alloc(sizeof(float) * r->bufSize);
+    r->outBuffers = (float**) leaf_alloc(sizeof(float*) * r->numVoices);
+    
     r->hopSize = DEFHOPSIZE;
     r->windowSize = DEFWINDOWSIZE;
     r->fba = FBA;
     tAutotune_setTimeConstant(rt, DEFTIMECONSTANT);
-
-    r->inputPeriod = 0.0f;
-}
-
-void tAutotune_init(tAutotune* const rt, int numVoices, int bufSize, int frameSize)
-{
-    _tAutotune* r = *rt = (_tAutotune*) leaf_alloc(sizeof(_tAutotune));
-    autotune_init(rt, numVoices, bufSize, frameSize);
     
-    r->inBuffer = (float*) leaf_alloc(sizeof(float) * r->bufSize);
-    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);
@@ -1263,11 +1300,15 @@
     {
         tPitchShift_init(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize);
     }
+    
+    r->inputPeriod = 0.0f;
 }
 
 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]);
@@ -1285,11 +1326,21 @@
 {
     _tMempool* m = *mp;
     _tAutotune* r = *rt = (_tAutotune*) mpool_alloc(sizeof(_tAutotune), &m->pool);
-    autotune_init(rt, numVoices, bufSize, frameSize);
-
+    
+    r->bufSize = bufSize;
+    r->frameSize = frameSize;
+    r->numVoices = numVoices;
+    
     r->inBuffer = (float*) mpool_alloc(sizeof(float) * r->bufSize, &m->pool);
     r->outBuffers = (float**) mpool_alloc(sizeof(float*) * r->numVoices, &m->pool);
-
+    
+    r->hopSize = DEFHOPSIZE;
+    r->windowSize = DEFWINDOWSIZE;
+    r->fba = FBA;
+    tAutotune_setTimeConstant(rt, DEFTIMECONSTANT);
+    
+    
+    
     r->ps = (tPitchShift*) mpool_alloc(sizeof(tPitchShift) * r->numVoices, &m->pool);
     r->freq = (float*) mpool_alloc(sizeof(float) * r->numVoices, &m->pool);
     r->tickOutput = (float*) mpool_alloc(sizeof(float) * r->numVoices, &m->pool);
@@ -1304,6 +1355,8 @@
     {
         tPitchShift_initToPool(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize, mp);
     }
+    
+    r->inputPeriod = 0.0f;
 }
 
 void    tAutotune_freeFromPool      (tAutotune* const rt, tMempool* const mp)
@@ -1310,12 +1363,13 @@
 {
     _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);
@@ -1367,6 +1421,8 @@
         r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize);
         tPitchShift_init(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize);
     }
+    
+    
 }
 
 void tAutotune_setFreqs(tAutotune* const rt, float f)
@@ -1428,28 +1484,12 @@
 // FORMANTSHIFTER
 //============================================================================================================
 // algorithm from Tom Baran's autotalent code.
-static void formantshifter_init(tFormantShifter* const fsr, int order)
-{
-    _tFormantShifter* fs = *fsr;
-    
-    fs->ford = order;
-    fs->falph = powf(0.001f, 40.0f * leaf.invSampleRate);
-    fs->flamb = -(0.8517f*sqrtf(atanf(0.06583f*leaf.sampleRate))-0.1916f);
-    fs->fhp = 0.0f;
-    fs->flp = 0.0f;
-    fs->flpa = powf(0.001f, 10.0f * leaf.invSampleRate);
-    fs->fmute = 1.0f;
-    fs->fmutealph = powf(0.001f, 0.5f * leaf.invSampleRate);
-    fs->cbi = 0;
-    fs->intensity = 1.0f;
-    fs->invIntensity = 1.0f;
-}
 
 void tFormantShifter_init(tFormantShifter* const fsr, int order)
 {
     _tFormantShifter* fs = *fsr = (_tFormantShifter*) leaf_alloc(sizeof(_tFormantShifter));
-    formantshifter_init(fsr, order);
     
+    fs->ford = order;
     fs->fk = (float*) leaf_allocAndClear(sizeof(float) * fs->ford);
     fs->fb = (float*) leaf_allocAndClear(sizeof(float) * fs->ford);
     fs->fc = (float*) leaf_allocAndClear(sizeof(float) * fs->ford);
@@ -1460,6 +1500,16 @@
     fs->ftvec = (float*) leaf_allocAndClear(sizeof(float) * fs->ford);
     fs->fbuff = (float*) leaf_allocAndClear(sizeof(float*) * fs->ford);
 
+    fs->falph = powf(0.001f, 40.0f * leaf.invSampleRate);
+    fs->flamb = -(0.8517f*sqrtf(atanf(0.06583f*leaf.sampleRate))-0.1916f);
+    fs->fhp = 0.0f;
+    fs->flp = 0.0f;
+    fs->flpa = powf(0.001f, 10.0f * leaf.invSampleRate);
+    fs->fmute = 1.0f;
+    fs->fmutealph = powf(0.001f, 0.5f * leaf.invSampleRate);
+    fs->cbi = 0;
+    fs->intensity = 1.0f;
+	fs->invIntensity = 1.0f;
 	tHighpass_init(&fs->hp, 10.0f);
 	tHighpass_init(&fs->hp2, 10.0f);
 	tFeedbackLeveler_init(&fs->fbl1, 0.99f, 0.005f, 0.125f, 0);
@@ -1490,8 +1540,8 @@
 {
     _tMempool* m = *mp;
     _tFormantShifter* fs = *fsr = (_tFormantShifter*) mpool_alloc(sizeof(_tFormantShifter), &m->pool);
-    formantshifter_init(fsr, order);
     
+    fs->ford = order;
     fs->fk = (float*) mpool_allocAndClear(sizeof(float) * fs->ford, &m->pool);
     fs->fb = (float*) mpool_allocAndClear(sizeof(float) * fs->ford, &m->pool);
     fs->fc = (float*) mpool_allocAndClear(sizeof(float) * fs->ford, &m->pool);
@@ -1500,8 +1550,20 @@
     fs->fsig = (float*) mpool_allocAndClear(sizeof(float) * fs->ford, &m->pool);
     fs->fsmooth = (float*) mpool_allocAndClear(sizeof(float) * fs->ford, &m->pool);
     fs->ftvec = (float*) mpool_allocAndClear(sizeof(float) * fs->ford, &m->pool);
+    
     fs->fbuff = (float*) mpool_allocAndClear(sizeof(float*) * fs->ford, &m->pool);
+
     
+    fs->falph = powf(0.001f, 10.0f * leaf.invSampleRate);
+    fs->flamb = -(0.8517f*sqrtf(atanf(0.06583f*leaf.sampleRate))-0.1916f);
+    fs->fhp = 0.0f;
+    fs->flp = 0.0f;
+    fs->flpa = powf(0.001f, 10.0f * leaf.invSampleRate);
+    fs->fmute = 1.0f;
+    fs->fmutealph = powf(0.001f, 1.0f * leaf.invSampleRate);
+    fs->cbi = 0;
+    fs->intensity = 1.0f;
+    fs->invIntensity = 1.0f;
     tHighpass_initToPool(&fs->hp, 20.0f, mp);
     tHighpass_initToPool(&fs->hp2, 20.0f, mp);
     tFeedbackLeveler_initToPool(&fs->fbl1, 0.8f, .005f, 0.125, 1, mp);
--- a/LEAF/Src/leaf-electrical.c
+++ b/LEAF/Src/leaf-electrical.c
@@ -167,6 +167,7 @@
 void tWDF_init(tWDF* const wdf, WDFComponentType type, float value, tWDF* const rL, tWDF* const rR)
 {
     *wdf = (_tWDF*) leaf_alloc(sizeof(_tWDF));
+    
     wdf_init(wdf, type, value, rL, rR);
 }
 
@@ -173,6 +174,7 @@
 void tWDF_free(tWDF* const wdf)
 {
     _tWDF* r = *wdf;
+    
     leaf_free(r);
 }
 
@@ -180,6 +182,7 @@
 {
     _tMempool* m = *mp;
     *wdf = (_tWDF*) mpool_alloc(sizeof(_tWDF), &m->pool);
+    
     wdf_init(wdf, type, value, rL, rR);
 }
 
@@ -187,6 +190,7 @@
 {
     _tMempool* m = *mp;
     _tWDF* r = *wdf;
+    
     mpool_free(r, &m->pool);
 }
 
--- a/LEAF/Src/leaf-envelopes.c
+++ b/LEAF/Src/leaf-envelopes.c
@@ -24,9 +24,9 @@
 #endif
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Envelope ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-static void    envelope_init(tEnvelope* const envlp, float attack, float decay, oBool loop)
+void    tEnvelope_init(tEnvelope* const envlp, float attack, float decay, oBool loop)
 {
-    _tEnvelope* env = *envlp;
+    _tEnvelope* env = *envlp = (_tEnvelope*) leaf_alloc(sizeof(_tEnvelope));
     
     env->exp_buff = exp_decay;
     env->inc_buff = attack_decay_inc;
@@ -64,12 +64,6 @@
     env->rampInc = env->inc_buff[rampIndex];
 }
 
-void    tEnvelope_init(tEnvelope* const envlp, float attack, float decay, oBool loop)
-{
-    *envlp = (_tEnvelope*) leaf_alloc(sizeof(_tEnvelope));
-    envelope_init(envlp, attack, decay, loop);
-}
-
 void tEnvelope_free(tEnvelope* const envlp)
 {
     _tEnvelope* env = *envlp;
@@ -79,8 +73,42 @@
 void    tEnvelope_initToPool    (tEnvelope* const envlp, float attack, float decay, oBool loop, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *envlp = (_tEnvelope*) mpool_alloc(sizeof(_tEnvelope), &m->pool);
-    envelope_init(envlp, attack, decay, loop);
+    _tEnvelope* env = *envlp = (_tEnvelope*) mpool_alloc(sizeof(_tEnvelope), &m->pool);
+    
+    env->exp_buff = exp_decay;
+    env->inc_buff = attack_decay_inc;
+    env->buff_size = sizeof(exp_decay);
+    
+    env->loop = loop;
+    
+    if (attack > 8192.0f)
+        attack = 8192.0f;
+    if (attack < 0.0f)
+        attack = 0.0f;
+    
+    if (decay > 8192.0f)
+        decay = 8192.0f;
+    if (decay < 0.0f)
+        decay = 0.0f;
+    
+    int16_t attackIndex = ((int16_t)(attack * 8.0f))-1;
+    int16_t decayIndex = ((int16_t)(decay * 8.0f))-1;
+    int16_t rampIndex = ((int16_t)(2.0f * 8.0f))-1;
+    
+    if (attackIndex < 0)
+        attackIndex = 0;
+    if (decayIndex < 0)
+        decayIndex = 0;
+    if (rampIndex < 0)
+        rampIndex = 0;
+    
+    env->inRamp = OFALSE;
+    env->inAttack = OFALSE;
+    env->inDecay = OFALSE;
+    
+    env->attackInc = env->inc_buff[attackIndex];
+    env->decayInc = env->inc_buff[decayIndex];
+    env->rampInc = env->inc_buff[rampIndex];
 }
 
 void    tEnvelope_freeFromPool  (tEnvelope* const envlp, tMempool* const mp)
@@ -226,9 +254,9 @@
 }
 
 /* ADSR */
-static void    adsr_init(tADSR* const adsrenv, float attack, float decay, float sustain, float release)
+void    tADSR_init(tADSR* const adsrenv, float attack, float decay, float sustain, float release)
 {
-    _tADSR* adsr = *adsrenv;
+    _tADSR* adsr = *adsrenv = (_tADSR*) leaf_alloc(sizeof(_tADSR));
     
     adsr->exp_buff = exp_decay;
     adsr->inc_buff = attack_decay_inc;
@@ -282,16 +310,10 @@
     adsr->rampInc = adsr->inc_buff[rampIndex];
 }
 
-
-void    tADSR_init(tADSR* const adsrenv, float attack, float decay, float sustain, float release)
-{
-    _tADSR* adsr = *adsrenv = (_tADSR*) leaf_alloc(sizeof(_tADSR));
-    adsr_init(adsrenv, attack, decay, sustain, release);
-}
-
 void tADSR_free(tADSR* const adsrenv)
 {
     _tADSR* adsr = *adsrenv;
+    
     leaf_free(adsr);
 }
 
@@ -298,8 +320,58 @@
 void    tADSR_initToPool    (tADSR* const adsrenv, float attack, float decay, float sustain, float release, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *adsrenv = (_tADSR*) mpool_alloc(sizeof(_tADSR), &m->pool);
-    adsr_init(adsrenv, attack, decay, sustain, release);
+    _tADSR* adsr = *adsrenv = (_tADSR*) mpool_alloc(sizeof(_tADSR), &m->pool);
+    
+    adsr->exp_buff = exp_decay;
+    adsr->inc_buff = attack_decay_inc;
+    adsr->buff_size = sizeof(exp_decay);
+    
+    if (attack > 8192.0f)
+        attack = 8192.0f;
+    if (attack < 0.0f)
+        attack = 0.0f;
+    
+    if (decay > 8192.0f)
+        decay = 8192.0f;
+    if (decay < 0.0f)
+        decay = 0.0f;
+    
+    if (sustain > 1.0f)
+        sustain = 1.0f;
+    if (sustain < 0.0f)
+        sustain = 0.0f;
+    
+    if (release > 8192.0f)
+        release = 8192.0f;
+    if (release < 0.0f)
+        release = 0.0f;
+    
+    int16_t attackIndex = ((int16_t)(attack * 8.0f))-1;
+    int16_t decayIndex = ((int16_t)(decay * 8.0f))-1;
+    int16_t releaseIndex = ((int16_t)(release * 8.0f))-1;
+    int16_t rampIndex = ((int16_t)(2.0f * 8.0f))-1;
+    
+    if (attackIndex < 0)
+        attackIndex = 0;
+    if (decayIndex < 0)
+        decayIndex = 0;
+    if (releaseIndex < 0)
+        releaseIndex = 0;
+    if (rampIndex < 0)
+        rampIndex = 0;
+    
+    adsr->inRamp = OFALSE;
+    adsr->inAttack = OFALSE;
+    adsr->inDecay = OFALSE;
+    adsr->inSustain = OFALSE;
+    adsr->inRelease = OFALSE;
+    
+    adsr->sustain = sustain;
+    
+    adsr->attackInc = adsr->inc_buff[attackIndex];
+    adsr->decayInc = adsr->inc_buff[decayIndex];
+    adsr->releaseInc = adsr->inc_buff[releaseIndex];
+    adsr->rampInc = adsr->inc_buff[rampIndex];
 }
 
 void    tADSR_freeFromPool  (tADSR* const adsrenv, tMempool* const mp)
@@ -306,6 +378,7 @@
 {
     _tMempool* m = *mp;
     _tADSR* adsr = *adsrenv;
+    
     mpool_free(adsr, &m->pool);
 }
 
@@ -489,12 +562,12 @@
 }
 
 /* Ramp */
-static void    ramp_init(tRamp* const r, float time, int samples_per_tick)
+void    tRamp_init(tRamp* const r, float time, int samples_per_tick)
 {
-    _tRamp* ramp = *r;
+    _tRamp* ramp = *r = (_tRamp*) leaf_alloc(sizeof(_tRamp));
     
     ramp->inv_sr_ms = 1.0f/(leaf.sampleRate*0.001f);
-    ramp->minimum_time = ramp->inv_sr_ms * samples_per_tick;
+	ramp->minimum_time = ramp->inv_sr_ms * samples_per_tick;
     ramp->curr = 0.0f;
     ramp->dest = 0.0f;
     
@@ -511,15 +584,10 @@
     ramp->inc = ((ramp->dest - ramp->curr) / ramp->time * ramp->inv_sr_ms) * (float)ramp->samples_per_tick;
 }
 
-void    tRamp_init(tRamp* const r, float time, int samples_per_tick)
-{
-    *r = (_tRamp*) leaf_alloc(sizeof(_tRamp));
-    ramp_init(r, time, samples_per_tick);
-}
-
 void tRamp_free(tRamp* const r)
 {
     _tRamp* ramp = *r;
+    
     leaf_free(ramp);
 }
 
@@ -526,8 +594,24 @@
 void    tRamp_initToPool    (tRamp* const r, float time, int samples_per_tick, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *r = (_tRamp*) mpool_alloc(sizeof(_tRamp), &m->pool);
-    ramp_init(r, time, samples_per_tick);
+    _tRamp* ramp = *r = (_tRamp*) mpool_alloc(sizeof(_tRamp), &m->pool);
+    
+    ramp->inv_sr_ms = 1.0f/(leaf.sampleRate*0.001f);
+    ramp->minimum_time = ramp->inv_sr_ms * samples_per_tick;
+    ramp->curr = 0.0f;
+    ramp->dest = 0.0f;
+    
+    if (time < ramp->minimum_time)
+    {
+        ramp->time = ramp->minimum_time;
+    }
+    else
+    {
+        ramp->time = time;
+    }
+    
+    ramp->samples_per_tick = samples_per_tick;
+    ramp->inc = ((ramp->dest - ramp->curr) / ramp->time * ramp->inv_sr_ms) * (float)ramp->samples_per_tick;
 }
 
 void    tRamp_freeFromPool  (tRamp* const r, tMempool* const mp)
@@ -534,6 +618,7 @@
 {
     _tMempool* m = *mp;
     _tRamp* ramp = *r;
+    
     mpool_free(ramp, &m->pool);
 }
 
@@ -599,27 +684,22 @@
 
 
 /* Exponential Smoother */
-static void    expsmooth_init(tExpSmooth* const expsmooth, float val, float factor)
-{    // factor is usually a value between 0 and 0.1. Lower value is slower. 0.01 for example gives you a smoothing time of about 10ms
-    _tExpSmooth* smooth = *expsmooth;
-    
-    smooth->curr = val;
-    smooth->dest = val;
-    if (factor < 0) factor = 0;
-    if (factor > 1) factor = 1;
-    smooth->factor = factor;
-    smooth->oneminusfactor = 1.0f - factor;
-}
-
 void    tExpSmooth_init(tExpSmooth* const expsmooth, float val, float factor)
 {	// factor is usually a value between 0 and 0.1. Lower value is slower. 0.01 for example gives you a smoothing time of about 10ms
-    *expsmooth = (_tExpSmooth*) leaf_alloc(sizeof(_tExpSmooth));
-    expsmooth_init(expsmooth, val, factor);
+    _tExpSmooth* smooth = *expsmooth = (_tExpSmooth*) leaf_alloc(sizeof(_tExpSmooth));
+    
+	smooth->curr=val;
+	smooth->dest=val;
+	if (factor<0) factor=0;
+	if (factor>1) factor=1;
+	smooth->factor=factor;
+	smooth->oneminusfactor=1.0f-factor;
 }
 
 void tExpSmooth_free(tExpSmooth* const expsmooth)
 {
     _tExpSmooth* smooth = *expsmooth;
+    
     leaf_free(smooth);
 }
 
@@ -626,8 +706,14 @@
 void    tExpSmooth_initToPool   (tExpSmooth* const expsmooth, float val, float factor, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *expsmooth = (_tExpSmooth*) mpool_alloc(sizeof(_tExpSmooth), &m->pool);
-    expsmooth_init(expsmooth, val, factor);
+    _tExpSmooth* smooth = *expsmooth = (_tExpSmooth*) mpool_alloc(sizeof(_tExpSmooth), &m->pool);
+    
+    smooth->curr=val;
+    smooth->dest=val;
+    if (factor<0) factor=0;
+    if (factor>1) factor=1;
+    smooth->factor=factor;
+    smooth->oneminusfactor=1.0f-factor;
 }
 
 void    tExpSmooth_freeFromPool (tExpSmooth* const expsmooth, tMempool* const mp)
@@ -634,6 +720,7 @@
 {
     _tMempool* m = *mp;
     _tExpSmooth* smooth = *expsmooth;
+    
     mpool_free(smooth, &m->pool);
 }
 
--- a/LEAF/Src/leaf-filters.c
+++ b/LEAF/Src/leaf-filters.c
@@ -21,23 +21,21 @@
 #endif
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ OnePole Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-static void    allpass_init(tAllpass* const ft, float initDelay, uint32_t maxDelay)
-{
-    _tAllpass* f = *ft;
-    f->gain = 0.7f;
-    f->lastOut = 0.0f;
-}
-
 void    tAllpass_init(tAllpass* const ft, float initDelay, uint32_t maxDelay)
 {
     _tAllpass* f = *ft = (_tAllpass*) leaf_alloc(sizeof(_tAllpass));
+    
+    f->gain = 0.7f;
+    
+    f->lastOut = 0.0f;
+    
     tLinearDelay_init(&f->delay, initDelay, maxDelay);
-    allpass_init(ft, initDelay, maxDelay);
 }
 
 void tAllpass_free(tAllpass* const ft)
 {
     _tAllpass* f = *ft;
+    
     tLinearDelay_free(&f->delay);
     leaf_free(f);
 }
@@ -46,8 +44,12 @@
 {
     _tMempool* m = *mp;
     _tAllpass* f = *ft = (_tAllpass*) mpool_alloc(sizeof(_tAllpass), &m->pool);
+    
+    f->gain = 0.7f;
+    
+    f->lastOut = 0.0f;
+    
     tLinearDelay_initToPool(&f->delay, initDelay, maxDelay, mp);
-    allpass_init(ft, initDelay, maxDelay);
 }
 
 void    tAllpass_freeFromPool   (tAllpass* const ft, tMempool* const mp)
@@ -54,6 +56,7 @@
 {
     _tMempool* m = *mp;
     _tAllpass* f = *ft;
+    
     tLinearDelay_freeFromPool(&f->delay, mp);
     mpool_free(f, &m->pool);
 }
@@ -86,9 +89,9 @@
 }
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ OnePole Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-static void    onepole_init(tOnePole* const ft, float freq)
+void    tOnePole_init(tOnePole* const ft, float freq)
 {
-    _tOnePole* f = *ft;
+    _tOnePole* f = *ft = (_tOnePole*) leaf_alloc(sizeof(_tOnePole));
     
     f->gain = 1.0f;
     f->a0 = 1.0;
@@ -99,15 +102,10 @@
     f->lastOut = 0.0f;
 }
 
-void    tOnePole_init(tOnePole* const ft, float freq)
-{
-    *ft = (_tOnePole*) leaf_alloc(sizeof(_tOnePole));
-    onepole_init(ft, freq);
-}
-
 void    tOnePole_free(tOnePole* const ft)
 {
     _tOnePole* f = *ft;
+    
     leaf_free(f);
 }
 
@@ -114,8 +112,15 @@
 void    tOnePole_initToPool     (tOnePole* const ft, float freq, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *ft = (_tOnePole*) mpool_alloc(sizeof(_tOnePole), &m->pool);
-    onepole_init(ft, freq);
+    _tOnePole* f = *ft = (_tOnePole*) mpool_alloc(sizeof(_tOnePole), &m->pool);
+    
+    f->gain = 1.0f;
+    f->a0 = 1.0;
+    
+    tOnePole_setFreq(ft, freq);
+    
+    f->lastIn = 0.0f;
+    f->lastOut = 0.0f;
 }
 
 void    tOnePole_freeFromPool   (tOnePole* const ft, tMempool* const mp)
@@ -122,6 +127,7 @@
 {
     _tMempool* m = *mp;
     _tOnePole* f = *ft;
+    
     mpool_free(f, &m->pool);
 }
 
@@ -187,9 +193,9 @@
 }
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ TwoPole Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-static void    twopole_init(tTwoPole* const ft)
+void    tTwoPole_init(tTwoPole* const ft)
 {
-    _tTwoPole* f = *ft;
+    _tTwoPole* f = *ft = (_tTwoPole*) leaf_alloc(sizeof(_tTwoPole));
     
     f->gain = 1.0f;
     f->a0 = 1.0;
@@ -199,15 +205,10 @@
     f->lastOut[1] = 0.0f;
 }
 
-void    tTwoPole_init(tTwoPole* const ft)
-{
-    *ft = (_tTwoPole*) leaf_alloc(sizeof(_tTwoPole));
-    twopole_init(ft);
-}
-
 void    tTwoPole_free(tTwoPole* const ft)
 {
     _tTwoPole* f = *ft;
+    
     leaf_free(f);
 }
 
@@ -214,8 +215,14 @@
 void    tTwoPole_initToPool     (tTwoPole* const ft, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *ft = (_tTwoPole*) mpool_alloc(sizeof(_tTwoPole), &m->pool);
-    twopole_init(ft);
+    _tTwoPole* f = *ft = (_tTwoPole*) mpool_alloc(sizeof(_tTwoPole), &m->pool);
+    
+    f->gain = 1.0f;
+    f->a0 = 1.0;
+    f->b0 = 1.0;
+    
+    f->lastOut[0] = 0.0f;
+    f->lastOut[1] = 0.0f;
 }
 
 void    tTwoPole_freeFromPool   (tTwoPole* const ft, tMempool* const mp)
@@ -222,6 +229,7 @@
 {
     _tMempool* m = *mp;
     _tTwoPole* f = *ft;
+    
     mpool_free(f, &m->pool);
 }
 
@@ -313,9 +321,9 @@
 }
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ OneZero Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-static void    onezero_init(tOneZero* const ft, float theZero)
+void    tOneZero_init(tOneZero* const ft, float theZero)
 {
-    _tOneZero* f = *ft;
+    _tOneZero* f = *ft = (_tOneZero*) leaf_alloc(sizeof(_tOneZero));
     
     f->gain = 1.0f;
     f->lastIn = 0.0f;
@@ -323,15 +331,10 @@
     tOneZero_setZero(ft, theZero);
 }
 
-void    tOneZero_init(tOneZero* const ft, float theZero)
-{
-    *ft = (_tOneZero*) leaf_alloc(sizeof(_tOneZero));
-    onezero_init(ft, theZero);
-}
-
 void    tOneZero_free(tOneZero* const ft)
 {
     _tOneZero* f = *ft;
+    
     leaf_free(f);
 }
 
@@ -338,8 +341,12 @@
 void    tOneZero_initToPool     (tOneZero* const ft, float theZero, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *ft = (_tOneZero*) mpool_alloc(sizeof(_tOneZero), &m->pool);
-    onezero_init(ft, theZero);
+    _tOneZero* f = *ft = (_tOneZero*) mpool_alloc(sizeof(_tOneZero), &m->pool);
+    
+    f->gain = 1.0f;
+    f->lastIn = 0.0f;
+    f->lastOut = 0.0f;
+    tOneZero_setZero(ft, theZero);
 }
 
 void    tOneZero_freeFromPool   (tOneZero* const ft, tMempool* const mp)
@@ -346,6 +353,7 @@
 {
     _tMempool* m = *mp;
     _tOneZero* f = *ft;
+    
     mpool_free(f, &m->pool);
 }
 
@@ -429,9 +437,9 @@
 }
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ TwoZero Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-static void    twozero_init(tTwoZero* const ft)
+void    tTwoZero_init(tTwoZero* const ft)
 {
-    _tTwoZero* f = *ft;
+    _tTwoZero* f = *ft = (_tTwoZero*) leaf_alloc(sizeof(_tTwoZero));
     
     f->gain = 1.0f;
     f->lastIn[0] = 0.0f;
@@ -438,15 +446,10 @@
     f->lastIn[1] = 0.0f;
 }
 
-void    tTwoZero_init(tTwoZero* const ft)
-{
-    *ft = (_tTwoZero*) leaf_alloc(sizeof(_tTwoZero));
-    twozero_init(ft);
-}
-
 void    tTwoZero_free(tTwoZero* const ft)
 {
     _tTwoZero* f = *ft;
+    
     leaf_free(f);
 }
 
@@ -453,8 +456,11 @@
 void    tTwoZero_initToPool     (tTwoZero* const ft, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *ft = (_tTwoZero*) mpool_alloc(sizeof(_tTwoZero), &m->pool);
-    twozero_init(ft);
+    _tTwoZero* f = *ft = (_tTwoZero*) mpool_alloc(sizeof(_tTwoZero), &m->pool);
+    
+    f->gain = 1.0f;
+    f->lastIn[0] = 0.0f;
+    f->lastIn[1] = 0.0f;
 }
 
 void    tTwoZero_freeFromPool   (tTwoZero* const ft, tMempool* const mp)
@@ -461,6 +467,7 @@
 {
     _tMempool* m = *mp;
     _tTwoZero* f = *ft;
+    
     mpool_free(f, &m->pool);
 }
 
@@ -535,9 +542,9 @@
 }
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ PoleZero Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-static void   polezero_init(tPoleZero* const pzf)
+void   tPoleZero_init(tPoleZero* const pzf)
 {
-    _tPoleZero* f = *pzf;
+    _tPoleZero* f = *pzf = (_tPoleZero*) leaf_alloc(sizeof(_tPoleZero));
     
     f->gain = 1.0f;
     f->b0 = 1.0;
@@ -547,15 +554,10 @@
     f->lastOut = 0.0f;
 }
 
-void   tPoleZero_init(tPoleZero* const pzf)
-{
-    *pzf = (_tPoleZero*) leaf_alloc(sizeof(_tPoleZero));
-    polezero_init(pzf);
-}
-
 void   tPoleZero_free(tPoleZero* const pzf)
 {
     _tPoleZero* f = *pzf;
+    
     leaf_free(f);
 }
 
@@ -563,7 +565,13 @@
 {
     _tMempool* m = *mp;
     _tPoleZero* f = *pzf = (_tPoleZero*) mpool_alloc(sizeof(_tPoleZero), &m->pool);
-    polezero_init(pzf);
+    
+    f->gain = 1.0f;
+    f->b0 = 1.0;
+    f->a0 = 1.0;
+    
+    f->lastIn = 0.0f;
+    f->lastOut = 0.0f;
 }
 
 void    tPoleZero_freeFromPool      (tPoleZero* const pzf, tMempool* const mp)
@@ -570,6 +578,7 @@
 {
     _tMempool* m = *mp;
     _tPoleZero* f = *pzf;
+    
     mpool_free(f, &m->pool);
 }
 
@@ -661,9 +670,9 @@
 }
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ BiQuad Filter ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-static void    biquad_init(tBiQuad* const ft)
+void    tBiQuad_init(tBiQuad* const ft)
 {
-    _tBiQuad* f = *ft;
+    _tBiQuad* f = *ft = (_tBiQuad*) leaf_alloc(sizeof(_tBiQuad));
     
     f->gain = 1.0f;
     
@@ -676,15 +685,10 @@
     f->lastOut[1] = 0.0f;
 }
 
-void    tBiQuad_init(tBiQuad* const ft)
-{
-    *ft = (_tBiQuad*) leaf_alloc(sizeof(_tBiQuad));
-    biquad_init(ft);
-}
-
 void    tBiQuad_free(tBiQuad* const ft)
 {
     _tBiQuad* f = *ft;
+    
     leaf_free(f);
 }
 
@@ -691,8 +695,17 @@
 void    tBiQuad_initToPool     (tBiQuad* const ft, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *ft = (_tBiQuad*) mpool_alloc(sizeof(_tBiQuad), &m->pool);
-    biquad_init(ft);
+    _tBiQuad* f = *ft = (_tBiQuad*) mpool_alloc(sizeof(_tBiQuad), &m->pool);
+    
+    f->gain = 1.0f;
+    
+    f->b0 = 0.0f;
+    f->a0 = 0.0f;
+    
+    f->lastIn[0] = 0.0f;
+    f->lastIn[1] = 0.0f;
+    f->lastOut[0] = 0.0f;
+    f->lastOut[1] = 0.0f;
 }
 
 void    tBiQuad_freeFromPool   (tBiQuad* const ft, tMempool* const mp)
@@ -699,6 +712,7 @@
 {
     _tMempool* m = *mp;
     _tBiQuad* f = *ft;
+    
     mpool_free(f, &m->pool);
 }
 
@@ -827,9 +841,9 @@
 
 // Less efficient, more accurate version of SVF, in which cutoff frequency is taken as floating point Hz value and tanf
 // is calculated when frequency changes.
-static void svf_init(tSVF* const svff, SVFType type, float freq, float Q)
+void tSVF_init(tSVF* const svff, SVFType type, float freq, float Q)
 {
-    _tSVF* svf = *svff;
+    _tSVF* svf = *svff = (_tSVF*) leaf_alloc(sizeof(_tSVF));
     
     svf->type = type;
     
@@ -843,15 +857,10 @@
     svf->a3 = svf->g*svf->a2;
 }
 
-void tSVF_init(tSVF* const svff, SVFType type, float freq, float Q)
-{
-    *svff = (_tSVF*) leaf_alloc(sizeof(_tSVF));
-    svf_init(svff, type, freq, Q);
-}
-
 void tSVF_free(tSVF* const svff)
 {
     _tSVF* svf = *svff;
+    
     leaf_free(svf);
 }
 
@@ -858,8 +867,18 @@
 void    tSVF_initToPool     (tSVF* const svff, SVFType type, float freq, float Q, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *svff = (_tSVF*) mpool_alloc(sizeof(_tSVF), &m->pool);
-    svf_init(svff, type, freq, Q);
+    _tSVF* svf = *svff = (_tSVF*) mpool_alloc(sizeof(_tSVF), &m->pool);
+    
+    svf->type = type;
+    
+    svf->ic1eq = 0;
+    svf->ic2eq = 0;
+    
+    svf->g = tanf(PI * freq * leaf.invSampleRate);
+    svf->k = 1.0f/Q;
+    svf->a1 = 1.0f/(1.0f + svf->g * (svf->g + svf->k));
+    svf->a2 = svf->g*svf->a1;
+    svf->a3 = svf->g*svf->a2;
 }
 
 void    tSVF_freeFromPool   (tSVF* const svff, tMempool* const mp)
@@ -911,9 +930,9 @@
 }
 
 // Efficient version of tSVF where frequency is set based on 12-bit integer input for lookup in tanh wavetable.
-static void   efficientsvf_init(tEfficientSVF* const svff, SVFType type, uint16_t input, float Q)
+void   tEfficientSVF_init(tEfficientSVF* const svff, SVFType type, uint16_t input, float Q)
 {
-    _tEfficientSVF* svf = *svff;
+    _tEfficientSVF* svf = *svff = (_tEfficientSVF*) leaf_alloc(sizeof(_tEfficientSVF));
     
     svf->type = type;
     
@@ -927,15 +946,10 @@
     svf->a3 = svf->g*svf->a2;
 }
 
-void   tEfficientSVF_init(tEfficientSVF* const svff, SVFType type, uint16_t input, float Q)
-{
-    *svff = (_tEfficientSVF*) leaf_alloc(sizeof(_tEfficientSVF));
-    efficientsvf_init(svff, type, input, Q);
-}
-
 void tEfficientSVF_free(tEfficientSVF* const svff)
 {
     _tEfficientSVF* svf = *svff;
+    
     leaf_free(svf);
 }
 
@@ -942,8 +956,18 @@
 void    tEfficientSVF_initToPool    (tEfficientSVF* const svff, SVFType type, uint16_t input, float Q, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *svff = (_tEfficientSVF*) mpool_alloc(sizeof(_tEfficientSVF), &m->pool);
-    efficientsvf_init(svff, type, input, Q);
+    _tEfficientSVF* svf = *svff = (_tEfficientSVF*) mpool_alloc(sizeof(_tEfficientSVF), &m->pool);
+    
+    svf->type = type;
+    
+    svf->ic1eq = 0;
+    svf->ic2eq = 0;
+    
+    svf->g = filtertan[input];
+    svf->k = 1.0f/Q;
+    svf->a1 = 1.0f/(1.0f+svf->g*(svf->g+svf->k));
+    svf->a2 = svf->g*svf->a1;
+    svf->a3 = svf->g*svf->a2;
 }
 
 void    tEfficientSVF_freeFromPool  (tEfficientSVF* const svff, tMempool* const mp)
@@ -950,6 +974,7 @@
 {
     _tMempool* m = *mp;
     _tEfficientSVF* svf = *svff;
+    
     mpool_free(svf, &m->pool);
 }
 
@@ -994,25 +1019,21 @@
 }
 
 /* Highpass */
-static void    highpass_init(tHighpass* const ft, float freq)
+void    tHighpass_init(tHighpass* const ft, float freq)
 {
-    _tHighpass* f = *ft;
+    _tHighpass* f = *ft = (_tHighpass*) leaf_alloc(sizeof(_tHighpass));
     
     f->R = (1.0f - (freq * leaf.twoPiTimesInvSampleRate));
     f->ys = 0.0f;
     f->xs = 0.0f;
+    
     f->frequency = freq;
 }
 
-void    tHighpass_init(tHighpass* const ft, float freq)
-{
-    *ft = (_tHighpass*) leaf_alloc(sizeof(_tHighpass));
-    highpass_init(ft, freq);
-}
-
 void    tHighpass_free(tHighpass* const ft)
 {
     _tHighpass* f = *ft;
+    
     leaf_free(f);
 }
 
@@ -1019,8 +1040,13 @@
 void    tHighpass_initToPool    (tHighpass* const ft, float freq, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *ft = (_tHighpass*) mpool_allocAndClear(sizeof(_tHighpass), &m->pool);
-    highpass_init(ft, freq);
+    _tHighpass* f = *ft = (_tHighpass*) mpool_allocAndClear(sizeof(_tHighpass), &m->pool);
+    
+    f->R = (1.0f - (freq * leaf.twoPiTimesInvSampleRate));
+    f->ys = 0.0f;
+    f->xs = 0.0f;
+    
+    f->frequency = freq;
 }
 
 void    tHighpass_freeFromPool  (tHighpass* const ft, tMempool* const mp)
@@ -1027,6 +1053,7 @@
 {
     _tMempool* m = *mp;
     _tHighpass* f = *ft;
+    
     mpool_free(f, &m->pool);
 }
 
@@ -1059,27 +1086,22 @@
     f->R = (1.0f-((f->frequency * 2.0f * 3.14f) * leaf.invSampleRate));
 }
 
-///////////////////////////////////////////////////////////////////////
-static void butterworth_init(tButterworth* const ft, int N, float f1, float f2)
+void tButterworth_init(tButterworth* const ft, int N, float f1, float f2)
 {
-    _tButterworth* f = *ft;
+    _tButterworth* f = *ft = (_tButterworth*) leaf_alloc(sizeof(_tButterworth));
     
     f->f1 = f1;
     f->f2 = f2;
     f->gain = 1.0f;
+    
     f->N = N;
     
     if (f->N > NUM_SVF_BW) f->N = NUM_SVF_BW;
-}
-
-void tButterworth_init(tButterworth* const ft, int N, float f1, float f2)
-{
-    _tButterworth* f = *ft = (_tButterworth*) leaf_alloc(sizeof(_tButterworth));
-    butterworth_init(ft, N, f1, f2);
-    for(int i = 0; i < f->N/2; ++i)
+    
+    for(int i = 0; i < N/2; ++i)
     {
-        tSVF_init(&f->low[i], SVFTypeHighpass, f->f1, 0.5f/cosf((1.0f+2.0f*i)*PI/(2*f->N)));
-        tSVF_init(&f->high[i], SVFTypeLowpass, f->f2, 0.5f/cosf((1.0f+2.0f*i)*PI/(2*f->N)));
+        tSVF_init(&f->low[i], SVFTypeHighpass, f1, 0.5f/cosf((1.0f+2.0f*i)*PI/(2*N)));
+        tSVF_init(&f->high[i], SVFTypeLowpass, f2, 0.5f/cosf((1.0f+2.0f*i)*PI/(2*N)));
     }
 }
 
@@ -1086,11 +1108,13 @@
 void tButterworth_free(tButterworth* const ft)
 {
     _tButterworth* f = *ft;
+    
     for(int i = 0; i < f->N/2; ++i)
     {
         tSVF_free(&f->low[i]);
         tSVF_free(&f->high[i]);
     }
+    
     leaf_free(f);
 }
 
@@ -1098,11 +1122,19 @@
 {
     _tMempool* m = *mp;
     _tButterworth* f = *ft = (_tButterworth*) mpool_alloc(sizeof(_tButterworth), &m->pool);
-    butterworth_init(ft, N, f1, f2);
-    for(int i = 0; i < f->N/2; ++i)
+    
+    f->f1 = f1;
+    f->f2 = f2;
+    f->gain = 1.0f;
+    
+    f->N = N;
+    
+    if (f->N > NUM_SVF_BW) f->N = NUM_SVF_BW;
+    
+    for(int i = 0; i < N/2; ++i)
     {
-        tSVF_initToPool(&f->low[i], SVFTypeHighpass, f->f1, 0.5f/cosf((1.0f+2.0f*i)*PI/(2*f->N)), mp);
-        tSVF_initToPool(&f->high[i], SVFTypeLowpass, f->f2, 0.5f/cosf((1.0f+2.0f*i)*PI/(2*f->N)), mp);
+        tSVF_initToPool(&f->low[i], SVFTypeHighpass, f1, 0.5f/cosf((1.0f+2.0f*i)*PI/(2*N)), mp);
+        tSVF_initToPool(&f->high[i], SVFTypeLowpass, f2, 0.5f/cosf((1.0f+2.0f*i)*PI/(2*N)), mp);
     }
 }
 
@@ -1110,11 +1142,13 @@
 {
     _tMempool* m = *mp;
     _tButterworth* f = *ft;
+    
     for(int i = 0; i < f->N/2; ++i)
     {
         tSVF_freeFromPool(&f->low[i], mp);
         tSVF_freeFromPool(&f->high[i], mp);
     }
+    
     mpool_free(f, &m->pool);
 }
 
@@ -1159,26 +1193,20 @@
     }
 }
 
-////////////////////////////////////////////////////////////////////
-static void    fir_init(tFIR* const firf, float* coeffs, int numTaps)
+void	tFIR_init(tFIR* const firf, float* coeffs, int numTaps)
 {
-    _tFIR* fir = *firf;
+    _tFIR* fir = *firf = (_tFIR*) leaf_alloc(sizeof(_tFIR));
     
     fir->numTaps = numTaps;
     fir->coeff = coeffs;
+    fir->past = (float*)leaf_alloc(sizeof(float) * fir->numTaps);
     for (int i = 0; i < fir->numTaps; ++i) fir->past[i] = 0.0f;
 }
 
-void	tFIR_init(tFIR* const firf, float* coeffs, int numTaps)
-{
-    _tFIR* fir = *firf = (_tFIR*) leaf_alloc(sizeof(_tFIR));
-    fir->past = (float*)leaf_alloc(sizeof(float) * numTaps);
-    fir_init(firf, coeffs, numTaps);
-}
-
 void    tFIR_free(tFIR* const firf)
 {
     _tFIR* fir = *firf;
+    
     leaf_free(fir->past);
     leaf_free(fir);
 }
@@ -1187,8 +1215,11 @@
 {
     _tMempool* m = *mp;
     _tFIR* fir = *firf = (_tFIR*) mpool_alloc(sizeof(_tFIR), &m->pool);
-    fir->past = (float*) mpool_alloc(sizeof(float) * numTaps, &m->pool);
-    fir_init(firf, coeffs, numTaps);
+    
+    fir->numTaps = numTaps;
+    fir->coeff = coeffs;
+    fir->past = (float*) mpool_alloc(sizeof(float) * fir->numTaps, &m->pool);
+    for (int i = 0; i < fir->numTaps; ++i) fir->past[i] = 0.0f;
 }
 
 void    tFIR_freeFromPool   (tFIR* const firf, tMempool* const mp)
@@ -1195,6 +1226,7 @@
 {
     _tMempool* m = *mp;
     _tFIR* fir = *firf;
+    
     mpool_free(fir->past, &m->pool);
     mpool_free(fir, &m->pool);
 }
--- a/LEAF/Src/leaf-instruments.c
+++ b/LEAF/Src/leaf-instruments.c
@@ -17,35 +17,34 @@
 #endif
 
 // ----------------- COWBELL ----------------------------//
-static void cowbell_init(t808Cowbell* const cowbellInst, int useStick)
-{
-    _t808Cowbell* cowbell = *cowbellInst;
 
-    tSquare_setFreq(&cowbell->p[0], 540.0f);
-    tSquare_setFreq(&cowbell->p[1], 1.48148f * 540.0f);
-    
-    cowbell->oscMix = 0.5f;
-    cowbell->useStick = useStick;
-}
-
 void t808Cowbell_init(t808Cowbell* const cowbellInst, int useStick)
 {
     _t808Cowbell* cowbell = *cowbellInst = (_t808Cowbell*) leaf_alloc(sizeof(_t808Cowbell));
     
     tSquare_init(&cowbell->p[0]);
+    tSquare_setFreq(&cowbell->p[0], 540.0f);
+    
     tSquare_init(&cowbell->p[1]);
-
+    tSquare_setFreq(&cowbell->p[1], 1.48148f * 540.0f);
+    
+    cowbell->oscMix = 0.5f;
+    
     tSVF_init(&cowbell->bandpassOsc, SVFTypeBandpass, 2500, 1.0f);
+    
     tSVF_init(&cowbell->bandpassStick, SVFTypeBandpass, 1800, 1.0f);
     
     tEnvelope_init(&cowbell->envGain, 5.0f, 100.0f, OFALSE);
+    
     tEnvelope_init(&cowbell->envFilter, 5.0, 100.0f, OFALSE);
     
     tHighpass_init(&cowbell->highpass, 1000.0f);
+    
     tNoise_init(&cowbell->stick, WhiteNoise);
+    
     tEnvelope_init(&cowbell->envStick, 5.0f, 5.0f, 0);
     
-    cowbell_init(cowbellInst, useStick);
+    cowbell->useStick = useStick;
 }
 
 void t808Cowebell_free(t808Cowbell* const cowbellInst)
@@ -70,19 +69,28 @@
     _t808Cowbell* cowbell = *cowbellInst = (_t808Cowbell*) mpool_alloc(sizeof(_t808Cowbell), &m->pool);
     
     tSquare_initToPool(&cowbell->p[0], mp);
+    tSquare_setFreq(&cowbell->p[0], 540.0f);
+    
     tSquare_initToPool(&cowbell->p[1], mp);
-
+    tSquare_setFreq(&cowbell->p[1], 1.48148f * 540.0f);
+    
+    cowbell->oscMix = 0.5f;
+    
     tSVF_initToPool(&cowbell->bandpassOsc, SVFTypeBandpass, 2500, 1.0f, mp);
+    
     tSVF_initToPool(&cowbell->bandpassStick, SVFTypeBandpass, 1800, 1.0f, mp);
     
     tEnvelope_initToPool(&cowbell->envGain, 5.0f, 100.0f, OFALSE, mp);
+    
     tEnvelope_initToPool(&cowbell->envFilter, 5.0, 100.0f, OFALSE, mp);
     
     tHighpass_initToPool(&cowbell->highpass, 1000.0f, mp);
+    
     tNoise_initToPool(&cowbell->stick, WhiteNoise, mp);
+    
     tEnvelope_initToPool(&cowbell->envStick, 5.0f, 5.0f, 0, mp);
-
-    cowbell_init(cowbellInst, useStick);
+    
+    cowbell->useStick = useStick;
 }
 
 void        t808Cowbell_freeFromPool    (t808Cowbell* const cowbellInst, tMempool* const mp)
@@ -174,20 +182,6 @@
 }
 
 // ----------------- HIHAT ----------------------------//
-static void hihat_init(t808Hihat* const hihatInst)
-{
-    _t808Hihat* hihat = *hihatInst;
-    
-    hihat->freq = 40.0f;
-    hihat->stretch = 0.0f;
-    
-    tSquare_setFreq(&hihat->p[0], 2.0f * hihat->freq);
-    tSquare_setFreq(&hihat->p[1], 3.00f * hihat->freq);
-    tSquare_setFreq(&hihat->p[2], 4.16f * hihat->freq);
-    tSquare_setFreq(&hihat->p[3], 5.43f * hihat->freq);
-    tSquare_setFreq(&hihat->p[4], 6.79f * hihat->freq);
-    tSquare_setFreq(&hihat->p[5], 8.21f * hihat->freq);
-}
 
 void t808Hihat_init(t808Hihat* const hihatInst)
 {
@@ -208,9 +202,18 @@
     tEnvelope_init(&hihat->envGain, 0.0f, 50.0f, OFALSE);
     tEnvelope_init(&hihat->envStick, 0.0f, 7.0f, OFALSE);
     
+    
     tHighpass_init(&hihat->highpass, 7000.0f);
     
-    hihat_init(hihatInst);
+    hihat->freq = 40.0f;
+    hihat->stretch = 0.0f;
+    
+    tSquare_setFreq(&hihat->p[0], 2.0f * hihat->freq);
+    tSquare_setFreq(&hihat->p[1], 3.00f * hihat->freq);
+    tSquare_setFreq(&hihat->p[2], 4.16f * hihat->freq);
+    tSquare_setFreq(&hihat->p[3], 5.43f * hihat->freq);
+    tSquare_setFreq(&hihat->p[4], 6.79f * hihat->freq);
+    tSquare_setFreq(&hihat->p[5], 8.21f * hihat->freq);
 }
 
 void t808Hihat_free(t808Hihat* const hihatInst)
@@ -255,10 +258,19 @@
     
     tEnvelope_initToPool(&hihat->envGain, 0.0f, 50.0f, OFALSE, mp);
     tEnvelope_initToPool(&hihat->envStick, 0.0f, 7.0f, OFALSE, mp);
-
+    
+    
     tHighpass_initToPool(&hihat->highpass, 7000.0f, mp);
     
-    hihat_init(hihatInst);
+    hihat->freq = 40.0f;
+    hihat->stretch = 0.0f;
+    
+    tSquare_setFreq(&hihat->p[0], 2.0f * hihat->freq);
+    tSquare_setFreq(&hihat->p[1], 3.00f * hihat->freq);
+    tSquare_setFreq(&hihat->p[2], 4.16f * hihat->freq);
+    tSquare_setFreq(&hihat->p[3], 5.43f * hihat->freq);
+    tSquare_setFreq(&hihat->p[4], 6.79f * hihat->freq);
+    tSquare_setFreq(&hihat->p[5], 8.21f * hihat->freq);
 }
 
 void    t808Hihat_freeFromPool  (t808Hihat* const hihatInst, tMempool* const mp)
@@ -389,39 +401,33 @@
 }
 
 // ----------------- SNARE ----------------------------//
-static void snare_init(t808Snare* const snareInst)
-{
-    _t808Snare* snare = *snareInst;
-    
-    float ratio[2] = {1.0, 1.5};
-    for (int i = 0; i < 2; i++)
-    {
-        tTriangle_setFreq(&snare->tone[i], ratio[i] * 400.0f);
-        snare->toneGain[i] = 0.5f;
-    }
-    snare->tone1Freq = ratio[0] * 100.0f;
-    snare->tone2Freq = ratio[1] * 100.0f;
-    snare->noiseFilterFreq = 3000.0f;
-    snare->noiseGain = 1.0f;
-}
 
 void t808Snare_init(t808Snare* const snareInst)
 {
     _t808Snare* snare = *snareInst = (_t808Snare*) leaf_alloc(sizeof(_t808Snare));
     
+    float ratio[2] = {1.0, 1.5};
     for (int i = 0; i < 2; i++)
     {
         tTriangle_init(&snare->tone[i]);
+        
+        tTriangle_setFreq(&snare->tone[i], ratio[i] * 400.0f);
         tSVF_init(&snare->toneLowpass[i], SVFTypeLowpass, 4000, 1.0f);
         tEnvelope_init(&snare->toneEnvOsc[i], 0.0f, 50.0f, OFALSE);
         tEnvelope_init(&snare->toneEnvGain[i], 1.0f, 150.0f, OFALSE);
         tEnvelope_init(&snare->toneEnvFilter[i], 1.0f, 2000.0f, OFALSE);
+        
+        snare->toneGain[i] = 0.5f;
     }
+    
+    snare->tone1Freq = ratio[0] * 100.0f;
+    snare->tone2Freq = ratio[1] * 100.0f;
+    snare->noiseFilterFreq = 3000.0f;
     tNoise_init(&snare->noiseOsc, WhiteNoise);
     tSVF_init(&snare->noiseLowpass, SVFTypeLowpass, 12000.0f, 0.8f);
     tEnvelope_init(&snare->noiseEnvGain, 0.0f, 100.0f, OFALSE);
     tEnvelope_init(&snare->noiseEnvFilter, 0.0f, 1000.0f, OFALSE);
-    snare_init(snareInst);
+    snare->noiseGain = 1.0f;
 }
 
 void        t808Snare_free                  (t808Snare* const snareInst)
@@ -449,20 +455,29 @@
 {
     _tMempool* m = *mp;
     _t808Snare* snare = *snareInst = (_t808Snare*) mpool_alloc(sizeof(_t808Snare), &m->pool);
-
+    
+    float ratio[2] = {1.0, 1.5};
     for (int i = 0; i < 2; i++)
     {
         tTriangle_initToPool(&snare->tone[i], mp);
+        
+        tTriangle_setFreq(&snare->tone[i], ratio[i] * 400.0f);
         tSVF_initToPool(&snare->toneLowpass[i], SVFTypeLowpass, 4000, 1.0f, mp);
         tEnvelope_initToPool(&snare->toneEnvOsc[i], 0.0f, 50.0f, OFALSE, mp);
         tEnvelope_initToPool(&snare->toneEnvGain[i], 1.0f, 150.0f, OFALSE, mp);
         tEnvelope_initToPool(&snare->toneEnvFilter[i], 1.0f, 2000.0f, OFALSE, mp);
+        
+        snare->toneGain[i] = 0.5f;
     }
+    
+    snare->tone1Freq = ratio[0] * 100.0f;
+    snare->tone2Freq = ratio[1] * 100.0f;
+    snare->noiseFilterFreq = 3000.0f;
     tNoise_initToPool(&snare->noiseOsc, WhiteNoise, mp);
     tSVF_initToPool(&snare->noiseLowpass, SVFTypeLowpass, 12000.0f, 0.8f, mp);
     tEnvelope_initToPool(&snare->noiseEnvGain, 0.0f, 100.0f, OFALSE, mp);
     tEnvelope_initToPool(&snare->noiseEnvFilter, 0.0f, 1000.0f, OFALSE, mp);
-    snare_init(snareInst);
+    snare->noiseGain = 1.0f;
 }
 
 void    t808Snare_freeFromPool  (t808Snare* const snareInst, tMempool* const mp)
@@ -577,22 +592,16 @@
 }
 
 // ----------------- KICK ----------------------------//
-static void kick_init   (t808Kick* const kickInst)
-{
-    _t808Kick* kick = *kickInst;
 
-    tCycle_setFreq(&kick->tone, 50.0f);
-    kick->toneInitialFreq = 40.0f;
-    kick->sighAmountInHz = 7.0f;
-    kick->chirpRatioMinusOne = 3.3f;
-    kick->noiseGain = 0.3f;
-}
-
 void        t808Kick_init        			(t808Kick* const kickInst)
 {
     _t808Kick* kick = *kickInst = (_t808Kick*) leaf_alloc(sizeof(_t808Kick));
     
 	tCycle_init(&kick->tone);
+	kick->toneInitialFreq = 40.0f;
+	kick->sighAmountInHz = 7.0f;
+	kick->chirpRatioMinusOne = 3.3f;
+	tCycle_setFreq(&kick->tone, 50.0f);
 	tSVF_init(&kick->toneLowpass, SVFTypeLowpass, 2000.0f, 0.5f);
 	tEnvelope_init(&kick->toneEnvOscChirp, 0.0f, 20.0f, OFALSE);
 	tEnvelope_init(&kick->toneEnvOscSigh, 0.0f, 2500.0f, OFALSE);
@@ -599,7 +608,7 @@
 	tEnvelope_init(&kick->toneEnvGain, 0.0f, 800.0f, OFALSE);
 	tNoise_init(&kick->noiseOsc, PinkNoise);
 	tEnvelope_init(&kick->noiseEnvGain, 0.0f, 1.0f, OFALSE);
-    kick_init(kickInst);
+	kick->noiseGain = 0.3f;
 }
 
 void        t808Kick_free                  (t808Kick* const kickInst)
@@ -623,6 +632,10 @@
     _t808Kick* kick = *kickInst = (_t808Kick*) mpool_alloc(sizeof(_t808Kick), &m->pool);
     
     tCycle_initToPool(&kick->tone, mp);
+    kick->toneInitialFreq = 40.0f;
+    kick->sighAmountInHz = 7.0f;
+    kick->chirpRatioMinusOne = 3.3f;
+    tCycle_setFreq(&kick->tone, 50.0f);
     tSVF_initToPool(&kick->toneLowpass, SVFTypeLowpass, 2000.0f, 0.5f, mp);
     tEnvelope_initToPool(&kick->toneEnvOscChirp, 0.0f, 20.0f, OFALSE, mp);
     tEnvelope_initToPool(&kick->toneEnvOscSigh, 0.0f, 2500.0f, OFALSE, mp);
@@ -629,7 +642,7 @@
     tEnvelope_initToPool(&kick->toneEnvGain, 0.0f, 800.0f, OFALSE, mp);
     tNoise_initToPool(&kick->noiseOsc, PinkNoise, mp);
     tEnvelope_initToPool(&kick->noiseEnvGain, 0.0f, 1.0f, OFALSE, mp);
-    kick_init(kickInst);
+    kick->noiseGain = 0.3f;
 }
 
 void    t808Kick_freeFromPool   (t808Kick* const kickInst, tMempool* const mp)
--- a/LEAF/Src/leaf-mempool.c
+++ b/LEAF/Src/leaf-mempool.c
@@ -360,21 +360,17 @@
 	//TODO: we should set up some kind of leaf_error method that reaches user space to notify library users of things that failed.
 }
 
-static void mempool_init(tMempool* const mp, char* memory, size_t size)
+void tMempool_init(tMempool* const mp, char* memory, size_t size)
 {
-    _tMempool* m = *mp;
+    _tMempool* m = *mp = (_tMempool*) leaf_alloc(sizeof(_tMempool));
+    
     mpool_create (memory, size, &m->pool);
 }
 
-void tMempool_init(tMempool* const mp, char* memory, size_t size)
-{
-    *mp = (_tMempool*) leaf_alloc(sizeof(_tMempool));
-    mempool_init(mp, memory, size);
-}
-
 void tMempool_free(tMempool* const mp)
 {
     _tMempool* m = *mp;
+    
     leaf_free(m);
 }
 
@@ -381,8 +377,9 @@
 void    tMempool_initToPool     (tMempool* const mp, char* memory, size_t size, tMempool* const mem)
 {
     _tMempool* mm = *mem;
-    *mp = (_tMempool*) mpool_alloc(sizeof(_tMempool), &mm->pool);
-    mempool_init(mp, memory, size);
+    _tMempool* m = *mp = (_tMempool*) mpool_alloc(sizeof(_tMempool), &mm->pool);
+    
+    mpool_create (memory, size, &m->pool);
 }
 
 void    tMempool_freeFromPool   (tMempool* const mp, tMempool* const mem)
@@ -389,5 +386,6 @@
 {
     _tMempool* mm = *mem;
     _tMempool* m = *mp;
+    
     mpool_free(m, &mm->pool);
 }
--- a/LEAF/Src/leaf-midi.c
+++ b/LEAF/Src/leaf-midi.c
@@ -19,9 +19,10 @@
 //====================================================================================
 /* Stack */
 //====================================================================================
-static void stack_init(tStack* const stack)
+
+void tStack_init(tStack* const stack)
 {
-    _tStack* ns = *stack;
+    _tStack* ns = *stack = (_tStack*) leaf_alloc(sizeof(_tStack));
     
     ns->ordered = OFALSE;
     ns->size = 0;
@@ -31,15 +32,10 @@
     for (int i = 0; i < STACK_SIZE; i++) ns->data[i] = -1;
 }
 
-void tStack_init(tStack* const stack)
-{
-    *stack = (_tStack*) leaf_alloc(sizeof(_tStack));
-    stack_init(stack);
-}
-
 void tStack_free(tStack* const stack)
 {
     _tStack* ns = *stack;
+    
     leaf_free(ns);
 }
 
@@ -46,8 +42,14 @@
 void    tStack_initToPool           (tStack* const stack, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *stack = (_tStack*) mpool_alloc(sizeof(_tStack), &m->pool);
-    stack_init(stack);
+    _tStack* ns = *stack = (_tStack*) mpool_alloc(sizeof(_tStack), &m->pool);
+    
+    ns->ordered = OFALSE;
+    ns->size = 0;
+    ns->pos = 0;
+    ns->capacity = STACK_SIZE;
+    
+    for (int i = 0; i < STACK_SIZE; i++) ns->data[i] = -1;
 }
 
 void    tStack_freeFromPool         (tStack* const stack, tMempool* const mp)
@@ -54,6 +56,7 @@
 {
     _tMempool* m = *mp;
     _tStack* ns = *stack;
+    
     mpool_free(ns, &m->pool);
 }
 
@@ -267,9 +270,9 @@
 
 
 // POLY
-static void poly_init(tPoly* const polyh, int maxNumVoices)
+void tPoly_init(tPoly* const polyh, int maxNumVoices)
 {
-    _tPoly* poly = *polyh;
+    _tPoly* poly = *polyh = (_tPoly*) leaf_alloc(sizeof(_tPoly));
     
     poly->numVoices = maxNumVoices;
     poly->maxNumVoices = maxNumVoices;
@@ -289,36 +292,27 @@
     
     poly->glideTime = 5.0f;
     
+    poly->ramps = (tRamp*) leaf_alloc(sizeof(tRamp) * poly->maxNumVoices);
+    poly->rampVals = (float*) leaf_alloc(sizeof(float) * poly->maxNumVoices);
+    poly->firstReceived = (oBool*) leaf_alloc(sizeof(oBool) * poly->maxNumVoices);
+    poly->voices = (int**) leaf_alloc(sizeof(int*) * poly->maxNumVoices);
+    
     for (int i = 0; i < poly->maxNumVoices; ++i)
     {
+        poly->voices[i] = (int*) leaf_alloc(sizeof(int) * 2);
         poly->voices[i][0] = -1;
         poly->firstReceived[i] = OFALSE;
+        
+        tRamp_init(&poly->ramps[i], poly->glideTime, 1);
     }
+    
     poly->pitchBend = 0.0f;
-    poly->pitchGlideIsActive = OFALSE;
-}
-
-void tPoly_init(tPoly* const polyh, int maxNumVoices)
-{
-    _tPoly* poly = *polyh = (_tPoly*) leaf_alloc(sizeof(_tPoly));
     
-    poly->ramps = (tRamp*) leaf_alloc(sizeof(tRamp) * maxNumVoices);
-    poly->rampVals = (float*) leaf_alloc(sizeof(float) * maxNumVoices);
-    poly->firstReceived = (oBool*) leaf_alloc(sizeof(oBool) * maxNumVoices);
-    poly->voices = (int**) leaf_alloc(sizeof(int*) * maxNumVoices);
-    for (int i = 0; i < maxNumVoices; ++i)
-    {
-        poly->voices[i] = (int*) leaf_alloc(sizeof(int) * 2);
-    }
-    poly_init(polyh, maxNumVoices);
-    
-    for (int i = 0; i < poly->maxNumVoices; ++i)
-    {
-        tRamp_init(&poly->ramps[i], poly->glideTime, 1);
-    }
     tRamp_init(&poly->pitchBendRamp, 1.0f, 1);
     tStack_init(&poly->stack);
     tStack_init(&poly->orderStack);
+    
+    poly->pitchGlideIsActive = OFALSE;
 }
 
 void tPoly_free(tPoly* const polyh)
@@ -347,23 +341,45 @@
     _tMempool* m = *mp;
     _tPoly* poly = *polyh = (_tPoly*) mpool_alloc(sizeof(_tPoly), &m->pool);
     
-    poly->ramps = (tRamp*) mpool_alloc(sizeof(tRamp) * maxNumVoices, &m->pool);
-    poly->rampVals = (float*) mpool_alloc(sizeof(float) * maxNumVoices, &m->pool);
-    poly->firstReceived = (oBool*) mpool_alloc(sizeof(oBool) * maxNumVoices, &m->pool);
-    poly->voices = (int**) mpool_alloc(sizeof(int*) * maxNumVoices, &m->pool);
-    for (int i = 0; i < maxNumVoices; ++i)
+    poly->numVoices = maxNumVoices;
+    poly->maxNumVoices = maxNumVoices;
+    poly->lastVoiceToChange = 0;
+    
+    // Arp mode stuff
+    poly->currentVoice = 0;
+    poly->maxLength = 128;
+    poly->currentNote = -1;
+    
+    //default learned CCs and notes are just the CCs 1-128 - notes are skipped
+    for (int i = 0; i < 128; i++)
     {
-        poly->voices[i] = (int*) mpool_alloc(sizeof(int) * 2, &m->pool);
+        poly->notes[i][0] = 0;
+        poly->notes[i][1] = -1;
     }
-    poly_init(polyh, maxNumVoices);
     
+    poly->glideTime = 5.0f;
+    
+    poly->ramps = (tRamp*) mpool_alloc(sizeof(tRamp) * poly->maxNumVoices, &m->pool);
+    poly->rampVals = (float*) mpool_alloc(sizeof(float) * poly->maxNumVoices, &m->pool);
+    poly->firstReceived = (oBool*) mpool_alloc(sizeof(oBool) * poly->maxNumVoices, &m->pool);
+    poly->voices = (int**) mpool_alloc(sizeof(int*) * poly->maxNumVoices, &m->pool);
+    
     for (int i = 0; i < poly->maxNumVoices; ++i)
     {
+        poly->voices[i] = (int*) mpool_alloc(sizeof(int) * 2, &m->pool);
+        poly->voices[i][0] = -1;
+        poly->firstReceived[i] = OFALSE;
+        
         tRamp_initToPool(&poly->ramps[i], poly->glideTime, 1, mp);
     }
+    
+    poly->pitchBend = 0.0f;
+    
     tRamp_initToPool(&poly->pitchBendRamp, 1.0f, 1, mp);
     tStack_initToPool(&poly->stack, mp);
     tStack_initToPool(&poly->orderStack, mp);
+    
+    poly->pitchGlideIsActive = OFALSE;
 }
 
 void    tPoly_freeFromPool  (tPoly* const polyh, tMempool* const mp)
--- a/LEAF/Src/leaf-oscillators.c
+++ b/LEAF/Src/leaf-oscillators.c
@@ -19,22 +19,18 @@
 #endif
 
 // Cycle
-static void    cycle_init(tCycle* const cy)
+void    tCycle_init(tCycle* const cy)
 {
-    _tCycle* c = *cy;
+    _tCycle* c = *cy = (_tCycle*) leaf_alloc(sizeof(_tCycle));
+    
     c->inc      =  0.0f;
     c->phase    =  0.0f;
 }
 
-void    tCycle_init(tCycle* const cy)
-{
-    *cy = (_tCycle*) leaf_alloc(sizeof(_tCycle));
-    cycle_init(cy);
-}
-
 void    tCycle_free(tCycle* const cy)
 {
     _tCycle* c = *cy;
+    
     leaf_free(c);
 }
 
@@ -41,8 +37,10 @@
 void    tCycle_initToPool   (tCycle* const cy, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *cy = (_tCycle*) mpool_alloc(sizeof(_tCycle), &m->pool);
-    cycle_init(cy);
+    _tCycle* c = *cy = (_tCycle*) mpool_alloc(sizeof(_tCycle), &m->pool);
+    
+    c->inc      =  0.0f;
+    c->phase    =  0.0f;
 }
 
 void    tCycle_freeFromPool (tCycle* const cy, tMempool* const mp)
@@ -49,6 +47,7 @@
 {
     _tMempool* m = *mp;
     _tCycle* c = *cy;
+    
     mpool_free(c, &m->pool);
 }
 
@@ -91,22 +90,18 @@
 
 //========================================================================
 /* Triangle */
-static void   triangle_init(tTriangle* const cy)
+void   tTriangle_init(tTriangle* const cy)
 {
-    _tTriangle* c = *cy;
+    _tTriangle* c = *cy = (_tTriangle*) leaf_alloc(sizeof(_tTriangle));
+    
     c->inc      =  0.0f;
     c->phase    =  0.0f;
 }
 
-void   tTriangle_init(tTriangle* const cy)
-{
-    *cy = (_tTriangle*) leaf_alloc(sizeof(_tTriangle));
-    triangle_init(cy);
-}
-
 void   tTriangle_free(tTriangle* const cy)
 {
     _tTriangle* c = *cy;
+    
     leaf_free(c);
 }
 
@@ -113,8 +108,10 @@
 void    tTriangle_initToPool    (tTriangle* const cy, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *cy = (_tTriangle*) mpool_alloc(sizeof(_tTriangle), &m->pool);
-    triangle_init(cy);
+    _tTriangle* c = *cy = (_tTriangle*) mpool_alloc(sizeof(_tTriangle), &m->pool);
+    
+    c->inc      =  0.0f;
+    c->phase    =  0.0f;
 }
 
 void    tTriangle_freeFromPool  (tTriangle* const cy, tMempool* const mp)
@@ -121,6 +118,7 @@
 {
     _tMempool* m = *mp;
     _tTriangle* c = *cy;
+    
     mpool_free(c, &m->pool);
 }
 
@@ -223,22 +221,18 @@
 
 //========================================================================
 /* Square */
-static void   square_init(tSquare* const cy)
+void   tSquare_init(tSquare* const cy)
 {
-    _tSquare* c = *cy;
+    _tSquare* c = *cy = (_tSquare*) leaf_alloc(sizeof(_tSquare));
+    
     c->inc      =  0.0f;
     c->phase    =  0.0f;
 }
 
-void   tSquare_init(tSquare* const cy)
-{
-    *cy = (_tSquare*) leaf_alloc(sizeof(_tSquare));
-    square_init(cy);
-}
-
 void   tSquare_free(tSquare* const cy)
 {
     _tSquare* c = *cy;
+    
     leaf_free(c);
 }
 
@@ -245,8 +239,10 @@
 void    tSquare_initToPool  (tSquare* const cy, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *cy = (_tSquare*) mpool_alloc(sizeof(_tSquare), &m->pool);
-    square_init(cy);
+    _tSquare* c = *cy = (_tSquare*) mpool_alloc(sizeof(_tSquare), &m->pool);
+    
+    c->inc      =  0.0f;
+    c->phase    =  0.0f;
 }
 
 void    tSquare_freeFromPool(tSquare* const cy, tMempool* const mp)
@@ -253,6 +249,7 @@
 {
     _tMempool* m = *mp;
     _tSquare* c = *cy;
+    
     mpool_free(c, &m->pool);
 }
 
@@ -353,22 +350,18 @@
 
 //=====================================================================
 // Sawtooth
-static void    sawtooth_init(tSawtooth* const cy)
+void    tSawtooth_init(tSawtooth* const cy)
 {
-    _tSawtooth* c = *cy;
+    _tSawtooth* c = *cy = (_tSawtooth*) leaf_alloc(sizeof(_tSawtooth));
+    
     c->inc      = 0.0f;
     c->phase    = 0.0f;
 }
 
-void    tSawtooth_init(tSawtooth* const cy)
-{
-    *cy = (_tSawtooth*) leaf_alloc(sizeof(_tSawtooth));
-    sawtooth_init(cy);
-}
-
 void    tSawtooth_free(tSawtooth* const cy)
 {
     _tSawtooth* c = *cy;
+    
     leaf_free(c);
 }
 
@@ -375,8 +368,10 @@
 void    tSawtooth_initToPool    (tSawtooth* const cy, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *cy = (_tSawtooth*) mpool_alloc(sizeof(_tSawtooth), &m->pool);
-    sawtooth_init(cy);
+    _tSawtooth* c = *cy = (_tSawtooth*) mpool_alloc(sizeof(_tSawtooth), &m->pool);
+    
+    c->inc      = 0.0f;
+    c->phase    = 0.0f;
 }
 
 void    tSawtooth_freeFromPool  (tSawtooth* const cy, tMempool* const mp)
@@ -383,6 +378,7 @@
 {
     _tMempool* m = *mp;
     _tSawtooth* c = *cy;
+    
     mpool_free(c, &m->pool);
 }
 
@@ -484,22 +480,25 @@
 
 //========================================================================
 /* Phasor */
-static void    phasor_init(tPhasor* const ph)
+void     tPhasorSampleRateChanged (tPhasor* const ph)
 {
     _tPhasor* p = *ph;
-    p->phase = 0.0f;
-    p->inc = 0.0f;
-}
+    
+    p->inc = p->freq * leaf.invSampleRate;
+};
 
 void    tPhasor_init(tPhasor* const ph)
 {
-    *ph = (_tPhasor*) leaf_alloc(sizeof(_tPhasor));
-    phasor_init(ph);
+    _tPhasor* p = *ph = (_tPhasor*) leaf_alloc(sizeof(_tPhasor));
+    
+    p->phase = 0.0f;
+    p->inc = 0.0f;
 }
 
 void    tPhasor_free(tPhasor* const ph)
 {
     _tPhasor* p = *ph;
+    
     leaf_free(p);
 }
 
@@ -506,8 +505,10 @@
 void    tPhasor_initToPool  (tPhasor* const ph, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *ph = (_tPhasor*) mpool_alloc(sizeof(_tPhasor), &m->pool);
-    phasor_init(ph);
+    _tPhasor* p = *ph = (_tPhasor*) mpool_alloc(sizeof(_tPhasor), &m->pool);
+    
+    p->phase = 0.0f;
+    p->inc = 0.0f;
 }
 
 void    tPhasor_freeFromPool(tPhasor* const ph, tMempool* const mp)
@@ -514,6 +515,7 @@
 {
     _tMempool* m = *mp;
     _tPhasor* p = *ph;
+    
     mpool_free(p, &m->pool);
 }
 
@@ -541,22 +543,18 @@
 }
 
 /* Noise */
-static void    noise_init(tNoise* const ns, NoiseType type)
+void    tNoise_init(tNoise* const ns, NoiseType type)
 {
-    _tNoise* n = *ns;
+    _tNoise* n = *ns = (_tNoise*) leaf_alloc(sizeof(_tNoise));
+    
     n->type = type;
     n->rand = leaf.random;
 }
 
-void    tNoise_init(tNoise* const ns, NoiseType type)
-{
-    *ns = (_tNoise*) leaf_alloc(sizeof(_tNoise));
-    noise_init(ns, type);
-}
-
 void    tNoise_free(tNoise* const ns)
 {
     _tNoise* n = *ns;
+    
     leaf_free(n);
 }
 
@@ -563,8 +561,10 @@
 void    tNoise_initToPool   (tNoise* const ns, NoiseType type, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *ns = (_tNoise*) mpool_alloc(sizeof(_tNoise), &m->pool);
-    noise_init(ns, type);
+    _tNoise* n = *ns = (_tNoise*) mpool_alloc(sizeof(_tNoise), &m->pool);
+    
+    n->type = type;
+    n->rand = leaf.random;
 }
 
 void    tNoise_freeFromPool (tNoise* const ns, tMempool* const mp)
@@ -571,6 +571,7 @@
 {
     _tMempool* m = *mp;
     _tNoise* n = *ns;
+    
     mpool_free(n, &m->pool);
 }
 
@@ -595,18 +596,20 @@
     }
 }
 
-void     tPhasorSampleRateChanged (tPhasor* const ph)
+//=================================================================================
+/* Neuron */
+
+void     tNeuronSampleRateChanged(tNeuron* nr)
 {
-    _tPhasor* p = *ph;
     
-    p->inc = p->freq * leaf.invSampleRate;
 }
 
-//=================================================================================
-/* Neuron */
-static void    neuron_init(tNeuron* const nr)
+void    tNeuron_init(tNeuron* const nr)
 {
-    _tNeuron* n = *nr;
+    _tNeuron* n = *nr = (_tNeuron*) leaf_alloc(sizeof(_tNeuron));
+    
+    tPoleZero_init(&n->f);
+    
     tPoleZero_setBlockZero(&n->f, 0.99f);
     
     n->timeStep = 1.0f / 50.0f;
@@ -632,16 +635,10 @@
     n->rate[2] = n->gL/n->C;
 }
 
-void    tNeuron_init(tNeuron* const nr)
-{
-    _tNeuron* n = *nr = (_tNeuron*) leaf_alloc(sizeof(_tNeuron));
-    tPoleZero_init(&n->f);
-    neuron_init(nr);
-}
-
 void    tNeuron_free(tNeuron* const nr)
 {
     _tNeuron* n = *nr;
+    
     tPoleZero_free(&n->f);
     leaf_free(n);
 }
@@ -650,8 +647,32 @@
 {
     _tMempool* m = *mp;
     _tNeuron* n = *nr = (_tNeuron*) mpool_alloc(sizeof(_tNeuron), &m->pool);
+    
     tPoleZero_initToPool(&n->f, mp);
-    neuron_init(nr);
+    
+    tPoleZero_setBlockZero(&n->f, 0.99f);
+    
+    n->timeStep = 1.0f / 50.0f;
+    
+    n->current = 0.0f; // 100.0f for sound
+    n->voltage = 0.0f;
+    
+    n->mode = NeuronNormal;
+    
+    n->P[0] = 0.0f;
+    n->P[1] = 0.0f;
+    n->P[2] = 1.0f;
+    
+    n->V[0] = -12.0f;
+    n->V[1] = 115.0f;
+    n->V[2] = 10.613f;
+    
+    n->gK = 36.0f;
+    n->gN = 120.0f;
+    n->gL = 0.3f;
+    n->C = 1.0f;
+    
+    n->rate[2] = n->gL/n->C;
 }
 
 void    tNeuron_freeFromPool(tNeuron* const nr, tMempool* const mp)
@@ -829,9 +850,4 @@
 {
     _tNeuron* n = *nr;
     n->current = current;
-}
-
-void     tNeuronSampleRateChanged(tNeuron* nr)
-{
-    
 }
--- a/LEAF/Src/leaf-physical.c
+++ b/LEAF/Src/leaf-physical.c
@@ -17,23 +17,21 @@
 #endif
 
 /* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ tPluck ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */
-static void    pluck_init         (tPluck* const pl, float lowestFrequency)
-{
-    if ( lowestFrequency <= 0.0f )  lowestFrequency = 10.0f;
-
-    tPluck_setFrequency(pl, 220.0f);
-}
-
 void    tPluck_init         (tPluck* const pl, float lowestFrequency)
 {
     _tPluck* p = *pl = (_tPluck*) leaf_alloc(sizeof(_tPluck));
-
+    
+    if ( lowestFrequency <= 0.0f )  lowestFrequency = 10.0f;
+    
     tNoise_init(&p->noise, WhiteNoise);
+    
     tOnePole_init(&p->pickFilter, 0.0f);
+    
     tOneZero_init(&p->loopFilter, 0.0f);
+    
     tAllpassDelay_init(&p->delayLine, 0.0f, leaf.sampleRate * 2);
     
-    pluck_init(pl, lowestFrequency);
+    tPluck_setFrequency(pl, 220.0f);
 }
 
 void tPluck_free (tPluck* const pl)
@@ -53,12 +51,17 @@
     _tMempool* m = *mp;
     _tPluck* p = *pl = (_tPluck*) mpool_alloc(sizeof(_tPluck), &m->pool);
     
+    if ( lowestFrequency <= 0.0f )  lowestFrequency = 10.0f;
+    
     tNoise_initToPool(&p->noise, WhiteNoise, mp);
+    
     tOnePole_initToPool(&p->pickFilter, 0.0f, mp);
+    
     tOneZero_initToPool(&p->loopFilter, 0.0f, mp);
+    
     tAllpassDelay_initToPool(&p->delayLine, 0.0f, leaf.sampleRate * 2, mp);
     
-    pluck_init(pl, lowestFrequency);
+    tPluck_setFrequency(pl, 220.0f);
 }
 
 void    tPluck_freeFromPool  (tPluck* const pl, tMempool* const mp)
@@ -152,29 +155,18 @@
 }
 
 /* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ tKarplusStrong ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */
-static void    karplusstrong_init (tKarplusStrong* const pl, float lowestFrequency)
+void    tKarplusStrong_init (tKarplusStrong* const pl, float lowestFrequency)
 {
-    _tKarplusStrong* p = *pl;
+    _tKarplusStrong* p = *pl = (_tKarplusStrong*) leaf_alloc(sizeof(_tKarplusStrong));
     
     if ( lowestFrequency <= 0.0f )  lowestFrequency = 8.0f;
     
-    p->pluckAmplitude = 0.3f;
-    p->pickupPosition = 0.4f;
-    
-    p->stretching = 0.9999f;
-    p->baseLoopGain = 0.995f;
-    p->loopGain = 0.999f;
-    
-    tKarplusStrong_setFrequency( pl, 220.0f );
-}
-
-void    tKarplusStrong_init (tKarplusStrong* const pl, float lowestFrequency)
-{
-    _tKarplusStrong* p = *pl = (_tKarplusStrong*) leaf_alloc(sizeof(_tKarplusStrong));
-
     tAllpassDelay_init(&p->delayLine, 0.0f, leaf.sampleRate * 2);
+
     tLinearDelay_init(&p->combDelay, 0.0f, leaf.sampleRate * 2);
+    
     tOneZero_init(&p->filter, 0.0f);
+    
     tNoise_init(&p->noise, WhiteNoise);
     
     for (int i = 0; i < 4; i++)
@@ -182,7 +174,14 @@
         tBiQuad_init(&p->biquad[i]);
     }
     
-    karplusstrong_init(pl, lowestFrequency);
+    p->pluckAmplitude = 0.3f;
+    p->pickupPosition = 0.4f;
+    
+    p->stretching = 0.9999f;
+    p->baseLoopGain = 0.995f;
+    p->loopGain = 0.999f;
+    
+    tKarplusStrong_setFrequency( pl, 220.0f );
 }
 
 void tKarplusStrong_free (tKarplusStrong* const pl)
@@ -206,10 +205,15 @@
 {
     _tMempool* m = *mp;
     _tKarplusStrong* p = *pl = (_tKarplusStrong*) mpool_alloc(sizeof(_tKarplusStrong), &m->pool);
- 
+    
+    if ( lowestFrequency <= 0.0f )  lowestFrequency = 8.0f;
+    
     tAllpassDelay_initToPool(&p->delayLine, 0.0f, leaf.sampleRate * 2, mp);
+    
     tLinearDelay_initToPool(&p->combDelay, 0.0f, leaf.sampleRate * 2, mp);
+    
     tOneZero_initToPool(&p->filter, 0.0f, mp);
+    
     tNoise_initToPool(&p->noise, WhiteNoise, mp);
     
     for (int i = 0; i < 4; i++)
@@ -217,7 +221,14 @@
         tBiQuad_initToPool(&p->biquad[i], mp);
     }
     
-    karplusstrong_init(pl, lowestFrequency);
+    p->pluckAmplitude = 0.3f;
+    p->pickupPosition = 0.4f;
+    
+    p->stretching = 0.9999f;
+    p->baseLoopGain = 0.995f;
+    p->loopGain = 0.999f;
+    
+    tKarplusStrong_setFrequency( pl, 220.0f );
 }
 
 void    tKarplusStrong_freeFromPool (tKarplusStrong* const pl, tMempool* const mp)
@@ -394,17 +405,6 @@
 }
 
 /* Simple Living String*/
-static void    simplelivingstring_init(tSimpleLivingString* const pl, float freq, float dampFreq,
-                                 float decay, float targetLev, float levSmoothFactor,
-                                 float levStrength, int levMode)
-{
-    _tSimpleLivingString* p = *pl;
-    
-    p->curr=0.0f;
-    p->decay=decay;
-    p->levMode=levMode;
-    tSimpleLivingString_setFreq(pl, freq);
-}
 
 void    tSimpleLivingString_init(tSimpleLivingString* const pl, float freq, float dampFreq,
                                  float decay, float targetLev, float levSmoothFactor,
@@ -412,13 +412,15 @@
 {
     _tSimpleLivingString* p = *pl = (_tSimpleLivingString*) leaf_alloc(sizeof(_tSimpleLivingString));
     
+    p->curr=0.0f;
     tExpSmooth_init(&p->wlSmooth, leaf.sampleRate/freq, 0.01); // smoother for string wavelength (not freq, to avoid expensive divisions)
+    tSimpleLivingString_setFreq(pl, freq);
     tLinearDelay_init(&p->delayLine,p->waveLengthInSamples, 2400);
     tOnePole_init(&p->bridgeFilter, dampFreq);
     tHighpass_init(&p->DCblocker,13);
+    p->decay=decay;
     tFeedbackLeveler_init(&p->fbLev, targetLev, levSmoothFactor, levStrength, levMode);
-    
-    simplelivingstring_init(pl, freq, dampFreq, decay, targetLev, levSmoothFactor, levStrength, levMode);
+    p->levMode=levMode;
 }
 
 void tSimpleLivingString_free(tSimpleLivingString* const pl)
@@ -440,14 +442,16 @@
 {
     _tMempool* m = *mp;
     _tSimpleLivingString* p = *pl = (_tSimpleLivingString*) mpool_alloc(sizeof(_tSimpleLivingString), &m->pool);
-
+    
+    p->curr=0.0f;
     tExpSmooth_initToPool(&p->wlSmooth, leaf.sampleRate/freq, 0.01, mp); // smoother for string wavelength (not freq, to avoid expensive divisions)
+    tSimpleLivingString_setFreq(pl, freq);
     tLinearDelay_initToPool(&p->delayLine,p->waveLengthInSamples, 2400, mp);
     tOnePole_initToPool(&p->bridgeFilter, dampFreq, mp);
     tHighpass_initToPool(&p->DCblocker,13, mp);
+    p->decay=decay;
     tFeedbackLeveler_initToPool(&p->fbLev, targetLev, levSmoothFactor, levStrength, levMode, mp);
-    
-    simplelivingstring_init(pl, freq, dampFreq, decay, targetLev, levSmoothFactor, levStrength, levMode);
+    p->levMode=levMode;
 }
 
 void    tSimpleLivingString_freeFromPool    (tSimpleLivingString* const pl, tMempool* const mp)
@@ -540,20 +544,6 @@
 }
 
 /* Living String*/
-static void    livingstring_init(tLivingString* const pl, float freq, float pickPos, float prepIndex,
-                           float dampFreq, float decay, float targetLev, float levSmoothFactor,
-                           float levStrength, int levMode)
-{
-    _tLivingString* p = *pl;
-    
-    p->curr = 0.0f;
-    p->freq = freq;
-    p->prepIndex = prepIndex;
-    p->dampFreq = dampFreq;
-    p->decay = decay;
-    p->prepIndex = prepIndex;
-    p->levMode = levMode;
-}
 
 void    tLivingString_init(tLivingString* const pl, float freq, float pickPos, float prepIndex,
                            float dampFreq, float decay, float targetLev, float levSmoothFactor,
@@ -561,14 +551,18 @@
 {
     _tLivingString* p = *pl = (_tLivingString*) leaf_alloc(sizeof(_tLivingString));
     
+    p->curr=0.0f;
     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);
+    p->freq = freq;
+    tExpSmooth_init(&p->ppSmooth, pickPos, 0.01); // smoother for pick position
     tLivingString_setPickPos(pl, pickPos);
+    p->prepIndex=prepIndex;
     tLinearDelay_init(&p->delLF,p->waveLengthInSamples, 2400);
     tLinearDelay_init(&p->delUF,p->waveLengthInSamples, 2400);
     tLinearDelay_init(&p->delUB,p->waveLengthInSamples, 2400);
     tLinearDelay_init(&p->delLB,p->waveLengthInSamples, 2400);
+    p->dampFreq = dampFreq;
     tOnePole_init(&p->bridgeFilter, dampFreq);
     tOnePole_init(&p->nutFilter, dampFreq);
     tOnePole_init(&p->prepFilterU, dampFreq);
@@ -575,10 +569,11 @@
     tOnePole_init(&p->prepFilterL, dampFreq);
     tHighpass_init(&p->DCblockerU,13);
     tHighpass_init(&p->DCblockerL,13);
+    p->decay=decay;
+    p->prepIndex = prepIndex;
     tFeedbackLeveler_init(&p->fbLevU, targetLev, levSmoothFactor, levStrength, levMode);
     tFeedbackLeveler_init(&p->fbLevL, targetLev, levSmoothFactor, levStrength, levMode);
-    
-    livingstring_init(pl, freq, pickPos, prepIndex, dampFreq, decay, targetLev, levSmoothFactor, levStrength, levMode);
+    p->levMode=levMode;
 }
 
 void tLivingString_free(tLivingString* const pl)
@@ -610,14 +605,18 @@
     _tMempool* m = *mp;
     _tLivingString* p = *pl = (_tLivingString*) mpool_alloc(sizeof(_tLivingString), &m->pool);
     
+    p->curr=0.0f;
     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);
+    p->freq = freq;
+    tExpSmooth_initToPool(&p->ppSmooth, pickPos, 0.01, mp); // smoother for pick position
     tLivingString_setPickPos(pl, pickPos);
+    p->prepIndex=prepIndex;
     tLinearDelay_initToPool(&p->delLF,p->waveLengthInSamples, 2400, mp);
     tLinearDelay_initToPool(&p->delUF,p->waveLengthInSamples, 2400, mp);
     tLinearDelay_initToPool(&p->delUB,p->waveLengthInSamples, 2400, mp);
     tLinearDelay_initToPool(&p->delLB,p->waveLengthInSamples, 2400, mp);
+    p->dampFreq = dampFreq;
     tOnePole_initToPool(&p->bridgeFilter, dampFreq, mp);
     tOnePole_initToPool(&p->nutFilter, dampFreq, mp);
     tOnePole_initToPool(&p->prepFilterU, dampFreq, mp);
@@ -624,10 +623,11 @@
     tOnePole_initToPool(&p->prepFilterL, dampFreq, mp);
     tHighpass_initToPool(&p->DCblockerU,13, mp);
     tHighpass_initToPool(&p->DCblockerL,13, mp);
+    p->decay=decay;
+    p->prepIndex = prepIndex;
     tFeedbackLeveler_initToPool(&p->fbLevU, targetLev, levSmoothFactor, levStrength, levMode, mp);
     tFeedbackLeveler_initToPool(&p->fbLevL, targetLev, levSmoothFactor, levStrength, levMode, mp);
-   
-    livingstring_init(pl, freq, pickPos, prepIndex, dampFreq, decay, targetLev, levSmoothFactor, levStrength, levMode);
+    p->levMode=levMode;
 }
 
 void    tLivingString_freeFromPool  (tLivingString* const pl, tMempool* const mp)
@@ -656,8 +656,8 @@
 void     tLivingString_setFreq(tLivingString* const pl, float freq)
 {    // NOTE: It is faster to set wavelength in samples directly
     _tLivingString* p = *pl;
-    if (freq < 20) freq = 20;
-    else if (freq > 10000) freq = 10000;
+    if (freq<20) freq=20;
+    else if (freq>10000) freq=10000;
     p->waveLengthInSamples = leaf.sampleRate/freq;
     tExpSmooth_setDest(&p->wlSmooth, p->waveLengthInSamples);
 }
@@ -665,8 +665,8 @@
 void     tLivingString_setWaveLength(tLivingString* const pl, float waveLength)
 {
     _tLivingString* p = *pl;
-    if (waveLength < 4.8) waveLength = 4.8;
-    else if (waveLength > 2400) waveLength = 2400;
+    if (waveLength<4.8) waveLength=4.8;
+    else if (waveLength>2400) waveLength=2400;
     p->waveLengthInSamples = waveLength;
     tExpSmooth_setDest(&p->wlSmooth, p->waveLengthInSamples);
 }
@@ -776,22 +776,19 @@
 
 ///Reed Table model
 //default values from STK are 0.6 offset and -0.8 slope
-static void    reedtable_init      (tReedTable* const pm, float offset, float slope)
+
+void    tReedTable_init      (tReedTable* const pm, float offset, float slope)
 {
-    _tReedTable* p = *pm;
+    _tReedTable* p = *pm = (_tReedTable*) leaf_alloc(sizeof(_tReedTable));
+    
     p->offset = offset;
     p->slope = slope;
 }
 
-void    tReedTable_init      (tReedTable* const pm, float offset, float slope)
-{
-    *pm = (_tReedTable*) leaf_alloc(sizeof(_tReedTable));
-    reedtable_init(pm, offset, slope);
-}
-
 void    tReedTable_free      (tReedTable* const pm)
 {
     _tReedTable* p = *pm;
+    
     leaf_free(p);
 }
 
@@ -798,8 +795,10 @@
 void    tReedTable_initToPool   (tReedTable* const pm, float offset, float slope, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    *pm = (_tReedTable*) mpool_alloc(sizeof(_tReedTable), &m->pool);
-    reedtable_init(pm, offset, slope);
+    _tReedTable* p = *pm = (_tReedTable*) mpool_alloc(sizeof(_tReedTable), &m->pool);
+    
+    p->offset = offset;
+    p->slope = slope;
 }
 
 void    tReedTable_freeFromPool (tReedTable* const pm, tMempool* const mp)
@@ -806,6 +805,7 @@
 {
     _tMempool* m = *mp;
     _tReedTable* p = *pm;
+    
     mpool_free(p, &m->pool);
 }
 
--- a/LEAF/Src/leaf-reverb.c
+++ b/LEAF/Src/leaf-reverb.c
@@ -19,19 +19,15 @@
 #endif
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ PRCReverb ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
-static void    prcreverb_init(tPRCReverb* const rev, float t60)
+void    tPRCReverb_init(tPRCReverb* const rev, float t60)
 {
-    _tPRCReverb* r = *rev;
+    _tPRCReverb* r = *rev = (_tPRCReverb*) leaf_alloc(sizeof(_tPRCReverb));
     
     if (t60 <= 0.0f) t60 = 0.001f;
     
     r->inv_441 = 1.0f/44100.0f;
     
-    // Delay lengths for 44100 Hz sample rate.
-    r->lengths[0] = 341;
-    r->lengths[1] = 613;
-    r->lengths[2] = 1557;
-    r->lengths[3] = 2137;
+    int lengths[4] = { 341, 613, 1557, 2137 }; // Delay lengths for 44100 Hz sample rate.
     double scaler = leaf.sampleRate * r->inv_441;
     
     int delay, i;
@@ -39,16 +35,20 @@
     {
         for (i=0; i<4; i++)
         {
-            delay = (int) scaler * r->lengths[i];
+            delay = (int) scaler * lengths[i];
             
             if ( (delay & 1) == 0)          delay++;
             
             while ( !LEAF_isPrime(delay) )  delay += 2;
             
-            r->lengths[i] = delay;
+            lengths[i] = delay;
         }
     }
     
+    tDelay_init(&r->allpassDelays[0], lengths[0], lengths[0] * 2);
+    tDelay_init(&r->allpassDelays[1], lengths[1], lengths[1] * 2);
+    tDelay_init(&r->combDelay, lengths[2], lengths[2] * 2);
+    
     tPRCReverb_setT60(rev, t60);
     
     r->allpassCoeff = 0.7f;
@@ -55,18 +55,10 @@
     r->mix = 0.5f;
 }
 
-void    tPRCReverb_init(tPRCReverb* const rev, float t60)
-{
-    _tPRCReverb* r = *rev = (_tPRCReverb*) leaf_alloc(sizeof(_tPRCReverb));
-    prcreverb_init(rev, t60);
-    tDelay_init(&r->allpassDelays[0], r->lengths[0], r->lengths[0] * 2);
-    tDelay_init(&r->allpassDelays[1], r->lengths[1], r->lengths[1] * 2);
-    tDelay_init(&r->combDelay, r->lengths[2], r->lengths[2] * 2);
-}
-
 void tPRCReverb_free(tPRCReverb* const rev)
 {
     _tPRCReverb* r = *rev;
+    
     tDelay_free(&r->allpassDelays[0]);
     tDelay_free(&r->allpassDelays[1]);
     tDelay_free(&r->combDelay);
@@ -77,10 +69,37 @@
 {
     _tMempool* m = *mp;
     _tPRCReverb* r = *rev = (_tPRCReverb*) mpool_alloc(sizeof(_tPRCReverb), &m->pool);
-    prcreverb_init(rev, t60);
-    tDelay_initToPool(&r->allpassDelays[0], r->lengths[0], r->lengths[0] * 2, mp);
-    tDelay_initToPool(&r->allpassDelays[1], r->lengths[1], r->lengths[1] * 2, mp);
-    tDelay_initToPool(&r->combDelay, r->lengths[2], r->lengths[2] * 2, mp);
+    
+    if (t60 <= 0.0f) t60 = 0.001f;
+    
+    r->inv_441 = 1.0f/44100.0f;
+    
+    int lengths[4] = { 341, 613, 1557, 2137 }; // Delay lengths for 44100 Hz sample rate.
+    double scaler = leaf.sampleRate * r->inv_441;
+    
+    int delay, i;
+    if (scaler != 1.0f)
+    {
+        for (i=0; i<4; i++)
+        {
+            delay = (int) scaler * lengths[i];
+            
+            if ( (delay & 1) == 0)          delay++;
+            
+            while ( !LEAF_isPrime(delay) )  delay += 2;
+            
+            lengths[i] = delay;
+        }
+    }
+    
+    tDelay_initToPool(&r->allpassDelays[0], lengths[0], lengths[0] * 2, mp);
+    tDelay_initToPool(&r->allpassDelays[1], lengths[1], lengths[1] * 2, mp);
+    tDelay_initToPool(&r->combDelay, lengths[2], lengths[2] * 2, mp);
+    
+    tPRCReverb_setT60(rev, t60);
+    
+    r->allpassCoeff = 0.7f;
+    r->mix = 0.5f;
 }
 
 void    tPRCReverb_freeFromPool (tPRCReverb* const rev, tMempool* const mp)
@@ -87,6 +106,7 @@
 {
     _tMempool* m = *mp;
     _tPRCReverb* r = *rev;
+    
     tDelay_freeFromPool(&r->allpassDelays[0], mp);
     tDelay_freeFromPool(&r->allpassDelays[1], mp);
     tDelay_freeFromPool(&r->combDelay, mp);
@@ -152,64 +172,62 @@
 }
 
 /* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ NReverb ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */
-static void    nreverb_init(tNReverb* const rev, float t60)
+void    tNReverb_init(tNReverb* const rev, float t60)
 {
-    _tNReverb* r = *rev;
+    _tNReverb* r = *rev = (_tNReverb*) leaf_alloc(sizeof(_tNReverb));
     
     if (t60 <= 0.0f) t60 = 0.001f;
     
     r->inv_441 = 1.0f/44100.0f;
     
-    int l[15] = {1433, 1601, 1867, 2053, 2251, 2399, 347, 113, 37, 59, 53, 43, 37, 29, 19}; // Delay lengths for 44100 Hz sample rate.
-    for (int i = 0; i < 15; i++) r->lengths[i] = l[i];
+    int lengths[15] = {1433, 1601, 1867, 2053, 2251, 2399, 347, 113, 37, 59, 53, 43, 37, 29, 19}; // Delay lengths for 44100 Hz sample rate.
     double scaler = leaf.sampleRate / 25641.0f;
     
     int delay, i;
+    
     for (i=0; i < 15; i++)
     {
-        delay = (int) scaler * r->lengths[i];
+        delay = (int) scaler * lengths[i];
         if ( (delay & 1) == 0)
             delay++;
         while ( !LEAF_isPrime(delay) )
             delay += 2;
-        r->lengths[i] = delay;
+        lengths[i] = delay;
     }
     
-    tNReverb_setT60(rev, t60);
-    r->allpassCoeff = 0.7f;
-    r->mix = 0.3f;
-    
-    for (int i = 0; i < 6; i++)
+    for ( i=0; i<6; i++ )
     {
-        r->combCoeffs[i] = pow(10.0, (-3 * r->lengths[i] * leaf.invSampleRate / t60));
+    	tLinearDelay_init(&r->combDelays[i], lengths[i], lengths[i] * 2.0f);
+    	tLinearDelay_clear(&r->combDelays[i]);
+        r->combCoeffs[i] = pow(10.0, (-3 * lengths[i] * leaf.invSampleRate / t60));
     }
-}
-
-void    tNReverb_init(tNReverb* const rev, float t60)
-{
-    _tNReverb* r = *rev = (_tNReverb*) leaf_alloc(sizeof(_tNReverb));
-    nreverb_init(rev, t60);
-    for (int i = 0; i < 6; i++)
+    
+    for ( i=0; i<8; i++ )
     {
-    	tLinearDelay_init(&r->combDelays[i], r->lengths[i], r->lengths[i] * 2.0f);
+    	tLinearDelay_init(&r->allpassDelays[i], lengths[i+6], lengths[i+6] * 2.0f);
+    	tLinearDelay_clear(&r->allpassDelays[i]);
     }
-    for (int i = 0; i < 8; i++)
-    {
-    	tLinearDelay_init(&r->allpassDelays[i], r->lengths[i+6], r->lengths[i+6] * 2.0f);
-    }
+
+    
+    tNReverb_setT60(rev, t60);
+    r->allpassCoeff = 0.7f;
+    r->mix = 0.3f;
 }
 
 void    tNReverb_free(tNReverb* const rev)
 {
     _tNReverb* r = *rev;
+    
     for (int i = 0; i < 6; i++)
     {
     	tLinearDelay_free(&r->combDelays[i]);
     }
+    
     for (int i = 0; i < 8; i++)
     {
     	tLinearDelay_free(&r->allpassDelays[i]);
     }
+    
     leaf_free(r);
 }
 
@@ -217,15 +235,41 @@
 {
     _tMempool* m = *mp;
     _tNReverb* r = *rev = (_tNReverb*) mpool_alloc(sizeof(_tNReverb), &m->pool);
-    nreverb_init(rev, t60);
-    for (int i = 0; i < 6; i++)
+    
+    if (t60 <= 0.0f) t60 = 0.001f;
+    
+    r->inv_441 = 1.0f/44100.0f;
+    
+    int lengths[15] = {1433, 1601, 1867, 2053, 2251, 2399, 347, 113, 37, 59, 53, 43, 37, 29, 19}; // Delay lengths for 44100 Hz sample rate.
+    double scaler = leaf.sampleRate / 25641.0f;
+    
+    int delay, i;
+    
+    for (i=0; i < 15; i++)
     {
-        tLinearDelay_initToPool(&r->combDelays[i], r->lengths[i], r->lengths[i] * 2.0f, mp);
+        delay = (int) scaler * lengths[i];
+        if ( (delay & 1) == 0)
+            delay++;
+        while ( !LEAF_isPrime(delay) )
+            delay += 2;
+        lengths[i] = delay;
     }
-    for (int i = 0; i < 8; i++)
+    
+    for ( i=0; i<6; i++ )
     {
-        tLinearDelay_initToPool(&r->allpassDelays[i], r->lengths[i+6], r->lengths[i+6] * 2.0f, mp);
+        tLinearDelay_initToPool(&r->combDelays[i], lengths[i], lengths[i] * 2.0f, mp);
+        r->combCoeffs[i] = pow(10.0, (-3 * lengths[i] * leaf.invSampleRate / t60));
     }
+    
+    for ( i=0; i<8; i++ )
+    {
+        tLinearDelay_initToPool(&r->allpassDelays[i], lengths[i+6], lengths[i+6] * 2.0f, mp);
+    }
+    
+    
+    tNReverb_setT60(rev, t60);
+    r->allpassCoeff = 0.7f;
+    r->mix = 0.3f;
 }
 
 void    tNReverb_freeFromPool   (tNReverb* const rev, tMempool* const mp)
@@ -232,14 +276,17 @@
 {
     _tMempool* m = *mp;
     _tNReverb* r = *rev;
+    
     for (int i = 0; i < 6; i++)
     {
         tLinearDelay_freeFromPool(&r->combDelays[i], mp);
     }
+    
     for (int i = 0; i < 8; i++)
     {
         tLinearDelay_freeFromPool(&r->allpassDelays[i], mp);
     }
+    
     mpool_free(r, &m->pool);
 }
 
@@ -383,41 +430,16 @@
 float       in_allpass_delays[4] = { 4.771f, 3.595f, 12.73f, 9.307f };
 float       in_allpass_gains[4] = { 0.75f, 0.75f, 0.625f, 0.625f };
 
-static void    dattorroreverb_init              (tDattorroReverb* const rev)
+
+void    tDattorroReverb_init              (tDattorroReverb* const rev)
 {
-    _tDattorroReverb* r = *rev;
+    _tDattorroReverb* r = *rev = (_tDattorroReverb*) leaf_alloc(sizeof(_tDattorroReverb));
     
     r->size_max = 2.0f;
     r->size = 1.f;
+    r->t = r->size * leaf.sampleRate * 0.001f;
     r->frozen = 0;
     // INPUT
-    for (int i = 0; i < 4; i++)
-    {
-        tAllpass_setGain(&r->in_allpass[i], in_allpass_gains[i]);
-    }
-    
-    // FEEDBACK 1
-    tAllpass_setGain(&r->f1_allpass, 0.7f);
-    tCycle_setFreq(&r->f1_lfo, 0.1f);
-    
-    // FEEDBACK 2
-    tAllpass_setGain(&r->f2_allpass, 0.7f);
-    tCycle_setFreq(&r->f2_lfo, 0.07f);
-    
-    // PARAMETERS
-    tDattorroReverb_setMix(rev, 0.5f);
-    tDattorroReverb_setInputDelay(rev,  0.f);
-    tDattorroReverb_setInputFilter(rev, 10000.f);
-    tDattorroReverb_setFeedbackFilter(rev, 5000.f);
-    tDattorroReverb_setFeedbackGain(rev, 0.4f);
-}
-
-void    tDattorroReverb_init              (tDattorroReverb* const rev)
-{
-    _tDattorroReverb* r = *rev = (_tDattorroReverb*) leaf_alloc(sizeof(_tDattorroReverb));
-    float size_max = 2.0f;
-    r->t = leaf.sampleRate * 0.001f;
-    // INPUT
     tTapeDelay_init(&r->in_delay, 0.f, SAMP(200.f));
     tOnePole_init(&r->in_filter, 1.f);
     
@@ -424,14 +446,16 @@
     for (int i = 0; i < 4; i++)
     {
         tAllpass_init(&r->in_allpass[i], SAMP(in_allpass_delays[i]), SAMP(20.f)); // * r->size_max
+        tAllpass_setGain(&r->in_allpass[i], in_allpass_gains[i]);
     }
     
     // FEEDBACK 1
     tAllpass_init(&r->f1_allpass, SAMP(30.51f), SAMP(100.f)); // * r->size_max
+    tAllpass_setGain(&r->f1_allpass, 0.7f);
     
-    tTapeDelay_init(&r->f1_delay_1, SAMP(141.69f), SAMP(200.0f) * size_max + 1);
-    tTapeDelay_init(&r->f1_delay_2, SAMP(89.24f), SAMP(100.0f) * size_max + 1);
-    tTapeDelay_init(&r->f1_delay_3, SAMP(125.f), SAMP(200.0f) * size_max + 1);
+    tTapeDelay_init(&r->f1_delay_1, SAMP(141.69f), SAMP(200.0f) * r->size_max + 1);
+    tTapeDelay_init(&r->f1_delay_2, SAMP(89.24f), SAMP(100.0f) * r->size_max + 1);
+    tTapeDelay_init(&r->f1_delay_3, SAMP(125.f), SAMP(200.0f) * r->size_max + 1);
     
     tOnePole_init(&r->f1_filter, 1.f);
     
@@ -438,13 +462,15 @@
     tHighpass_init(&r->f1_hp, 20.f);
     
     tCycle_init(&r->f1_lfo);
+    tCycle_setFreq(&r->f1_lfo, 0.1f);
     
     // FEEDBACK 2
     tAllpass_init(&r->f2_allpass, SAMP(22.58f), SAMP(100.f)); // * r->size_max
+    tAllpass_setGain(&r->f2_allpass, 0.7f);
     
-    tTapeDelay_init(&r->f2_delay_1, SAMP(149.62f), SAMP(200.f) * size_max + 1);
-    tTapeDelay_init(&r->f2_delay_2, SAMP(60.48f), SAMP(100.f) * size_max + 1);
-    tTapeDelay_init(&r->f2_delay_3, SAMP(106.28f), SAMP(200.f) * size_max + 1);
+    tTapeDelay_init(&r->f2_delay_1, SAMP(149.62f), SAMP(200.f) * r->size_max + 1);
+    tTapeDelay_init(&r->f2_delay_2, SAMP(60.48f), SAMP(100.f) * r->size_max + 1);
+    tTapeDelay_init(&r->f2_delay_3, SAMP(106.28f), SAMP(200.f) * r->size_max + 1);
     
     tOnePole_init(&r->f2_filter, 1.f);
     
@@ -451,8 +477,19 @@
     tHighpass_init(&r->f2_hp, 20.f);
     
     tCycle_init(&r->f2_lfo);
+    tCycle_setFreq(&r->f2_lfo, 0.07f);
     
-    dattorroreverb_init(rev);
+    
+    // PARAMETERS
+    tDattorroReverb_setMix(rev, 0.5f);
+    
+    tDattorroReverb_setInputDelay(rev,  0.f);
+    
+    tDattorroReverb_setInputFilter(rev, 10000.f);
+    
+    tDattorroReverb_setFeedbackFilter(rev, 5000.f);
+    
+    tDattorroReverb_setFeedbackGain(rev, 0.4f);
 }
 
 void    tDattorroReverb_free              (tDattorroReverb* const rev)
@@ -501,8 +538,11 @@
 {
     _tMempool* m = *mp;
     _tDattorroReverb* r = *rev = (_tDattorroReverb*) mpool_alloc(sizeof(_tDattorroReverb), &m->pool);
-    float size_max = 2.0f;
-    r->t = leaf.sampleRate * 0.001f;
+    
+    r->size_max = 2.0f;
+    r->size = 1.f;
+    r->t = r->size * leaf.sampleRate * 0.001f;
+    r->frozen = 0;
     // INPUT
     tTapeDelay_initToPool(&r->in_delay, 0.f, SAMP(200.f), mp);
     tOnePole_initToPool(&r->in_filter, 1.f, mp);
@@ -510,14 +550,16 @@
     for (int i = 0; i < 4; i++)
     {
         tAllpass_initToPool(&r->in_allpass[i], SAMP(in_allpass_delays[i]), SAMP(20.f), mp); // * r->size_max
+        tAllpass_setGain(&r->in_allpass[i], in_allpass_gains[i]);
     }
     
     // FEEDBACK 1
     tAllpass_initToPool(&r->f1_allpass, SAMP(30.51f), SAMP(100.f), mp); // * r->size_max
+    tAllpass_setGain(&r->f1_allpass, 0.7f);
     
-    tTapeDelay_initToPool(&r->f1_delay_1, SAMP(141.69f), SAMP(200.0f) * size_max + 1, mp);
-    tTapeDelay_initToPool(&r->f1_delay_2, SAMP(89.24f), SAMP(100.0f) * size_max + 1, mp);
-    tTapeDelay_initToPool(&r->f1_delay_3, SAMP(125.f), SAMP(200.0f) * size_max + 1, mp);
+    tTapeDelay_initToPool(&r->f1_delay_1, SAMP(141.69f), SAMP(200.0f) * r->size_max + 1, mp);
+    tTapeDelay_initToPool(&r->f1_delay_2, SAMP(89.24f), SAMP(100.0f) * r->size_max + 1, mp);
+    tTapeDelay_initToPool(&r->f1_delay_3, SAMP(125.f), SAMP(200.0f) * r->size_max + 1, mp);
     
     tOnePole_initToPool(&r->f1_filter, 1.f, mp);
     
@@ -524,13 +566,15 @@
     tHighpass_initToPool(&r->f1_hp, 20.f, mp);
     
     tCycle_initToPool(&r->f1_lfo, mp);
+    tCycle_setFreq(&r->f1_lfo, 0.1f);
     
     // FEEDBACK 2
     tAllpass_initToPool(&r->f2_allpass, SAMP(22.58f), SAMP(100.f), mp); // * r->size_max
+    tAllpass_setGain(&r->f2_allpass, 0.7f);
     
-    tTapeDelay_initToPool(&r->f2_delay_1, SAMP(149.62f), SAMP(200.f) * size_max + 1, mp);
-    tTapeDelay_initToPool(&r->f2_delay_2, SAMP(60.48f), SAMP(100.f) * size_max + 1, mp);
-    tTapeDelay_initToPool(&r->f2_delay_3, SAMP(106.28f), SAMP(200.f) * size_max + 1, mp);
+    tTapeDelay_initToPool(&r->f2_delay_1, SAMP(149.62f), SAMP(200.f) * r->size_max + 1, mp);
+    tTapeDelay_initToPool(&r->f2_delay_2, SAMP(60.48f), SAMP(100.f) * r->size_max + 1, mp);
+    tTapeDelay_initToPool(&r->f2_delay_3, SAMP(106.28f), SAMP(200.f) * r->size_max + 1, mp);
     
     tOnePole_initToPool(&r->f2_filter, 1.f, mp);
     
@@ -537,8 +581,19 @@
     tHighpass_initToPool(&r->f2_hp, 20.f, mp);
     
     tCycle_initToPool(&r->f2_lfo, mp);
+    tCycle_setFreq(&r->f2_lfo, 0.07f);
     
-    dattorroreverb_init(rev);
+    
+    // PARAMETERS
+    tDattorroReverb_setMix(rev, 0.5f);
+    
+    tDattorroReverb_setInputDelay(rev,  0.f);
+    
+    tDattorroReverb_setInputFilter(rev, 10000.f);
+    
+    tDattorroReverb_setFeedbackFilter(rev, 5000.f);
+    
+    tDattorroReverb_setFeedbackGain(rev, 0.4f);
 }
 
 void    tDattorroReverb_freeFromPool      (tDattorroReverb* const rev, tMempool* const mp)
--- a/LEAF/Src/leaf-sampling.c
+++ b/LEAF/Src/leaf-sampling.c
@@ -23,9 +23,13 @@
 #endif
 
 //==============================================================================
-static void  buffer_init (tBuffer* const sb, uint32_t length)
+
+void  tBuffer_init (tBuffer* const sb, uint32_t length)
 {
-    _tBuffer* s = *sb;
+    _tBuffer* s = *sb = (_tBuffer*) leaf_alloc(sizeof(_tBuffer));
+    
+    s->buff = (float*) leaf_alloc( sizeof(float) * length);
+    
     s->bufferLength = length;
     s->recordedLength = 0;
     s->active = 0;
@@ -33,16 +37,10 @@
     s->mode = RecordOneShot;
 }
 
-void  tBuffer_init (tBuffer* const sb, uint32_t length)
-{
-    _tBuffer* s = *sb = (_tBuffer*) leaf_alloc(sizeof(_tBuffer));
-    buffer_init(sb, length);
-    s->buff = (float*) leaf_alloc( sizeof(float) * length);
-}
-
 void  tBuffer_free (tBuffer* const sb)
 {
     _tBuffer* s = *sb;
+    
     leaf_free(s->buff);
     leaf_free(s);
 }
@@ -51,8 +49,13 @@
 {
     _tMempool* m = *mp;
     _tBuffer* s = *sb = (_tBuffer*) mpool_alloc(sizeof(_tBuffer), &m->pool);
-    buffer_init(sb, length);
+    
     s->buff = (float*) mpool_alloc( sizeof(float) * length, &m->pool);
+    
+    s->bufferLength = length;
+    s->recordedLength = 0;
+    s->idx = 0;
+    s->mode = RecordOneShot;
 }
 
 void  tBuffer_freeFromPool (tBuffer* const sb, tMempool* const mp)
@@ -59,6 +62,7 @@
 {
     _tMempool* m = *mp;
     _tBuffer* s = *sb;
+
     mpool_free(s->buff, &m->pool);
     mpool_free(s, &m->pool);
 }
@@ -158,9 +162,9 @@
 
 static void attemptStartEndChange(tSampler* const sp);
 
-static void sampler_init(tSampler* const sp, tBuffer* const b)
+void tSampler_init(tSampler* const sp, tBuffer* const b)
 {
-    _tSampler* p = *sp;
+    _tSampler* p = *sp = (_tSampler*) leaf_alloc(sizeof(_tSampler));
     _tBuffer* s = *b;
     
     p->samp = s;
@@ -184,6 +188,7 @@
     
     p->cfxlen = 500; // default 300 sample crossfade
     
+    tRamp_init(&p->gain, 7.0f, 1);
     tRamp_setVal(&p->gain, 0.f);
     
     p->targetstart = -1;
@@ -190,34 +195,12 @@
     p->targetend = -1;
 }
 
-void tSampler_init(tSampler* const sp, tBuffer* const b)
-{
-    _tSampler* p = *sp = (_tSampler*) leaf_alloc(sizeof(_tSampler));
-    tRamp_init(&p->gain, 7.0f, 1);
-    sampler_init(sp, b);
-}
-
 void tSampler_free         (tSampler* const sp)
 {
     _tSampler* p = *sp;
     tRamp_free(&p->gain);
+    
     leaf_free(p);
-}
-
-void tSampler_initToPool    (tSampler* const sp, tBuffer* const b, tMempool* mp)
-{
-    _tMempool* m = *mp;
-    _tSampler* p = *sp = (_tSampler*) mpool_alloc(sizeof(_tSampler), &m->pool);
-    tRamp_initToPool(&p->gain, 7.0f, 1, mp);
-    sampler_init(sp, b);
-}
-
-void tSampler_freeFromPool  (tSampler* const sp, tMempool* mp)
-{
-    _tMempool* m = *mp;
-    _tSampler* p = *sp;
-    tRamp_freeFromPool(&p->gain, mp);
-    mpool_free(p, &m->pool);
 }
 
 void tSampler_setSample (tSampler* const sp, tBuffer* const b)
--- a/LEAF_JUCEPlugin/Source/MyTest.cpp
+++ b/LEAF_JUCEPlugin/Source/MyTest.cpp
@@ -46,7 +46,7 @@
     tSVF_init(&bp1, SVFTypeBandpass, 100, 4.0f);
     tSVF_init(&bp2, SVFTypeBandpass, 1000, 4.0f);
     
-    tFormantShifter_init(&fs, 20);
+    tFormantShifter_init(&fs, 2048, 20);
     
     // Init and set record
     tBuffer_init (&buff, leaf.sampleRate); // init, 1 second buffer