shithub: leaf

Download patch

ref: 3b564d49db43601e7e6bbe0b013febbbd90217a4
parent: d6d64a92922b89abb17d2e695586ad1fdcb4bf89
author: Matthew Wang <Matthew@nat-oitwireless-inside-vapornet100-10-9-82-139.princeton.edu>
date: Thu Oct 24 12:16:48 EDT 2019

use mempool for all large/variable size member and free function for every object

binary files a/LEAF/Inc/.DS_Store b/LEAF/Inc/.DS_Store differ
--- a/LEAF/Inc/leaf-808.h
+++ b/LEAF/Inc/leaf-808.h
@@ -15,9 +15,7 @@
 
 //==============================================================================
     
-#include "leaf-globals.h"
 #include "leaf-math.h"
-
 #include "leaf-oscillator.h"
 #include "leaf-utilities.h"
 #include "leaf-filter.h"
@@ -37,10 +35,11 @@
     tHighpass highpass;
     float oscMix;
     float filterCutoff;
+    oBool useStick;
     
 } t808Cowbell;
 
-void    t808Cowbell_init             (t808Cowbell* const);
+void    t808Cowbell_init             (t808Cowbell* const, int useStick);
 void    t808Cowbell_free             (t808Cowbell* const);
 float   t808Cowbell_tick             (t808Cowbell* const);
 void    t808Cowbell_on               (t808Cowbell* const, float vel);
@@ -49,6 +48,7 @@
 void    t808Cowbell_setBandpassFreq  (t808Cowbell* const, float freq);
 void    t808Cowbell_setFreq          (t808Cowbell* const, float freq);
 void    t808Cowbell_setOscMix        (t808Cowbell* const, float oscMix);
+void    t808Cowbell_setStick         (t808Cowbell* const, int useStick);
 
 //==============================================================================
     
--- a/LEAF/Inc/leaf-WDF.h
+++ b/LEAF/Inc/leaf-WDF.h
@@ -14,7 +14,7 @@
 
 //==============================================================================
 
-#include "leaf-globals.h"
+#include "leaf-global.h"
 #include "leaf-math.h"
 
 //==============================================================================
--- a/LEAF/Inc/leaf-crusher.h
+++ b/LEAF/Inc/leaf-crusher.h
@@ -18,7 +18,7 @@
 
 //==============================================================================
 
-#include "leaf-globals.h"
+#include "leaf-global.h"
 #include "leaf-math.h"
 
 //==============================================================================
--- a/LEAF/Inc/leaf-delay.h
+++ b/LEAF/Inc/leaf-delay.h
@@ -7,18 +7,17 @@
 ==============================================================================*/
 
 #ifndef LEAF_DELAY_H_INCLUDED
-#define LEAF_DELAY_H_INCLUDED
-
-#ifdef __cplusplus
-extern "C" {
+#define LEAF_DELAY_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
 #endif
 
-//==============================================================================
+//==============================================================================
     
-#include "leaf-globals.h"
 #include "leaf-math.h"
 
-//==============================================================================
+//==============================================================================
     
 /* Non-interpolating delay, reimplemented from STK (Cook and Scavone). */
 typedef struct _tDelay
@@ -46,7 +45,7 @@
 float       tDelay_getLastOut   (tDelay*  const);
 float       tDelay_getLastIn    (tDelay*  const);
 
-//==============================================================================
+//==============================================================================
     
 /* Linearly-interpolating delay, reimplemented from STK (Cook and Scavone). */
 typedef struct _tDelayL
@@ -80,7 +79,7 @@
 float       tDelayL_getLastOut  (tDelayL*  const);
 float       tDelayL_getLastIn   (tDelayL*  const);
 
-//==============================================================================
+//==============================================================================
     
 /* Allpass-interpolating delay, reimplemented from STK (Cook and Scavone). */
 typedef struct _tDelayA
@@ -103,7 +102,7 @@
 } tDelayA;
 
 void        tDelayA_init        (tDelayA*  const, float delay, uint32_t maxDelay);
-void        tDelayA_free        (tDelayA* const);
+void        tDelayA_free        (tDelayA* const);
 
 int         tDelayA_setDelay    (tDelayA*  const, float delay);
 float       tDelayA_getDelay    (tDelayA*  const);
@@ -114,44 +113,44 @@
 float       tDelayA_getLastOut  (tDelayA*  const);
 float       tDelayA_getLastIn   (tDelayA*  const);
 
-//==============================================================================
-    
-/* Linear interpolating delay with fixed read and write pointers, variable rate. */
-typedef struct _tTapeDelay
-{
-    float gain;
-    float* buff;
-    
-    float lastOut, lastIn;
-    
-    uint32_t inPoint;
-    
-    uint32_t maxDelay;
-    
-    float delay, inc, idx;
-    
-    float apInput;
-    
-} tTapeDelay;
-
-void        tTapeDelay_init        (tTapeDelay*  const, float delay, uint32_t maxDelay);
-void        tTapeDelay_free        (tTapeDelay* const);
-
-int         tTapeDelay_setDelay    (tTapeDelay*  const, float delay);
-float       tTapeDelay_getDelay    (tTapeDelay*  const);
-void        tTapeDelay_tapIn       (tTapeDelay*  const, float in, uint32_t tapDelay);
-float       tTapeDelay_tapOut      (tTapeDelay* const d, float tapDelay);
-float       tTapeDelay_addTo       (tTapeDelay*  const, float value, uint32_t tapDelay);
-float       tTapeDelay_tick        (tTapeDelay*  const, float sample);
-float       tTapeDelay_getLastOut  (tTapeDelay*  const);
-float       tTapeDelay_getLastIn   (tTapeDelay*  const);
-    
-//==============================================================================
-    
-#ifdef __cplusplus
-}
+//==============================================================================
+    
+/* Linear interpolating delay with fixed read and write pointers, variable rate. */
+typedef struct _tTapeDelay
+{
+    float gain;
+    float* buff;
+    
+    float lastOut, lastIn;
+    
+    uint32_t inPoint;
+    
+    uint32_t maxDelay;
+    
+    float delay, inc, idx;
+    
+    float apInput;
+    
+} tTapeDelay;
+
+void        tTapeDelay_init        (tTapeDelay*  const, float delay, uint32_t maxDelay);
+void        tTapeDelay_free        (tTapeDelay* const);
+
+int         tTapeDelay_setDelay    (tTapeDelay*  const, float delay);
+float       tTapeDelay_getDelay    (tTapeDelay*  const);
+void        tTapeDelay_tapIn       (tTapeDelay*  const, float in, uint32_t tapDelay);
+float       tTapeDelay_tapOut      (tTapeDelay* const d, float tapDelay);
+float       tTapeDelay_addTo       (tTapeDelay*  const, float value, uint32_t tapDelay);
+float       tTapeDelay_tick        (tTapeDelay*  const, float sample);
+float       tTapeDelay_getLastOut  (tTapeDelay*  const);
+float       tTapeDelay_getLastIn   (tTapeDelay*  const);
+    
+//==============================================================================
+    
+#ifdef __cplusplus
+}
 #endif
 
-#endif  // LEAF_DELAY_H_INCLUDED
-
+#endif  // LEAF_DELAY_H_INCLUDED
+
 //==============================================================================
--- a/LEAF/Inc/leaf-filter.h
+++ b/LEAF/Inc/leaf-filter.h
@@ -15,11 +15,8 @@
 
 //==============================================================================
     
-#include "leaf-globals.h"
 #include "leaf-math.h"
-
 #include "leaf-delay.h"
-
 #include "leaf-tables.h"
 
 //==============================================================================
--- a/LEAF/Inc/leaf-formant.h
+++ b/LEAF/Inc/leaf-formant.h
@@ -15,7 +15,8 @@
 
 //==============================================================================
     
-#include "leaf-globals.h"
+#include "leaf-global.h"
+#include "leaf-mempool.h"
 #include "leaf-math.h"
 
 //==============================================================================
--- /dev/null
+++ b/LEAF/Inc/leaf-global.h
@@ -1,0 +1,37 @@
+/*
+  ==============================================================================
+
+    leaf-global.h
+    Created: 24 Oct 2019 2:24:38pm
+    Author:  Matthew Wang
+
+  ==============================================================================
+*/
+
+#ifndef LEAF_GLOBAL_H_INCLUDED
+#define LEAF_GLOBAL_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _LEAF
+{
+    float   sampleRate;
+    float   invSampleRate;
+    int     blockSize;
+    
+    float   (*random)(void);
+} LEAF;
+
+extern LEAF leaf; // The global instance of LEAF.
+    
+    //==============================================================================
+    
+#ifdef __cplusplus
+}
+#endif
+
+#endif  // LEAF_GLOBAL_H_INCLUDED
+
+//==============================================================================
--- a/LEAF/Inc/leaf-globals.h
+++ /dev/null
@@ -1,61 +1,0 @@
-/*==============================================================================
-
-    leaf-globals.h
-    Created: 23 Jan 2017 10:34:10pm
-    Author:  Michael R Mulshine
-
-==============================================================================*/
-
-#ifndef LEAF_GLOBALS_H_INCLUDED
-#define LEAF_GLOBALS_H_INCLUDED
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-    
-//==============================================================================
-
-#include "leaf-mempool.h"
-    
-//==============================================================================
-    
-typedef struct _LEAF
-{
-    float   sampleRate;
-    float   invSampleRate;
-    int     blockSize;
-    
-
-    float*  sinewave;
-    float*  sawtooth[11];
-    float*  square[11];
-    float*  triangle[11];
-
-
-    float   (*random)(void);
-} LEAF;
-    
-//==============================================================================
-
-extern LEAF leaf; // The global instance of LEAF.
-    
-//==============================================================================
-
-#define PS_FRAME_SIZE 1024 // SNAC_FRAME_SIZE in leaf-pitch.h should match (or be smaller than?) this
-#define ENV_WINDOW_SIZE 1024
-#define ENV_HOP_SIZE 256
-    
-union unholy_t { /* a union between a float and an integer */
-    float f;
-    int i;
-};
-    
-//==============================================================================
-    
-#ifdef __cplusplus
-}
-#endif
-    
-#endif  // LEAF_GLOBALS_H_INCLUDED
-
-//==============================================================================
--- a/LEAF/Inc/leaf-math.h
+++ b/LEAF/Inc/leaf-math.h
@@ -13,6 +13,7 @@
 extern "C" {
 #endif
 
+#include "leaf-global.h"
 #include "math.h"
 #include "stdint.h"
 #include "stdlib.h"
@@ -26,6 +27,12 @@
     OTRUE  = 1,
     OFALSE = 0
 }oBool;
+    
+// Allows for bitwise operations on floats
+union unholy_t { /* a union between a float and an integer */
+    float f;
+    int i;
+};
 
 #define SQRT8 2.82842712475f
 #define WSCALE 1.30612244898f
--- a/LEAF/Inc/leaf-mempool.h
+++ b/LEAF/Inc/leaf-mempool.h
@@ -50,9 +50,6 @@
     
 //==============================================================================
 
-
-#define MPOOL_POOL_SIZE   50 000
-
 #define MPOOL_ALIGN_SIZE (8)
 
 //#define size_t unsigned long
--- a/LEAF/Inc/leaf-midi.h
+++ b/LEAF/Inc/leaf-midi.h
@@ -15,9 +15,9 @@
     
 //==============================================================================
     
-#include "leaf-globals.h"
+#include "leaf-global.h"
+#include "leaf-mempool.h"
 #include "leaf-math.h"
-
 #include "leaf-utilities.h"
 
 //==============================================================================
@@ -28,7 +28,7 @@
     tStack stack;
     tStack orderStack;
     
-    tRamp* ramp;
+    tRamp* ramps;
     float* rampVals;
     oBool* firstReceived;
     float glideTime;
--- a/LEAF/Inc/leaf-oscillator.h
+++ b/LEAF/Inc/leaf-oscillator.h
@@ -7,15 +7,14 @@
 ==============================================================================*/
 
 #ifndef LEAF_OSCILLATOR_H_INCLUDED
-#define LEAF_OSCILLATOR_H_INCLUDED
-
-#ifdef __cplusplus
-extern "C" {
+#define LEAF_OSCILLATOR_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
 #endif
 
 //==============================================================================
 
-#include "leaf-globals.h"
 #include "leaf-math.h"
 
 #include "leaf-filter.h"
@@ -171,12 +170,12 @@
 
 float       tNoise_tick          (tNoise*  const);
 
-//==============================================================================
+//==============================================================================
     
-#ifdef __cplusplus
-}
-#endif
+#ifdef __cplusplus
+}
+#endif
         
-#endif  // LEAF_OSCILLATOR_H_INCLUDED
-
+#endif  // LEAF_OSCILLATOR_H_INCLUDED
+
 //==============================================================================
--- a/LEAF/Inc/leaf-oversampler.h
+++ b/LEAF/Inc/leaf-oversampler.h
@@ -16,7 +16,8 @@
     
 //==============================================================================
     
-#include "leaf-globals.h"
+#include "leaf-global.h"
+#include "leaf-mempool.h"
 #include "leaf-math.h"
 #include "leaf-filter.h"
     
--- a/LEAF/Inc/leaf-pitch.h
+++ b/LEAF/Inc/leaf-pitch.h
@@ -17,12 +17,12 @@
 
 //==============================================================================
 
-#include "leaf-globals.h"
+#include "leaf-global.h"
 #include "leaf-math.h"
 
 #include "leaf-filter.h"
 #include "leaf-utilities.h"
-#include "../leaf.h"
+
 //==============================================================================
     
 #define DEFPITCHRATIO 2.0f
--- a/LEAF/Inc/leaf-reverb.h
+++ b/LEAF/Inc/leaf-reverb.h
@@ -15,7 +15,7 @@
 
 //==============================================================================
     
-#include "leaf-globals.h"
+#include "leaf-global.h"
 #include "leaf-math.h"
 
 #include "leaf-delay.h"
--- a/LEAF/Inc/leaf-sample.h
+++ b/LEAF/Inc/leaf-sample.h
@@ -16,7 +16,7 @@
     
 //==============================================================================
  
-#include "leaf-globals.h"
+#include "leaf-global.h"
 #include "leaf-math.h"
     
 #include "leaf-utilities.h"
--- a/LEAF/Inc/leaf-string.h
+++ b/LEAF/Inc/leaf-string.h
@@ -17,7 +17,7 @@
     
 //==============================================================================
 
-#include "leaf-globals.h"
+#include "leaf-global.h"
 #include "leaf-math.h"
 
 #include "leaf-delay.h"
--- a/LEAF/Inc/leaf-tables.h
+++ b/LEAF/Inc/leaf-tables.h
@@ -15,7 +15,6 @@
     
 //==============================================================================
 
-#include "leaf-globals.h"
 #include "leaf-math.h"
 
 //==============================================================================
--- a/LEAF/Inc/leaf-utilities.h
+++ b/LEAF/Inc/leaf-utilities.h
@@ -17,7 +17,6 @@
 
 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
 
-#include "leaf-globals.h"
 #include "leaf-math.h"
 #include "leaf-filter.h"
 #include "leaf-delay.h"
@@ -369,6 +368,8 @@
 // ENV~ from PD, modified for LEAF
 #define MAXOVERLAP 32
 #define INITVSTAKEN 64
+#define ENV_WINDOW_SIZE 1024
+#define ENV_HOP_SIZE 256
 
 typedef struct _tEnv
 {
--- a/LEAF/Inc/leaf-vocoder.h
+++ b/LEAF/Inc/leaf-vocoder.h
@@ -15,7 +15,7 @@
 
 //==============================================================================
 
-#include "leaf-globals.h"
+#include "leaf-global.h"
 #include "leaf-math.h"
 
 //==============================================================================
--- a/LEAF/Inc/leaf-wavefolder.h
+++ b/LEAF/Inc/leaf-wavefolder.h
@@ -16,7 +16,7 @@
 
 //==============================================================================
 
-#include "leaf-globals.h"
+#include "leaf-global.h"
 #include "leaf-math.h"
 
 //==============================================================================
--- a/LEAF/Src/leaf-808.c
+++ b/LEAF/Src/leaf-808.c
@@ -16,16 +16,54 @@
 
 #endif
 
-#define USE_STICK 0
+// ----------------- COWBELL ----------------------------//
+
+void t808Cowbell_init(t808Cowbell* const cowbell, int useStick) {
+    
+    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->useStick = useStick;
+}
+
+void t808Cowebell_free(t808Cowbell* const cowbell)
+{
+    tSquare_free(&cowbell->p[0]);
+    tSquare_free(&cowbell->p[1]);
+    tSVF_free(&cowbell->bandpassOsc);
+    tSVF_free(&cowbell->bandpassStick);
+    tEnvelope_free(&cowbell->envGain);
+    tEnvelope_free(&cowbell->envFilter);
+    tHighpass_free(&cowbell->highpass);
+    tNoise_free(&cowbell->stick);
+    tEnvelope_free(&cowbell->envStick);
+}
+
 void t808Cowbell_on(t808Cowbell* const cowbell, float vel)
 {
-    
     tEnvelope_on(&cowbell->envGain, vel);
     
-#if USE_STICK
-    tEnvelope_on(&cowbell->envStick,vel);
-#endif
-    
+    if (cowbell->useStick)
+        tEnvelope_on(&cowbell->envStick,vel);
 }
 
 float t808Cowbell_tick(t808Cowbell* const cowbell) {
@@ -41,9 +79,9 @@
     
     sample *= (0.9f * tEnvelope_tick(&cowbell->envGain));
     
-#if USE_STICK
-    sample += (0.1f * tEnvelope_tick(&cowbell->envStick) * tSVF_tick(&cowbell->bandpassStick, tNoise_tick(&cowbell->stick)));
-#endif
+    if (cowbell->useStick)
+        sample += (0.1f * tEnvelope_tick(&cowbell->envStick) * tSVF_tick(&cowbell->bandpassStick, tNoise_tick(&cowbell->stick)));
+
     
     sample = tHighpass_tick(&cowbell->highpass, sample);
     
@@ -77,30 +115,61 @@
     cowbell->oscMix = oscMix;
 }
 
-void t808Cowbell_init(t808Cowbell* const cowbell) {
+void t808Cowbell_setStick(t808Cowbell* const cowbell, int useStick)
+{
+    cowbell->useStick = useStick;
+}
+
+// ----------------- HIHAT ----------------------------//
+
+void t808Hihat_init(t808Hihat* const hihat)
+{
+    for (int i = 0; i < 6; i++)
+    {
+        tSquare_init(&hihat->p[i]);
+    }
     
-    tSquare_init(&cowbell->p[0]);
-    tSquare_setFreq(&cowbell->p[0], 540.0f);
+    tNoise_init(&hihat->stick, PinkNoise);
+    tNoise_init(&hihat->n, WhiteNoise);
     
-    tSquare_init(&cowbell->p[1]);
-    tSquare_setFreq(&cowbell->p[1], 1.48148f * 540.0f);
+    // need to fix SVF to be generic
+    tSVF_init(&hihat->bandpassStick, SVFTypeBandpass,2500.0f,1.2f);
+    tSVF_init(&hihat->bandpassOsc, SVFTypeBandpass,3500.0f,0.3f);
     
-    cowbell->oscMix = 0.5f;
+    tEnvelope_init(&hihat->envGain, 0.0f, 50.0f, OFALSE);
+    tEnvelope_init(&hihat->envStick, 0.0f, 7.0f, OFALSE);
     
-    tSVF_init(&cowbell->bandpassOsc, SVFTypeBandpass, 2500, 1.0f);
     
-    tSVF_init(&cowbell->bandpassStick, SVFTypeBandpass, 1800, 1.0f);
+    tHighpass_init(&hihat->highpass, 7000.0f);
     
-    tEnvelope_init(&cowbell->envGain, 5.0f, 100.0f, OFALSE);
+    hihat->freq = 40.0f;
+    hihat->stretch = 0.0f;
     
-    tEnvelope_init(&cowbell->envFilter, 5.0, 100.0f, OFALSE);
+    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 hihat)
+{
+    for (int i = 0; i < 6; i++)
+    {
+        tSquare_free(&hihat->p[i]);
+    }
     
-    tHighpass_init(&cowbell->highpass, 1000.0f);
+    tNoise_free(&hihat->stick);
+    tNoise_free(&hihat->n);
     
-#if USE_STICK
-    tNoise_init(&cowbell->stick, NoiseTypeWhite);
-    tEnvelope_init(&cowbell->envStick, 5.0f, 5.0f, 0);
-#endif
+    // need to fix SVF to be generic
+    tSVF_free(&hihat->bandpassStick);
+    tSVF_free(&hihat->bandpassOsc);
+    tEnvelope_free(&hihat->envGain);
+    tEnvelope_free(&hihat->envStick);
+    
+    tHighpass_free(&hihat->highpass);
 }
 
 void t808Hihat_on(t808Hihat* const hihat, float vel) {
@@ -198,35 +267,50 @@
 		hihat->freq = freq;
 }
 
-void t808Hihat_init(t808Hihat* const hihat)
+// ----------------- SNARE ----------------------------//
+
+void t808Snare_init(t808Snare* const snare)
 {
-    for (int i = 0; i < 6; i++)
+    float ratio[2] = {1.0, 1.5};
+    for (int i = 0; i < 2; i++)
     {
-        tSquare_init(&hihat->p[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;
     }
     
-    tNoise_init(&hihat->stick, PinkNoise);
-    tNoise_init(&hihat->n, WhiteNoise);
-    
-    // need to fix SVF to be generic
-    tSVF_init(&hihat->bandpassStick, SVFTypeBandpass,2500.0f,1.2f);
-    tSVF_init(&hihat->bandpassOsc, SVFTypeBandpass,3500.0f,0.3f);
-    
-    tEnvelope_init(&hihat->envGain, 0.0f, 50.0f, OFALSE);
-    tEnvelope_init(&hihat->envStick, 0.0f, 7.0f, OFALSE);
-    
+    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->noiseGain = 1.0f;
+}
 
-    tHighpass_init(&hihat->highpass, 7000.0f);
+void        t808Snare_free                  (t808Snare* const snare)
+{
+    for (int i = 0; i < 2; i++)
+    {
+        tTriangle_free(&snare->tone[i]);
+        tSVF_free(&snare->toneLowpass[i]);
+        tEnvelope_free(&snare->toneEnvOsc[i]);
+        tEnvelope_free(&snare->toneEnvGain[i]);
+        tEnvelope_free(&snare->toneEnvFilter[i]);
+    }
     
-    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);
+    
+    tNoise_free(&snare->noiseOsc);
+    tSVF_free(&snare->noiseLowpass);
+    tEnvelope_free(&snare->noiseEnvGain);
+    tEnvelope_free(&snare->noiseEnvFilter);
 }
 
 void t808Snare_on(t808Snare* const snare, float vel)
@@ -285,7 +369,6 @@
     tSVF_setQ(&snare->noiseLowpass, noiseFilterQ);
 }
 
-
 static float tone[2];
 
 float t808Snare_tick(t808Snare* const snare)
@@ -308,51 +391,8 @@
     return sample;
 }
 
-void t808Snare_init(t808Snare* const snare)
-{
-    float ratio[2] = {1.0, 1.5};
-    for (int i = 0; i < 2; i++)
-    {
-        tTriangle_init(&snare->tone[i]);
+// ----------------- KICK ----------------------------//
 
-        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->noiseGain = 1.0f;
-}
-
-void        t808Snare_free                  (t808Snare* const snare)
-{
-    for (int i = 0; i < 2; i++)
-    {
-        tTriangle_free(&snare->tone[i]);
-        tSVF_free(&snare->toneLowpass[i]);
-        tEnvelope_free(&snare->toneEnvOsc[i]);
-        tEnvelope_free(&snare->toneEnvGain[i]);
-        tEnvelope_free(&snare->toneEnvFilter[i]);
-    }
-    
-    
-    tNoise_free(&snare->noiseOsc);
-    tSVF_free(&snare->noiseLowpass);
-    tEnvelope_free(&snare->noiseEnvGain);
-    tEnvelope_free(&snare->noiseEnvFilter);
-}
-
-
 void        t808Kick_init        			(t808Kick* const kick)
 {
 	tCycle_init(&kick->tone);
@@ -369,7 +409,6 @@
 	kick->noiseGain = 0.3f;
 }
 
-
 void        t808Kick_free                  (t808Kick* const kick)
 {
 	tCycle_free(&kick->tone);
@@ -410,6 +449,7 @@
 	tEnvelope_setDecay(&kick->toneEnvGain,decay);
 	tEnvelope_setDecay(&kick->toneEnvGain,decay * 3.0f);
 }
+
 void        t808Kick_setNoiseDecay         (t808Kick* const kick, float decay);
 void        t808Kick_setSighAmount         (t808Kick* const kick, float sigh);
 void        t808Kick_setChirpAmount         (t808Kick* const kick, float chirp);
--- a/LEAF/Src/leaf-WDF.c
+++ b/LEAF/Src/leaf-WDF.c
@@ -154,7 +154,7 @@
 
 void tWDF_free(tWDF* const r)
 {
-    leaf_free(r);
+
 }
 
 float tWDF_tick(tWDF* const r, float sample, tWDF* const outputPoint, uint8_t paramsChanged)
--- a/LEAF/Src/leaf-crusher.c
+++ b/LEAF/Src/leaf-crusher.c
@@ -32,7 +32,7 @@
 
 void    tCrusher_free    (tCrusher* const c)
 {
-    leaf_free(c);
+
 }
 
 float   tCrusher_tick    (tCrusher* const c, float input)
--- a/LEAF/Src/leaf-delay.c
+++ b/LEAF/Src/leaf-delay.c
@@ -41,7 +41,6 @@
 void tDelay_free(tDelay* const d)
 {
     leaf_free(d->buff);
-    leaf_free(d);
 }
 
 float   tDelay_tick (tDelay* const d, float input)
@@ -153,7 +152,6 @@
 void tDelayL_free(tDelayL* const d)
 {
     leaf_free(d->buff);
-    leaf_free(d);
 }
 
 float   tDelayL_tick (tDelayL* const d, float input)
@@ -319,7 +317,6 @@
 void tDelayA_free(tDelayA* const d)
 {
     leaf_free(d->buff);
-    leaf_free(d);
 }
 
 float   tDelayA_tick (tDelayA* const d, float input)
@@ -455,7 +452,6 @@
 void tTapeDelay_free(tTapeDelay* const d)
 {
     leaf_free(d->buff);
-    leaf_free(d);
 }
 
 //#define SMOOTH_FACTOR 10.f
--- a/LEAF/Src/leaf-filter.c
+++ b/LEAF/Src/leaf-filter.c
@@ -30,15 +30,14 @@
     tDelayL_init(&f->delay, initDelay, maxDelay);
 }
 
-void    tAllpass_setDelay(tAllpass* const f, float delay)
+void tAllpass_free(tAllpass* const f)
 {
-    tDelayL_setDelay(&f->delay, delay);
+    tDelayL_free(&f->delay);
 }
 
-void    tAllpass_free(tAllpass* const f)
+void    tAllpass_setDelay(tAllpass* const f, float delay)
 {
-    leaf_free(&f->delay);
-    leaf_free(f);
+    tDelayL_setDelay(&f->delay, delay);
 }
 
 void    tAllpass_setGain(tAllpass* const f, float gain)
@@ -81,8 +80,6 @@
         tSVF_free(&f->low[i]);
         tSVF_free(&f->high[i]);
     }
-    
-    leaf_free(f);
 }
 
 float tButterworth_tick(tButterworth* const f, float samp)
@@ -129,7 +126,7 @@
 
 void    tOneZero_free(tOneZero* const f)
 {
-    leaf_free(f);
+    
 }
 
 float   tOneZero_tick(tOneZero* const f, float input)
@@ -210,7 +207,7 @@
 
 void    tTwoZero_free(tTwoZero* const f)
 {
-    leaf_free(f);
+    
 }
 
 float   tTwoZero_tick(tTwoZero* const f, float input)
@@ -287,7 +284,7 @@
 
 void    tOnePole_free(tOnePole* const f)
 {
-    leaf_free(f);
+    
 }
 
 void    tOnePole_setB0(tOnePole* const f, float b0)
@@ -359,7 +356,7 @@
 
 void    tTwoPole_free(tTwoPole* const f)
 {
-    leaf_free(f);
+    
 }
 
 float   tTwoPole_tick(tTwoPole* const f, float input)
@@ -450,7 +447,7 @@
 
 void   tPoleZero_free(tPoleZero* const f)
 {
-    leaf_free(f);
+    
 }
 
 void    tPoleZero_setB0(tPoleZero* const pzf, float b0)
@@ -543,7 +540,7 @@
 
 void    tBiQuad_free(tBiQuad* const f)
 {
-    leaf_free(f);
+    
 }
 
 float   tBiQuad_tick(tBiQuad* const f, float input)
@@ -655,6 +652,20 @@
 }
 
 /* Highpass */
+void    tHighpass_init(tHighpass* const f, float freq)
+{
+    f->R = (1.0f-((freq * 2.0f * 3.14f)* leaf.invSampleRate));
+    f->ys = 0.0f;
+    f->xs = 0.0f;
+    
+    f->frequency = freq;
+}
+
+void    tHighpass_free(tHighpass* const f)
+{
+    
+}
+
 void     tHighpass_setFreq(tHighpass* const f, float freq)
 {
     f->frequency = freq;
@@ -675,20 +686,6 @@
     return f->ys;
 }
 
-void    tHighpass_init(tHighpass* const f, float freq)
-{
-    f->R = (1.0f-((freq * 2.0f * 3.14f)* leaf.invSampleRate));
-    f->ys = 0.0f;
-    f->xs = 0.0f;
-    
-    f->frequency = freq;
-}
-
-void    tHighpass_free(tHighpass* const f)
-{
-    leaf_free(f);
-}
-
 void tHighpassSampleRateChanged(tHighpass* const f)
 {
     f->R = (1.0f-((f->frequency * 2.0f * 3.14f) * leaf.invSampleRate));
@@ -737,7 +734,7 @@
 
 void tSVF_free(tSVF* const svf)
 {
-    leaf_free(svf);
+    
 }
 
 int     tSVF_setFreq(tSVF* const svf, float freq)
@@ -782,6 +779,11 @@
     svf->a3 = a3;
 }
 
+void tSVFE_free(tSVFE* const svf)
+{
+    
+}
+
 float   tSVFE_tick(tSVFE* const svf, float v0)
 {
     float v1,v2,v3;
@@ -838,5 +840,4 @@
 void	tFIR_free(tFIR* const fir)
 {
     leaf_free(fir->past);
-    leaf_free(fir);
 }
--- a/LEAF/Src/leaf-formant.c
+++ b/LEAF/Src/leaf-formant.c
@@ -61,8 +61,6 @@
         leaf_free(fs->fbuff[i]);
     }
     leaf_free(fs->fbuff);
-    
-    leaf_free(fs);
 }
 
 
--- a/LEAF/Src/leaf-mempool.c
+++ b/LEAF/Src/leaf-mempool.c
@@ -48,6 +48,7 @@
 
 #endif
 
+// This might be too low.
 #define NUM_BLOCKS 50
 
 mpool_pool_t blocks[NUM_BLOCKS];
--- a/LEAF/Src/leaf-midi.c
+++ b/LEAF/Src/leaf-midi.c
@@ -37,7 +37,7 @@
     
     poly->glideTime = 5.0f;
     
-    poly->ramp = (tRamp*) leaf_alloc(sizeof(tRamp) * poly->maxNumVoices);
+    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);
@@ -48,7 +48,7 @@
         poly->voices[i][0] = -1;
         poly->firstReceived[i] = OFALSE;
         
-        tRamp_init(&poly->ramp[i], poly->glideTime, 1);
+        tRamp_init(&poly->ramps[i], poly->glideTime, 1);
     }
     
     poly->pitchBend = 0.0f;
@@ -64,7 +64,7 @@
 {
     for (int i = 0; i < poly->maxNumVoices; i++)
     {
-        tRamp_free(&poly->ramp[i]);
+        tRamp_free(&poly->ramps[i]);
         leaf_free(poly->voices[i]);
     }
     tRamp_free(&poly->pitchBendRamp);
@@ -72,11 +72,9 @@
     tStack_free(&poly->orderStack);
     
     leaf_free(poly->voices);
-    leaf_free(poly->ramp);
+    leaf_free(poly->ramps);
     leaf_free(poly->rampVals);
     leaf_free(poly->firstReceived);
-
-    
 }
 
 void tPoly_tickPitch(tPoly* poly)
@@ -89,7 +87,7 @@
 {
     for (int i = 0; i < poly->maxNumVoices; ++i)
     {
-        tRamp_tick(&poly->ramp[i]);
+        tRamp_tick(&poly->ramps[i]);
     }
 }
 
@@ -122,7 +120,7 @@
             {
                 if (!poly->firstReceived[i] || !poly->pitchGlideIsActive)
                 {
-                    tRamp_setVal(&poly->ramp[i], note);
+                    tRamp_setVal(&poly->ramps[i], note);
                     poly->firstReceived[i] = OTRUE;
                 }
                 
@@ -134,7 +132,7 @@
                 poly->notes[note][0] = vel;
                 poly->notes[note][1] = i;
                 
-                tRamp_setDest(&poly->ramp[i], poly->voices[i][0]);
+                tRamp_setDest(&poly->ramps[i], poly->voices[i][0]);
                 
                 alteredVoice = i;
                 break;
@@ -158,8 +156,8 @@
                     poly->notes[note][0] = vel;
                     poly->notes[note][1] = whichVoice;
                     
-                    tRamp_setTime(&poly->ramp[whichVoice], poly->glideTime);
-                    tRamp_setDest(&poly->ramp[whichVoice], poly->voices[whichVoice][0]);
+                    tRamp_setTime(&poly->ramps[whichVoice], poly->glideTime);
+                    tRamp_setDest(&poly->ramps[whichVoice], poly->voices[whichVoice][0]);
                     
                     alteredVoice = whichVoice;
                     
@@ -214,7 +212,7 @@
             if (poly->notes[noteToTest][1] < 0) //if there is a stolen note waiting (marked inactive but on the stack)
             {
                 poly->voices[deactivatedVoice][0] = noteToTest; //set the newly free voice to use the old stolen note
-                tRamp_setDest(&poly->ramp[deactivatedVoice], poly->voices[deactivatedVoice][0]);
+                tRamp_setDest(&poly->ramps[deactivatedVoice], poly->voices[deactivatedVoice][0]);
                 poly->voices[deactivatedVoice][1] = poly->notes[noteToTest][0]; // set the velocity of the voice to be the velocity of that note
                 poly->notes[noteToTest][1] = deactivatedVoice; //mark that it is no longer stolen and is now active
                 return -1;
@@ -278,7 +276,7 @@
     poly->glideTime = t;
     for (int i = 0; i < poly->maxNumVoices; ++i)
     {
-        tRamp_setTime(&poly->ramp[i], poly->glideTime);
+        tRamp_setTime(&poly->ramps[i], poly->glideTime);
     }
 }
 
@@ -289,7 +287,7 @@
 
 float tPoly_getPitch(tPoly* const poly, uint8_t voice)
 {
-    return tRamp_sample(&poly->ramp[voice]) + tRamp_sample(&poly->pitchBendRamp);
+    return tRamp_sample(&poly->ramps[voice]) + tRamp_sample(&poly->pitchBendRamp);
 }
 
 int tPoly_getKey(tPoly* const poly, uint8_t voice)
--- a/LEAF/Src/leaf-oscillator.c
+++ b/LEAF/Src/leaf-oscillator.c
@@ -57,8 +57,6 @@
 void    tNeuron_free(tNeuron* const n)
 {
     tPoleZero_free(&n->f);
-    
-    leaf_free(n);
 }
 
 void   tNeuron_reset(tNeuron* const n)
@@ -226,7 +224,7 @@
 
 void    tCycle_free(tCycle* const c)
 {
-    leaf_free(c);
+
 }
 
 int     tCycle_setFreq(tCycle* const c, float freq)
@@ -266,6 +264,17 @@
     p->inc = p->freq * leaf.invSampleRate;
 };
 
+void    tPhasor_init(tPhasor* const p)
+{
+    p->phase = 0.0f;
+    p->inc = 0.0f;
+}
+
+void    tPhasor_free(tPhasor* const p)
+{
+    
+}
+
 int     tPhasor_setFreq(tPhasor* const p, float freq)
 {
     if (freq < 0.0f) freq = 0.0f;
@@ -285,16 +294,7 @@
     return p->phase;
 }
 
-void    tPhasor_init(tPhasor* const p)
-{
-    p->phase = 0.0f;
-    p->inc = 0.0f;
-}
 
-void    tPhasor_free(tPhasor* const p)
-{
-    leaf_free(p);
-}
 
 void    tSawtooth_init(tSawtooth* const c)
 {
@@ -304,7 +304,7 @@
 
 void    tSawtooth_free(tSawtooth* const c)
 {
-    leaf_free(c);
+
 }
 
 int     tSawtooth_setFreq(tSawtooth* const c, float freq)
@@ -411,7 +411,8 @@
 
 void   tTriangle_free(tTriangle* const c)
 {
-    leaf_free(c);}
+    
+}
 
 int tTriangle_setFreq(tTriangle* const c, float freq)
 {
@@ -513,7 +514,7 @@
 
 void   tSquare_free(tSquare* const c)
 {
-    leaf_free(c);
+   
 }
 
 int     tSquare_setFreq(tSquare*  const c, float freq)
@@ -614,7 +615,7 @@
 
 void    tNoise_free(tNoise* const n)
 {
-    leaf_free(n);
+    
 }
 
 float   tNoise_tick(tNoise* const n)
--- a/LEAF/Src/leaf-oversampler.c
+++ b/LEAF/Src/leaf-oversampler.c
@@ -41,7 +41,6 @@
 {
     leaf_free(os->upState);
     leaf_free(os->downState);
-    leaf_free(os);
 }
 
 float tOversampler_tick(tOversampler* const os, float input, float (*effectTick)(float))
--- a/LEAF/Src/leaf-pitch.c
+++ b/LEAF/Src/leaf-pitch.c
@@ -51,8 +51,6 @@
     tSNAC_free(&ps->snac);
     tSOLAD_free(&ps->sola);
     tHighpass_free(&ps->hp);
-    
-    leaf_free(ps);
 }
 
 float tPitchShifter_tick(tPitchShifter* ps, float sample)
@@ -94,7 +92,6 @@
         tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor);
         tSOLAD_ioSamples(&ps->sola, &(ps->inBuffer[i]), &(ps->outBuffer[i]), ps->frameSize);
         
-        
     }
     
     return out;
@@ -368,8 +365,6 @@
 {
     tEnv_free(&p->env);
     tSNAC_free(&p->snac);
-    
-    leaf_free(p);
 }
 
 float tPeriod_findPeriod (tPeriod* p, float sample)
@@ -470,8 +465,6 @@
 {
     tSOLAD_free(&ps->sola);
     tHighpass_free(&ps->hp);
-    
-    leaf_free(ps);
 }
 
 float tPitchShift_shift (tPitchShift* ps)
--- a/LEAF/Src/leaf-reverb.c
+++ b/LEAF/Src/leaf-reverb.c
@@ -58,7 +58,6 @@
     tDelay_free(&r->allpassDelays[0]);
     tDelay_free(&r->allpassDelays[1]);
     tDelay_free(&r->combDelay);
-    leaf_free(r);
 }
 
 void    tPRCRev_setT60(tPRCRev* const r, float t60)
@@ -167,8 +166,6 @@
     {
         tDelay_free(&r->allpassDelays[i]);
     }
-    
-    leaf_free(r);
 }
 
 void    tNRev_setT60(tNRev* const r, float t60)
@@ -334,6 +331,8 @@
     
     tOnePole_free(&r->f1_filter);
     
+    tHighpass_free(&r->f2_hp);
+    
     tCycle_free(&r->f1_lfo);
     
     // FEEDBACK 2
@@ -345,9 +344,9 @@
     
     tOnePole_free(&r->f2_filter);
     
-    tCycle_free(&r->f2_lfo);
+    tHighpass_free(&r->f2_hp);
     
-    leaf_free(r);
+    tCycle_free(&r->f2_lfo);
 }
 
 float   tDattorro_tick              (tDattorro* const r, float input)
--- a/LEAF/Src/leaf-sample.c
+++ b/LEAF/Src/leaf-sample.c
@@ -39,7 +39,6 @@
 void  tBuffer_free (tBuffer* const s)
 {
     leaf_free(s->buff);
-    leaf_free(s);
 }
 
 void tBuffer_tick (tBuffer* const s, float sample)
@@ -136,7 +135,6 @@
 void tSampler_free         (tSampler* const p)
 {
     tRamp_free(&p->gain);
-    leaf_free(p);
 }
 
 float tSampler_tick        (tSampler* const p)
--- a/LEAF/Src/leaf-string.c
+++ b/LEAF/Src/leaf-string.c
@@ -38,8 +38,6 @@
     tOnePole_free(&p->pickFilter);
     tOneZero_free(&p->loopFilter);
     tDelayA_free(&p->delayLine);
-
-    leaf_free(p);
 }
 
 float   tPluck_getLastOut    (tPluck *p)
@@ -149,8 +147,6 @@
     {
         tBiQuad_free(&p->biquad[i]);
     }
-    
-    leaf_free(p);
 }
 
 float   tStifKarp_getLastOut    (tStifKarp* const p)
--- a/LEAF/Src/leaf-tables.c
+++ b/LEAF/Src/leaf-tables.c
@@ -3,11 +3,11 @@
 #if _WIN32 || _WIN64
 
 #include "..\Inc\leaf-tables.h"
-#include "..\Inc\leaf-globals.h"
+#include "..\Inc\leaf-global.h"
 #else
 
 #include "../Inc/leaf-tables.h"
-#include "../Inc/leaf-globals.h"
+#include "../Inc/leaf-global.h"
 
 #endif
 
--- a/LEAF/Src/leaf-utilities.c
+++ b/LEAF/Src/leaf-utilities.c
@@ -126,7 +126,7 @@
 
 void tEnv_free (tEnv* const x)
 {
-    leaf_free(x);
+
 }
 
 float tEnv_tick (tEnv* const x)
@@ -204,6 +204,11 @@
     c->W = 1.0f; // decibel Make-up gain
 }
 
+void tCompressor_free(tCompressor* const c)
+{
+    
+}
+
 int ccount = 0;
 float tCompressor_tick(tCompressor* const c, float in)
 {
@@ -306,7 +311,7 @@
 
 void tEnvelope_free(tEnvelope* const env)
 {
-    leaf_free(env);
+    
 }
 
 int     tEnvelope_setAttack(tEnvelope* const env, float attack)
@@ -498,6 +503,11 @@
     adsr->rampInc = adsr->inc_buff[rampIndex];
 }
 
+void tADSR_free(tADSR* const adsr)
+{
+    
+}
+
 int     tADSR_setAttack(tADSR* const adsr, float attack)
 {
     int32_t attackIndex;
@@ -683,6 +693,11 @@
     e->d_coeff = decayCoeff;
 }
 
+void tEnvelopeFollower_free(tEnvelopeFollower* const e)
+{
+    
+}
+
 float   tEnvelopeFollower_tick(tEnvelopeFollower* const ef, float x)
 {
     if (x < 0.0f ) x = -x;  /* Absolute value. */
@@ -729,6 +744,11 @@
     ramp->inc = ((ramp->dest - ramp->curr) / ramp->time * ramp->inv_sr_ms) * (float)ramp->samples_per_tick;
 }
 
+void tRamp_free(tRamp* const ramp)
+{
+    
+}
+
 int     tRamp_setTime(tRamp* const r, float time)
 {
 	if (time < r->minimum_time)
@@ -791,6 +811,11 @@
 	smooth->oneminusfactor=1.0f-factor;
 }
 
+void tExpSmooth_free(tExpSmooth* const smooth)
+{
+    
+}
+
 int     tExpSmooth_setFactor(tExpSmooth* const smooth, 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
 	if (factor<0)
@@ -835,6 +860,11 @@
 	p->oneminusfactor=1.0f-factor;
 }
 
+void tPwrFollow_free(tPwrFollow* const p)
+{
+    
+}
+
 int     tPwrFollow_setFactor(tPwrFollow* const p, float factor)
 {
 	if (factor<0) factor=0;
@@ -866,6 +896,11 @@
 	p->strength=strength;
 }
 
+void tFBleveller_free(tFBleveller* const p)
+{
+    tPwrFollow_free(&p->pwrFlw);
+}
+
 int     tFBleveller_setStrength(tFBleveller* const p, float strength)
 {	// strength is how strongly level diff is affecting the amp ratio
 	// try 0.125 for a start
@@ -972,6 +1007,15 @@
 	p->levMode=levMode;
 }
 
+void tSimpleLivingString_free(tSimpleLivingString* const p)
+{
+    tExpSmooth_free(&p->wlSmooth);
+    tDelayL_free(&p->delayLine);
+    tOnePole_free(&p->bridgeFilter);
+    tHighpass_free(&p->DCblocker);
+    tFBleveller_free(&p->fbLev);
+}
+
 int     tSimpleLivingString_setFreq(tSimpleLivingString* const p, float freq)
 {
 	if (freq<20) freq=20;
@@ -1068,6 +1112,24 @@
 	p->levMode=levMode;
 }
 
+void tLivingString_free(tLivingString* const p)
+{
+    tExpSmooth_free(&p->wlSmooth);
+    tExpSmooth_free(&p->ppSmooth);
+    tDelayL_free(&p->delLF);
+    tDelayL_free(&p->delUF);
+    tDelayL_free(&p->delUB);
+    tDelayL_free(&p->delLB);
+    tOnePole_free(&p->bridgeFilter);
+    tOnePole_free(&p->nutFilter);
+    tOnePole_free(&p->prepFilterU);
+    tOnePole_free(&p->prepFilterL);
+    tHighpass_free(&p->DCblockerU);
+    tHighpass_free(&p->DCblockerL);
+    tFBleveller_free(&p->fbLevU);
+    tFBleveller_free(&p->fbLevL);
+}
+
 int     tLivingString_setFreq(tLivingString* const p, float freq)
 {	// NOTE: It is faster to set wavelength in samples directly
 	if (freq<20) freq=20;
@@ -1189,6 +1251,21 @@
 
 /* Stack */
 
+void tStack_init(tStack* const ns)
+{
+    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_free(tStack* const ns)
+{
+    
+}
+
 // If stack contains note, returns index. Else returns -1;
 int tStack_contains(tStack* const ns, uint16_t noteVal)
 {
@@ -1382,17 +1459,6 @@
 {
     return ns->data[0];
 }
-
-void tStack_init(tStack* const ns)
-{
-    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;
-}
-
 /******************************************************************************/
 /***************** static function declarations *******************************/
 /******************************************************************************/
@@ -1416,7 +1482,6 @@
 
 void tSOLAD_free(tSOLAD* const w)
 {
-    leaf_free(w);
 }
 
 // send one block of input samples, receive one block of output samples
@@ -1750,7 +1815,10 @@
 
 void tSNAC_free(tSNAC* const s)
 {
-    leaf_free(s);
+    leaf_free(s->inputbuf);
+    leaf_free(s->processbuf);
+    leaf_free(s->spectrumbuf);
+    leaf_free(s->biasbuf);
 }
 /******************************************************************************/
 /************************** public access functions****************************/
@@ -2058,7 +2126,7 @@
 
 void tAtkDtk_free(tAtkDtk *a)
 {
-    leaf_free(a);
+    
 }
 
 /*******Public Functions***********/
--- a/LEAF/Src/leaf-vocoder.c
+++ b/LEAF/Src/leaf-vocoder.c
@@ -51,8 +51,6 @@
     leaf_free(v->window);
     leaf_free(v->buf0);
     leaf_free(v->buf1);
-    
-    leaf_free(v);
 }
 
 void tTalkbox_update(tTalkbox* const v) ///update internal parameters...
@@ -227,7 +225,6 @@
 	v->O = (int32_t)((0.0001f + 0.0004f * v->param[3]) * leaf.sampleRate);
 }
 
-
 void   tVocoder_init        (tVocoder* const v)
 {
     v->param[0] = 0.33f;  //input select
@@ -240,6 +237,11 @@
     v->param[7] = 0.33f;  //num bands
     
     tVocoder_update(v);
+}
+
+void tVocoder_free (tVocoder* const v)
+{
+    
 }
 
 void        tVocoder_update      (tVocoder* const v)
--- a/LEAF/Src/leaf-wavefolder.c
+++ b/LEAF/Src/leaf-wavefolder.c
@@ -23,6 +23,11 @@
     w->xn1 = 0.0f;
 }
 
+void tLockhardWavefolder_free(tLockhartWavefolder* const w)
+{
+    
+}
+
 double tLockhartWavefolderLambert(double x, double ln)
 {
     double thresh, w, expw, p, r, s, err;
--- a/LEAF/leaf.h
+++ b/LEAF/leaf.h
@@ -19,8 +19,9 @@
 
 #if _WIN32 || _WIN64
 
-#include ".\Inc\leaf-globals.h"
+#include ".\Inc\leaf-global.h"
 #include ".\Inc\leaf-math.h"
+#include ".\Inc\leaf-mempool.h"
 #include ".\Inc\leaf-utilities.h"
 #include ".\Inc\leaf-delay.h"
 #include ".\Inc\leaf-filter.h"
@@ -40,8 +41,9 @@
 
 #else
 
-#include "./Inc/leaf-globals.h"
+#include "./Inc/leaf-global.h"
 #include "./Inc/leaf-math.h"
+#include "./Inc/leaf-mempool.h"
 #include "./Inc/leaf-utilities.h"
 #include "./Inc/leaf-delay.h"
 #include "./Inc/leaf-filter.h"
--- a/LEAF_JUCEPlugin/LEAF.jucer
+++ b/LEAF_JUCEPlugin/LEAF.jucer
@@ -23,7 +23,7 @@
           <FILE id="Hu4b98" name="trigtbl.h" compile="0" resource="0" file="../LEAF/Externals/trigtbl.h"/>
         </GROUP>
         <GROUP id="{0E2E673D-2AE5-AECB-4E28-A1EE29180BD2}" name="Inc">
-          <FILE id="xaaxl7" name="leaf-globals.h" compile="0" resource="0" file="../LEAF/Inc/leaf-globals.h"/>
+          <FILE id="IwBoc4" name="leaf-global.h" compile="0" resource="0" file="../LEAF/Inc/leaf-global.h"/>
           <FILE id="cmehFw" name="leaf-math.h" compile="0" resource="0" file="../LEAF/Inc/leaf-math.h"/>
           <FILE id="XQTGHV" name="leaf-mempool.h" compile="0" resource="0" file="../LEAF/Inc/leaf-mempool.h"/>
           <FILE id="k0yQ8k" name="leaf-808.h" compile="0" resource="0" file="../LEAF/Inc/leaf-808.h"/>