shithub: leaf

Download patch

ref: 53cc69afc79c8adb859f00cdb183612baa50a48e
parent: b76149637b10bffdd86e62b86730c4f51922fad6
parent: dba875129b0d0aabbc90d8affcf782e2b8a116a4
author: mulshine <mulshine@princeton.edu>
date: Mon Apr 8 07:14:07 EDT 2019

Merged with mike_dev etc.

--- a/LEAF/Inc/leaf-808.h
+++ b/LEAF/Inc/leaf-808.h
@@ -1,19 +1,20 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    leaf_808.h
+    leaf-808.h
     Created: 30 Nov 2018 10:24:44am
     Author:  airship
 
-  ==============================================================================
-*/
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+==============================================================================*/
 
+#ifndef LEAF_808_H_INCLUDED
+#define LEAF_808_H_INCLUDED
+
 #ifdef __cplusplus
 extern "C" {
-#endif
-
+#endif
+
+//==============================================================================
+    
 #include "leaf-globals.h"
 #include "leaf-math.h"
 
@@ -21,10 +22,8 @@
 #include "leaf-utilities.h"
 #include "leaf-filter.h"
 
-
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 // 808 Cowbell
 typedef struct _t808Cowbell {
     
@@ -51,9 +50,8 @@
 void    t808Cowbell_setFreq          (t808Cowbell* const, float freq);
 void    t808Cowbell_setOscMix        (t808Cowbell* const, float oscMix);
 
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 // 808 Hihat
 typedef struct _t808Hihat {
     
@@ -90,9 +88,9 @@
 void        t808Hihat_setOscFreq         (t808Hihat* const, float freq);
 void 		t808Hihat_setStretch				(t808Hihat* const hihat, float stretch);
 void 		t808Hihat_setFM					(t808Hihat* const hihat, float FM_amount);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+
+//==============================================================================
+    
 // 808 Snare
 typedef struct _t808Snare {
     
@@ -133,8 +131,8 @@
 void        t808Snare_setNoiseFilterFreq    (t808Snare* const, float noiseFilterFreq);
 void        t808Snare_setNoiseFilterQ       (t808Snare* const, float noiseFilterQ);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 // 808 Kick
 typedef struct _t808Kick {
 
@@ -173,9 +171,14 @@
 void        t808Kick_setNoiseFilterFreq    (t808Kick* const, float noiseFilterFreq);
 void        t808Kick_setNoiseFilterQ       (t808Kick* const, float noiseFilterQ);
     
+//==============================================================================
+    
 #ifdef __cplusplus
 }
-#endif
+#endif
+
+#endif // LEAF_808_H_INCLUDED
+
+//==============================================================================
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
 
--- a/LEAF/Inc/leaf-crusher.h
+++ b/LEAF/Inc/leaf-crusher.h
@@ -1,64 +1,64 @@
-/*
-  ==============================================================================
-
-    leaf-crusher.h
-    Created: 7 Feb 2019 10:58:22am
-    Author:  airship
-
-  ==============================================================================
-*/
-
-#ifndef LEAF_CRUSHER_H_INCLUDED
-#define LEAF_CRUSHER_H_INCLUDED
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//==============================================================================
-
-#include "leaf-globals.h"
-#include "leaf-math.h"
-
-//==============================================================================
-
-typedef struct _tCrusher
-{
-    float srr;
-    float mult, div;
-    float rnd;
-
-    uint32_t  op; //which bitwise operation (0-7)
-
-    float gain;
-
-} tCrusher;
-
-
-void    tCrusher_init    (tCrusher* const);
-void    tCrusher_free    (tCrusher* const);
-
-float   tCrusher_tick    (tCrusher* const, float input);
-
-// 0.0 - 1.0
-void    tCrusher_setOperation (tCrusher* const, float op);
-
-// 0.0 - 1.0
-void    tCrusher_setQuality (tCrusher* const, float val);
-
-// what division to round to
-void    tCrusher_setRound (tCrusher* const, float rnd);
-
-// sampling ratio
-void    tCrusher_setSamplingRatio (tCrusher* const, float ratio);
-
-//==============================================================================
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // LEAF_WAVEFOLDER_H_INCLUDED
-
+/*
+  ==============================================================================
+
+    leaf-crusher.h
+    Created: 7 Feb 2019 10:58:22am
+    Author:  airship
+
+  ==============================================================================
+*/
+
+#ifndef LEAF_CRUSHER_H_INCLUDED
+#define LEAF_CRUSHER_H_INCLUDED
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//==============================================================================
+
+#include "leaf-globals.h"
+#include "leaf-math.h"
+
+//==============================================================================
+    
+typedef struct _tCrusher
+{
+    float srr;
+    float mult, div;
+    float rnd;
+    
+    uint32_t  op; //which bitwise operation (0-7)
+    
+    float gain;
+    
+} tCrusher;
+    
+
+void    tCrusher_init    (tCrusher* const);
+void    tCrusher_free    (tCrusher* const);
+
+float   tCrusher_tick    (tCrusher* const, float input);
+    
+// 0.0 - 1.0
+void    tCrusher_setOperation (tCrusher* const, float op);
+ 
+// 0.0 - 1.0
+void    tCrusher_setQuality (tCrusher* const, float val);
+    
+// what division to round to
+void    tCrusher_setRound (tCrusher* const, float rnd);
+    
+// sampling ratio
+void    tCrusher_setSamplingRatio (tCrusher* const, float ratio);
+    
+//==============================================================================
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // LEAF_WAVEFOLDER_H_INCLUDED
+
 //==============================================================================
--- a/LEAF/Inc/leaf-delay.h
+++ b/LEAF/Inc/leaf-delay.h
@@ -1,27 +1,25 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    LEAFDelay.h
+    leaf-delay.h
     Created: 20 Jan 2017 12:01:24pm
     Author:  Michael R Mulshine
 
-  ==============================================================================
-*/
+==============================================================================*/
 
-#ifndef LEAFDELAY_H_INCLUDED
-#define LEAFDELAY_H_INCLUDED
+#ifndef LEAF_DELAY_H_INCLUDED
+#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
 {
@@ -48,9 +46,8 @@
 float       tDelay_getLastOut   (tDelay*  const);
 float       tDelay_getLastIn    (tDelay*  const);
 
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* Linearly-interpolating delay, reimplemented from STK (Cook and Scavone). */
 typedef struct _tDelayL
 {
@@ -81,8 +78,8 @@
 float       tDelayL_getLastOut  (tDelayL*  const);
 float       tDelayL_getLastIn   (tDelayL*  const);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* Allpass-interpolating delay, reimplemented from STK (Cook and Scavone). */
 typedef struct _tDelayA
 {
@@ -115,8 +112,8 @@
 float       tDelayA_getLastOut  (tDelayA*  const);
 float       tDelayA_getLastIn   (tDelayA*  const);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* Linear interpolating delay with fixed read and write pointers, variable rate. */
 typedef struct _tTapeDelay
 {
@@ -147,8 +144,12 @@
 float       tTapeDelay_getLastOut  (tTapeDelay*  const);
 float       tTapeDelay_getLastIn   (tTapeDelay*  const);
     
+//==============================================================================
+    
 #ifdef __cplusplus
 }
 #endif
 
-#endif  // LEAFDELAY_H_INCLUDED
+#endif  // LEAF_DELAY_H_INCLUDED
+
+//==============================================================================
--- a/LEAF/Inc/leaf-filter.h
+++ b/LEAF/Inc/leaf-filter.h
@@ -1,22 +1,20 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    LEAFFilter.h
+    leaf-filter.h
     Created: 20 Jan 2017 12:01:10pm
     Author:  Michael R Mulshine
 
-  ==============================================================================
-*/
+==============================================================================*/
 
-#ifndef LEAFFILTER_H_INCLUDED
-#define LEAFFILTER_H_INCLUDED
+#ifndef LEAF_FILTER_H_INCLUDED
+#define LEAF_FILTER_H_INCLUDED
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 #include "leaf-globals.h"
 #include "leaf-math.h"
 
@@ -24,8 +22,8 @@
 
 #include "leaf-wavetables.h"
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* tAllpass: Schroeder allpass. Comb-filter with feedforward and feedback. */
 typedef struct _tAllpass
 {
@@ -45,8 +43,8 @@
 void        tAllpass_setDelay       (tAllpass* const f, float delay);
 
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* tOnePole: OnePole filter, reimplemented from STK (Cook and Scavone). */
 typedef struct _tOnePole
 {
@@ -73,9 +71,8 @@
 void        tOnePole_setCoefficients(tOnePole* const, float b0, float a1);
 void        tOnePole_setGain        (tOnePole* const, float gain);
 
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* TwoPole filter, reimplemented from STK (Cook and Scavone). */
 typedef struct _tTwoPole
 {
@@ -100,10 +97,9 @@
 void        tTwoPole_setResonance   (tTwoPole*  const, float freq, float radius, oBool normalize);
 void        tTwoPole_setCoefficients(tTwoPole*  const, float b0, float a1, float a2);
 void        tTwoPole_setGain        (tTwoPole*  const, float gain);
-
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* OneZero filter, reimplemented from STK (Cook and Scavone). */
 typedef struct _tOneZero
 {
@@ -123,9 +119,8 @@
 void        tOneZero_setGain        (tOneZero*  const, float gain);
 float       tOneZero_getPhaseDelay(tOneZero *f, float frequency );
 
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* TwoZero filter, reimplemented from STK (Cook and Scavone). */
 typedef struct _tTwoZero
 {
@@ -149,9 +144,8 @@
 void        tTwoZero_setCoefficients(tTwoZero*  const, float b0, float b1, float b2);
 void        tTwoZero_setGain        (tTwoZero*  const, float gain);
 
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* PoleZero filter, reimplemented from STK (Cook and Scavone). */
 typedef struct _tPoleZero
 {
@@ -175,9 +169,8 @@
 void        tPoleZero_setBlockZero      (tPoleZero*  const, float thePole);
 void        tPoleZero_setGain           (tPoleZero*  const, float gain);
 
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* BiQuad filter, reimplemented from STK (Cook and Scavone). */
 typedef struct _tBiQuad
 {
@@ -206,9 +199,8 @@
 void        tBiQuad_setCoefficients(tBiQuad*  const, float b0, float b1, float b2, float a1, float a2);
 void        tBiQuad_setGain        (tBiQuad*  const, float gain);
 
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* State Variable Filter, algorithm from Andy Simper. */
 typedef enum SVFType
 {
@@ -235,9 +227,8 @@
 int         tSVF_setFreq    (tSVF*  const, float freq);
 int         tSVF_setQ       (tSVF*  const, float Q);
 
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* Efficient State Variable Filter for 14-bit control input, [0, 4096). */
 typedef struct _tSVFE
 {
@@ -255,9 +246,8 @@
 int         tSVFE_setFreq   (tSVFE*  const, uint16_t controlFreq);
 int         tSVFE_setQ      (tSVFE*  const, float Q);
 
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* Simple Highpass filter. */
 typedef struct _tHighpass
 {
@@ -273,9 +263,8 @@
 void        tHighpass_setFreq   (tHighpass*  const, float freq);
 float       tHighpass_getFreq   (tHighpass*  const);
 
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 // Butterworth Filter
 #define NUM_SVF_BW 16
 typedef struct _tButterworth
@@ -299,10 +288,12 @@
 void        tButterworth_setF2      (tButterworth* const, float in);
 void        tButterworth_setFreqs   (tButterworth* const, float f1, float f2);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
     
 #ifdef __cplusplus
 }
 #endif
 
-#endif  // LEAFFILTER_H_INCLUDED
+#endif  // LEAF_FILTER_H_INCLUDED
+
+//==============================================================================
--- a/LEAF/Inc/leaf-formant.h
+++ b/LEAF/Inc/leaf-formant.h
@@ -1,24 +1,25 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
     leaf-formant.h
     Created: 30 Nov 2018 11:03:37am
     Author:  airship
 
-  ==============================================================================
-*/
+==============================================================================*/
 
+#ifndef LEAF_FORMANT_H_INCLUDED
+#define LEAF_FORMANT_H_INCLUDED
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 #include "leaf-globals.h"
 #include "leaf-math.h"
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 #define FORD 7
 #define FORMANT_BUFFER_SIZE 2048
 
@@ -51,11 +52,15 @@
 float       tFormantShifter_tick            (tFormantShifter* const, float input, float fwarp);
 float       tFormantShifter_remove          (tFormantShifter* const, float input);
 float       tFormantShifter_add             (tFormantShifter* const, float input, float fwarp);
-void        tFormantShifter_ioSamples       (tFormantShifter* const, float* in, float* out, int size, float fwarp);
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+void        tFormantShifter_ioSamples       (tFormantShifter* const, float* in, float* out, int size, float fwarp);
+    
+//==============================================================================
     
 #ifdef __cplusplus
 }
-#endif
+#endif
+
+#endif // LEAF_FORMANT_H_INCLUDED
+
+//==============================================================================
 
--- a/LEAF/Inc/leaf-globals.h
+++ b/LEAF/Inc/leaf-globals.h
@@ -1,29 +1,23 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
     leaf-globals.h
     Created: 23 Jan 2017 10:34:10pm
     Author:  Michael R Mulshine
 
-  ==============================================================================
-*/
+==============================================================================*/
 
-#ifndef OPPSGLOBALS_H_INCLUDED
-#define OPPSGLOBALS_H_INCLUDED
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                                                                       *
- * If your application requires use of many instances of one component or is facing memory limitations,  *
- * use this set of defines to increase or limit the number of instances of each component. The library   *
- * will pre-allocate only the number of instances defined here.                                          *
- *                                                                                                       *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-#include "leaf-mempool.h"
+#ifndef LEAF_GLOBALS_H_INCLUDED
+#define LEAF_GLOBALS_H_INCLUDED
 
 #ifdef __cplusplus
 extern "C" {
 #endif
+    
+//==============================================================================
+
+#include "leaf-mempool.h"
+    
+//==============================================================================
     
 typedef struct _LEAF
 {
@@ -30,11 +24,22 @@
     float   sampleRate;
     float   invSampleRate;
     int     blockSize;
-    
+    
+    /*
+    float*  sinewave;
+    float*  sawtooth[11];
+    float*  square[11];
+    float*  triangle[11];
+     */
+
     float   (*random)(void);
-} LEAF;
+} LEAF;
+    
+//==============================================================================
 
-extern LEAF leaf;
+extern LEAF leaf; // The global instance of LEAF.
+    
+//==============================================================================
 
 #define SHAPER1_TABLE_SIZE 65536
 extern const float shaper1[SHAPER1_TABLE_SIZE];
@@ -52,13 +57,20 @@
 #define     DELAY_LENGTH        16000   // The maximum delay length of all Delay/DelayL/DelayA components.
                                             // Feel free to change to suit memory constraints or desired delay max length / functionality.
 
-//#define TALKBOX_BUFFER_LENGTH   1600    // Every talkbox instance introduces 5 buffers of this size
-
-
-union unholy_t { /* a union between a float and an integer */
-    float f;
-    int i;
-};
-
-
-#endif  // OPPSGLOBALS_H_INCLUDED
+#define TALKBOX_BUFFER_LENGTH   1600    // Every talkbox instance introduces 5 buffers of this size
+
+    
+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
@@ -15,14 +15,12 @@
 
 #include "math.h"
 #include "stdint.h"
-#include "stdlib.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "stdlib.h"
 
 //==============================================================================
 
+//==============================================================================
+
 typedef enum oBool
 {
     OTRUE  = 1,
@@ -81,6 +79,10 @@
 // Jones shaper
 float LEAF_shaper     (float input, float m_drive);
 float LEAF_reedTable  (float input, float offset, float slope);
+    
+float LEAF_reduct (float input, float ratio);
+float LEAF_round (float input, float rnd);
+float LEAF_bitwise_xor(float input, uint32_t op);
 
 float LEAF_reduct (float input, float ratio);
 float LEAF_round (float input, float rnd);
@@ -102,11 +104,6 @@
 // dope af
 float       LEAF_chebyshevT(float in, int n);
 float       LEAF_CompoundChebyshevT(float in, int n, float* amps);
-
-
-// Hermite interpolation
-float LEAF_interpolate_hermite (float A, float B, float C, float D, float t);
-float LEAF_interpolation_linear (float A, float B, float t);
 
 // Hermite interpolation
 float LEAF_interpolate_hermite (float A, float B, float C, float D, float t);
--- a/LEAF/Inc/leaf-mempool.h
+++ b/LEAF/Inc/leaf-mempool.h
@@ -1,4 +1,5 @@
-/**
+/*==============================================================================
+ 
    In short, mpool is distributed under so called "BSD license",
    
    Copyright (c) 2009-2010 Tatsuhiko Kubo <cubicdaiya@gmail.com>
@@ -28,25 +29,29 @@
    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ 
+   written by C99 style
+==============================================================================*/
 
-/* written by C99 style */
+#ifndef LEAF_MPOOL_H_INCLUDED
+#define LEAF_MPOOL_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+    
+//==============================================================================
 
-#ifndef MPOOL_H
-#define MPOOL_H
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdbool.h>
+#include <stdbool.h>
+    
+//==============================================================================
 
 #define MPOOL_POOL_SIZE   500000
 #define MPOOL_ALIGN_SIZE (8)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
 
 //#define size_t unsigned long
       
@@ -68,7 +73,6 @@
     int next;
 } mpool_t;
 
-
 void mpool_create (size_t size, mpool_t* pool);
 
 void *mpool_alloc(size_t size, mpool_t* pool);
@@ -86,12 +90,18 @@
 size_t leaf_pool_get_size(void);
 size_t leaf_pool_get_used(void);
 
-void* leaf_pool_get_pool(void);
+void* leaf_pool_get_pool(void);
 
+void leaf_mempool_overrun(void);
+    
+//==============================================================================
+
 #ifdef __cplusplus
 }
 #endif
 
-#endif
+#endif // LEAF_MPOOL_H
+
+//==============================================================================
 
 
--- a/LEAF/Inc/leaf-midi.h
+++ b/LEAF/Inc/leaf-midi.h
@@ -1,26 +1,27 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
     leaf-midi.h
     Created: 30 Nov 2018 11:29:26am
     Author:  airship
 
-  ==============================================================================
-*/
+==============================================================================*/
+
+#ifndef LEAF_MIDI_H_INCLUDED
+#define LEAF_MIDI_H_INCLUDED
 
 #ifdef __cplusplus
 extern "C" {
 #endif
     
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 #include "leaf-globals.h"
 #include "leaf-math.h"
 
 #include "leaf-utilities.h"
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 typedef struct _tMidiNote
 {
     uint8_t pitch;
@@ -38,8 +39,8 @@
     
 } tMidiNode;
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* Polyphonic Handler */
 typedef struct _tPoly
 {
@@ -56,8 +57,8 @@
 void        tPoly_noteOn(tPoly* poly, int midiNoteNumber, float velocity);
 void        tPoly_noteOff(tPoly* poly, int midiNoteNumber);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* tMPoly */
 typedef struct _tMPoly
 {
@@ -110,9 +111,13 @@
 int     tMPoly_getVelocity(tMPoly* const, uint8_t voice);
 int     tMPoly_isOn(tMPoly* const, uint8_t voice);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
     
 #ifdef __cplusplus
 }
-#endif
+#endif
+
+#endif // LEAF_MIDI_H_INCLUDED
+
+//==============================================================================
 
--- a/LEAF/Inc/leaf-oscillator.h
+++ b/LEAF/Inc/leaf-oscillator.h
@@ -1,21 +1,19 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    LEAFOscillator.h
+    leaf-oscillator.h
     Created: 20 Jan 2017 12:00:58pm
     Author:  Michael R Mulshine
 
-  ==============================================================================
-*/
+==============================================================================*/
 
-#ifndef LEAFOSCILLATOR_H_INCLUDED
-#define LEAFOSCILLATOR_H_INCLUDED
+#ifndef LEAF_OSCILLATOR_H_INCLUDED
+#define LEAF_OSCILLATOR_H_INCLUDED
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 #include "leaf-globals.h"
 #include "leaf-math.h"
@@ -22,7 +20,7 @@
 
 #include "leaf-filter.h"
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* tNeuron */
 typedef enum NeuronMode
@@ -66,7 +64,7 @@
 void        tNeuron_setV3       (tNeuron* const, float V3);
 void        tNeuron_setTimeStep (tNeuron* const, float timestep);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* tPhasor: Aliasing phasor [0.0, 1.0) */
 typedef struct _tPhasor
@@ -82,7 +80,7 @@
 float       tPhasor_tick        (tPhasor*  const);
 int         tPhasor_setFreq     (tPhasor*  const, float freq);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* tCycle: Cycle/Sine waveform. Wavetable synthesis.*/
 typedef struct _tCycle
@@ -99,7 +97,7 @@
 float       tCycle_tick         (tCycle*  const);
 int         tCycle_setFreq      (tCycle*  const, float freq);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* tSawtooth: Anti-aliased Sawtooth waveform using wavetable interpolation. Wavetables constructed from sine components. */
 typedef struct _tSawtooth
@@ -116,7 +114,7 @@
 float       tSawtooth_tick      (tSawtooth*  const);
 int         tSawtooth_setFreq   (tSawtooth*  const, float freq);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* tTriangle: Anti-aliased Triangle waveform using wavetable interpolation. Wavetables constructed from sine components. */
 typedef struct _tTriangle
@@ -133,7 +131,7 @@
 float       tTriangle_tick      (tTriangle*  const);
 int         tTriangle_setFreq   (tTriangle*  const, float freq);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* tSquare: Anti-aliased Square waveform using wavetable interpolation. Wavetables constructed from sine components. */
 typedef struct _tSquare
@@ -150,7 +148,7 @@
 float       tSquare_tick        (tSquare*  const);
 int         tSquare_setFreq     (tSquare*  const, float freq);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* tNoise. WhiteNoise, PinkNoise. */
 typedef enum NoiseType
@@ -173,10 +171,12 @@
 
 float       tNoise_tick          (tNoise*  const);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
     
 #ifdef __cplusplus
 }
 #endif
         
-#endif  // LEAFOSCILLATOR_H_INCLUDED
+#endif  // LEAF_OSCILLATOR_H_INCLUDED
+
+//==============================================================================
--- a/LEAF/Inc/leaf-pitch.h
+++ b/LEAF/Inc/leaf-pitch.h
@@ -8,11 +8,14 @@
   ==============================================================================
 */
 
+#ifndef LEAF_PITCH_H_INCLUDED
+#define LEAF_PITCH_H_INCLUDED
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 #include "leaf-globals.h"
 #include "leaf-math.h"
@@ -20,8 +23,8 @@
 #include "leaf-filter.h"
 #include "leaf-utilities.h"
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 #define DEFPITCHRATIO 2.0f
 #define DEFTIMECONSTANT 100.0f
 #define DEFHOPSIZE 64
@@ -29,8 +32,8 @@
 #define FBA 20
 #define HPFREQ 40.0f
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* tSOLAD : pitch shifting algorithm that underlies tPitchShifter etc */
 #define LOOPSIZE (2048*2)      // (4096*2) // loop size must be power of two
 #define LOOPMASK (LOOPSIZE - 1)
@@ -72,8 +75,8 @@
 // reset state variables
 void    tSOLAD_resetState       (tSOLAD *w);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 // tSNAC: period detector
 #define SNAC_FRAME_SIZE 1024           // default analysis framesize // should be the same as (or smaller than?) PS_FRAME_SIZE
 #define DEFOVERLAP 1                // default overlap
@@ -112,8 +115,8 @@
 float   tSNAC_getPeriod     (tSNAC *s);
 float   tSNAC_getfidelity   (tSNAC *s);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 // Pitch shifter 
 typedef struct _tPitchShifter
 {
@@ -159,8 +162,8 @@
 void        tPitchShifter_setWindowSize     (tPitchShifter* const, int ws);
 float       tPitchShifter_getPeriod         (tPitchShifter* const);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 // Period detection
 typedef struct _tPeriod
 {
@@ -198,8 +201,8 @@
 void        tPeriod_setHopSize              (tPeriod* p, int hs);
 void        tPeriod_setWindowSize           (tPeriod* p, int ws);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 // Pitch shift
 typedef struct _tPitchShift
 {
@@ -229,8 +232,12 @@
 float       tPitchShift_shiftToFreq         (tPitchShift* const, float freq);
 void        tPitchShift_setPitchFactor      (tPitchShift* const, float pf);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
     
 #ifdef __cplusplus
 }
-#endif
+#endif
+
+#endif // LEAF_PITCH_H_INCLUDED
+
+//==============================================================================
--- a/LEAF/Inc/leaf-reverb.h
+++ b/LEAF/Inc/leaf-reverb.h
@@ -1,22 +1,20 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    LEAFReverb.h
+    leaf-reverb.h
     Created: 20 Jan 2017 12:02:04pm
     Author:  Michael R Mulshine
 
-  ==============================================================================
-*/
+==============================================================================*/
 
-#ifndef LEAFREVERB_H_INCLUDED
-#define LEAFREVERB_H_INCLUDED
+#ifndef LEAF_REVERB_H_INCLUDED
+#define LEAF_REVERB_H_INCLUDED
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 #include "leaf-globals.h"
 #include "leaf-math.h"
 
@@ -24,7 +22,7 @@
 #include "leaf-filter.h"
 #include "leaf-oscillator.h"
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* PRCRev: Reverb, reimplemented from STK (Cook and Scavone). */
 typedef struct _tPRCRev
@@ -53,7 +51,7 @@
 // Set mix between dry input and wet output signal.
 void    tPRCRev_setMix  (tPRCRev* const, float mix);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* NRev: Reverb, reimplemented from STK (Cook and Scavone). */
 typedef struct _tNRev
@@ -83,7 +81,7 @@
 // Set mix between dry input and wet output signal.
 void    tNRev_setMix    (tNRev*  const, float mix);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 typedef struct _tDattorro
 {
@@ -145,4 +143,6 @@
 }
 #endif
 
-#endif  // LEAFREVERB_H_INCLUDED
+#endif  // LEAF_REVERB_H_INCLUDED
+
+//==============================================================================
--- /dev/null
+++ b/LEAF/Inc/leaf-sample.h
@@ -1,0 +1,124 @@
+/*==============================================================================
+
+    leaf-sample.h
+    Created: 23 Jan 2019 11:22:09am
+    Author:  Mike Mulshine
+
+==============================================================================*/
+
+
+#ifndef LEAF_SAMPLE_H_INCLUDED
+#define LEAF_SAMPLE_H_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+    
+//==============================================================================
+ 
+#include "leaf-globals.h"
+#include "leaf-math.h"
+    
+#include "leaf-utilities.h"
+    
+//==============================================================================
+    
+    typedef enum RecordMode
+    {
+        RecordOneShot = 0,
+        RecordLoop,
+        RecordModeNil
+    } RecordMode;
+    
+    typedef struct _tBuffer
+    {
+        float* buff;
+        
+        uint32_t idx;
+        uint32_t length;
+        
+        RecordMode mode;
+        
+        int active;
+        
+    } tBuffer;
+
+    void  tBuffer_init (tBuffer* const, uint32_t length);
+    void  tBuffer_free (tBuffer* const);
+    
+    void  tBuffer_tick (tBuffer* const, float sample);
+    
+    void  tBuffer_read(tBuffer* const, float* buff, uint32_t len);
+    
+    float tBuffer_get (tBuffer* const, int idx);
+    
+    void  tBuffer_record (tBuffer* const);
+    void  tBuffer_stop (tBuffer* const);
+    
+    void  tBuffer_setRecordMode (tBuffer* const, RecordMode mode);
+    
+    void  tBuffer_clear (tBuffer* const);
+    
+//==============================================================================
+    
+    typedef enum PlayMode
+    {
+        PlayNormal,
+        PlayLoop,
+        PlayBackAndForth,
+        PlayModeNil
+    } PlayMode;
+    
+    typedef struct _tSampler
+    {
+        tBuffer* samp;
+        
+        tRamp gain;
+        
+        float idx;
+        float inc;
+        float iinc;
+        int8_t dir;
+        int8_t flip;
+        int8_t bnf;
+        
+        int32_t start;
+        int32_t end;
+        uint32_t len;
+        uint32_t cfxlen;
+    
+        PlayMode mode;
+        int retrigger;
+        
+        int active;
+
+    } tSampler;
+    
+    void    tSampler_init      (tSampler* const, tBuffer* s);
+    void    tSampler_free      (tSampler* const);
+    
+    float   tSampler_tick      (tSampler* const);
+
+    void    tSampler_setSample (tSampler* const, tBuffer* s);
+    
+    void    tSampler_setMode   (tSampler* const, PlayMode mode);
+    
+    void    tSampler_play      (tSampler* const);
+    void    tSampler_stop      (tSampler* const);
+    
+    void    tSampler_setStart  (tSampler* const, int32_t start);
+    void    tSampler_setEnd    (tSampler* const, int32_t end);
+    
+    void    tSampler_setCrossfadeLength  (tSampler* const p, uint32_t length);
+    
+    void    tSampler_setRate   (tSampler* const, float rate);
+    
+//==============================================================================
+    
+#ifdef __cplusplus
+}
+#endif
+
+#endif // LEAF_SAMPLE_H_INCLUDED
+
+//==============================================================================
--- a/LEAF/Inc/leaf-string.h
+++ b/LEAF/Inc/leaf-string.h
@@ -8,11 +8,14 @@
   ==============================================================================
 */
 
+#ifndef LEAF_STRING_H_INCLUDED
+#define LEAF_STRING_H_INCLUDED
+
 #ifdef __cplusplus
 extern "C" {
 #endif
     
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 #include "leaf-globals.h"
 #include "leaf-math.h"
@@ -21,7 +24,7 @@
 #include "leaf-filter.h"
 #include "leaf-oscillator.h"
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* Karplus Strong model */
 typedef struct _tPluck
@@ -62,9 +65,8 @@
 // tPluck Utilities.
 float       tPluck_getLastOut    (tPluck*  const);
 
-
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
+//==============================================================================
+    
 /* Stif Karplus Strong model */
 typedef struct _tStifKarp
 {
@@ -130,8 +132,12 @@
 // tStifKarp utilities.
 float       tStifKarp_getLastOut         (tStifKarp*  const);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
     
 #ifdef __cplusplus
 }
-#endif
+#endif
+
+#endif // LEAF_STRING_H_INCLUDED
+
+//==============================================================================
--- a/LEAF/Inc/leaf-utilities.h
+++ b/LEAF/Inc/leaf-utilities.h
@@ -1,26 +1,24 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    LEAFUtilities.h
+    leaf-utilities.h
     Created: 20 Jan 2017 12:02:17pm
     Author:  Michael R Mulshine
 
-  ==============================================================================
-*/
+==============================================================================*/
 
-#ifndef LEAFUTILITIES_H_INCLUDED
-#define LEAFUTILITIES_H_INCLUDED
+#ifndef LEAF_UTILITIES_H_INCLUDED
+#define LEAF_UTILITIES_H_INCLUDED
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 #include "leaf-globals.h"
 #include "leaf-math.h"
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 // STACK implementation (fixed size)
 #define STACK_SIZE 128
@@ -48,7 +46,7 @@
 int     tStack_next                 (tStack* const);
 int     tStack_get                  (tStack* const, int which);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* Ramp */
 typedef struct _tRamp {
@@ -70,7 +68,7 @@
 int     tRamp_setDest   (tRamp* const, float dest);
 int     tRamp_setVal    (tRamp* const, float val);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* Compressor */
 typedef struct _tCompressor
@@ -88,7 +86,7 @@
 void    tCompressor_free    (tCompressor* const);
 float   tCompressor_tick    (tCompressor* const, float input);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* Attack-Decay envelope */
 typedef struct _tEnvelope {
@@ -120,7 +118,7 @@
 int     tEnvelope_loop      (tEnvelope*  const, oBool loop);
 int     tEnvelope_on        (tEnvelope*  const, float velocity);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* ADSR */
 typedef struct _tADSR
@@ -152,7 +150,7 @@
 int     tADSR_on        (tADSR*  const, float velocity);
 int     tADSR_off       (tADSR*  const);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* Envelope Follower */
 typedef struct _tEnvelopeFollower
@@ -170,7 +168,7 @@
 int     tEnvelopeFollower_decayCoeff     (tEnvelopeFollower*  const, float decayCoeff);
 int     tEnvelopeFollower_attackThresh   (tEnvelopeFollower*  const, float attackThresh);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* tAtkDtk */
 #define DEFBLOCKSIZE 1024
@@ -221,7 +219,7 @@
 // find largest transient in input block, return index of attack
 int     tAtkDtk_detect          (tAtkDtk* const, float *in);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 // ENV~ from PD, modified for LEAF
 #define MAXOVERLAP 32
@@ -246,12 +244,14 @@
 float   tEnv_tick           (tEnv* const);
 void    tEnv_processBlock   (tEnv* const, float* in);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
     
 #ifdef __cplusplus
 }
 #endif
 
-#endif  // LEAFUTILITIES_H_INCLUDED
+#endif  // LEAF_UTILITIES_H_INCLUDED
+
+//==============================================================================
 
 
--- a/LEAF/Inc/leaf-vocoder.h
+++ b/LEAF/Inc/leaf-vocoder.h
@@ -1,26 +1,24 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    LEAFInstrument.h
+    leaf-vocoder.h
     Created: 20 Jan 2017 12:01:54pm
     Author:  Michael R Mulshine
 
-  ==============================================================================
-*/
+==============================================================================*/
 
-#ifndef LEAFINSTRUMENT_H_INCLUDED
-#define LEAFINSTRUMENT_H_INCLUDED
+#ifndef LEAF_VOCODER_H_INCLUDED
+#define LEAF_VOCODER_H_INCLUDED
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 #include "leaf-globals.h"
 #include "leaf-math.h"
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* tTalkbox */
 #define NUM_TALKBOX_PARAM 4
@@ -52,7 +50,7 @@
 void        tTalkbox_lpc         (float *buf, float *car, int32_t n, int32_t o);
 void		tTalkbox_setQuality  (tTalkbox* const, float quality);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* tVocoder */
 #define NUM_VOCODER_PARAM 8
@@ -79,10 +77,12 @@
 void        tVocoder_update      (tVocoder* const);
 void        tVocoder_suspend     (tVocoder* const);
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 #ifdef __cplusplus
 }
 #endif
         
-#endif  // LEAFINSTRUMENT_H_INCLUDED
+#endif  // LEAF_VOCODER_H_INCLUDED
+
+//==============================================================================
--- a/LEAF/Inc/leaf-wavefolder.h
+++ b/LEAF/Inc/leaf-wavefolder.h
@@ -1,23 +1,25 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
     leaf-wavefolder.h
     Created: 30 Nov 2018 11:57:05am
     Author:  airship
 
-  ==============================================================================
-*/
-
-#ifdef __cplusplus
-extern "C" {
+==============================================================================*/
+
+#ifndef LEAF_WAVEFOLDER_H_INCLUDED
+#define LEAF_WAVEFOLDER_H_INCLUDED
+
+
+#ifdef __cplusplus
+extern "C" {
 #endif
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 #include "leaf-globals.h"
 #include "leaf-math.h"
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* tLockhartWavefolder */
 #define THRESH 10e-10
@@ -43,9 +45,14 @@
 void    tLockhartWavefolder_free    (tLockhartWavefolder* const);
 
 float   tLockhartWavefolder_tick    (tLockhartWavefolder* const, float samp);
-
-    
-#ifdef __cplusplus
-}
+
+    
+//==============================================================================
+    
+#ifdef __cplusplus
+}
 #endif
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+
+#endif // LEAF_WAVEFOLDER_H_INCLUDED
+
+//==============================================================================
--- a/LEAF/Inc/leaf-wavetables.h
+++ b/LEAF/Inc/leaf-wavetables.h
@@ -1,26 +1,24 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    LEAFWavetables.h
+    leaf-wavetables.h
     Created: 4 Dec 2016 9:42:41pm
     Author:  Michael R Mulshine
 
-  ==============================================================================
-*/
+==============================================================================*/
 
-#ifndef WAVETABLES_H_INCLUDED
-#define WAVETABLES_H_INCLUDED
+#ifndef LEAF_WAVETABLES_H_INCLUDED
+#define LEAF_WAVETABLES_H_INCLUDED
 
 #ifdef __cplusplus
 extern "C" {
-#endif
+#endif
+    
+//==============================================================================
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-
 #include "leaf-globals.h"
 #include "leaf-math.h"
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 
 #define SINE_TABLE_SIZE 2048
@@ -62,7 +60,7 @@
 
 extern const float tanh1[TANH1_TABLE_SIZE];
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
 
 /* Sine wave table ripped from http://aquaticus.info/pwm-sine-wave. */
 extern const float sinewave[SINE_TABLE_SIZE];
@@ -73,10 +71,12 @@
 
 extern const float squarewave[11][SQR_TABLE_SIZE];
 
-// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+//==============================================================================
     
 #ifdef __cplusplus
 }
 #endif
 
-#endif  // WAVETABLES_H_INCLUDED
+#endif  // LEAF_WAVETABLES_H_INCLUDED
+
+//==============================================================================
--- a/LEAF/Src/leaf-808.c
+++ b/LEAF/Src/leaf-808.c
@@ -1,12 +1,10 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    leaf_808.cpp
+    leaf-808.c
     Created: 30 Nov 2018 10:24:21am
     Author:  airship
 
-  ==============================================================================
-*/
+==============================================================================*/
 
 #if _WIN32 || _WIN64
 
--- a/LEAF/Src/leaf-crusher.c
+++ b/LEAF/Src/leaf-crusher.c
@@ -1,84 +1,84 @@
-/*==============================================================================
-
-    leaf-crusher.c
-    Created: 30 Nov 2018 11:56:49am
-    Author:  airship
-
-==============================================================================*/
-
-#if _WIN32 || _WIN64
-
-#include "..\Inc\leaf-crusher.h"
-
-#else
-
-#include "../Inc/leaf-crusher.h"
-
-#endif
-
-//==============================================================================
-
-#define SCALAR 5000.f
-
-void    tCrusher_init    (tCrusher* const c)
-{
-    c->op = 4;
-    c->div = SCALAR;
-    c->rnd = 0.25f;
-    c->srr = 0.25f;
-
-    c->gain = (c->div / SCALAR) * 0.7f + 0.3f;
-}
-
-void    tCrusher_free    (tCrusher* const c)
-{
-    leaf_free(c);
-}
-
-float   tCrusher_tick    (tCrusher* const c, float input)
-{
-    float sample = input;
-
-    sample *= SCALAR; // SCALAR is 5000 by default
-
-    sample = (int32_t) sample;
-
-    sample /= c->div;
-
-    sample = LEAF_bitwise_xor(sample, c->op << 23);
-
-    sample = LEAF_clip(-1.f, sample, 1.f);
-
-    sample = LEAF_round(sample, c->rnd);
-
-    sample = LEAF_reduct(sample, c->srr);
-
-    return sample * c->gain;
-
-}
-
-void    tCrusher_setOperation (tCrusher* const c, float op)
-{
-	c->op = (uint32_t) (op * 8.0f);
-}
-
-// 0.0 - 1.0
-void    tCrusher_setQuality (tCrusher* const c, float val)
-{
-    val = LEAF_clip(0.0f, val, 1.0f);
-
-    c->div = 0.01f + val * SCALAR;
-
-    c->gain = (c->div / SCALAR) * 0.7f + 0.3f;
-}
-
-// what decimal to round to
-void    tCrusher_setRound (tCrusher* const c, float rnd)
-{
-    c->rnd = fabsf(rnd);
-}
-
-void    tCrusher_setSamplingRatio (tCrusher* const c, float ratio)
-{
-    c->srr = ratio;
+/*==============================================================================
+
+    leaf-crusher.c
+    Created: 30 Nov 2018 11:56:49am
+    Author:  airship
+
+==============================================================================*/
+
+#if _WIN32 || _WIN64
+
+#include "..\Inc\leaf-crusher.h"
+
+#else
+
+#include "../Inc/leaf-crusher.h"
+
+#endif
+
+//==============================================================================
+
+#define SCALAR 5000.f
+
+void    tCrusher_init    (tCrusher* const c)
+{
+    c->op = 4;
+    c->div = SCALAR;
+    c->rnd = 0.25f;
+    c->srr = 0.25f;
+    
+    c->gain = (c->div / SCALAR) * 0.7f + 0.3f;
+}
+
+void    tCrusher_free    (tCrusher* const c)
+{
+    leaf_free(c);
+}
+
+float   tCrusher_tick    (tCrusher* const c, float input)
+{
+    float sample = input;
+    
+    sample *= SCALAR; // SCALAR is 5000 by default
+    
+    sample = (int32_t) sample;
+    
+    sample /= c->div;
+
+    sample = LEAF_bitwise_xor(sample, c->op << 23);
+    
+    sample = LEAF_clip(-1.f, sample, 1.f);
+    
+    sample = LEAF_round(sample, c->rnd);
+    
+    sample = LEAF_reduct(sample, c->srr);
+    
+    return sample * c->gain;
+    
+}
+
+void    tCrusher_setOperation (tCrusher* const c, float op)
+{
+	c->op = (uint32_t) (op * 8.0f);
+}
+
+// 0.0 - 1.0
+void    tCrusher_setQuality (tCrusher* const c, float val)
+{
+    val = LEAF_clip(0.0f, val, 1.0f);
+    
+    c->div = 0.01f + val * SCALAR;
+    
+    c->gain = (c->div / SCALAR) * 0.7f + 0.3f;
+}
+
+// what decimal to round to
+void    tCrusher_setRound (tCrusher* const c, float rnd)
+{
+    c->rnd = fabsf(rnd);
+}
+
+void    tCrusher_setSamplingRatio (tCrusher* const c, float ratio)
+{
+    c->srr = ratio;
 }
--- a/LEAF/Src/leaf-delay.c
+++ b/LEAF/Src/leaf-delay.c
@@ -1,12 +1,10 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    LEAFDelay.c
+    leaf-delay.c
     Created: 20 Jan 2017 12:01:24pm
     Author:  Michael R Mulshine
 
-  ==============================================================================
-*/
+==============================================================================*/
 
 #if _WIN32 || _WIN64
 
@@ -415,8 +413,6 @@
 void   tTapeDelay_init (tTapeDelay* const d, float delay, uint32_t maxDelay)
 {
     d->maxDelay = maxDelay;
-    
-    d->delay = LEAF_clip(1.f, delay, d->maxDelay);
 
     d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay);
     
@@ -429,7 +425,7 @@
     d->inc = 1.0f;
     d->inPoint = 0;
     
-    tTapeDelay_setDelay(d, 1.f);
+    tTapeDelay_setDelay(d, delay);
 }
 
 void tTapeDelay_free(tTapeDelay* const d)
@@ -440,7 +436,7 @@
 
 int count = 0;
 
-#define SMOOTH_FACTOR 10.f
+//#define SMOOTH_FACTOR 10.f
 
 float   tTapeDelay_tick (tTapeDelay* const d, float input)
 {
@@ -461,11 +457,11 @@
     float diff = (d->inPoint - d->idx);
     while (diff < 0.f) diff += d->maxDelay;
     
-    d->inc = 1.0f + (diff - d->delay) / d->delay * SMOOTH_FACTOR;
+    d->inc = 1.0f + (diff - d->delay) / d->delay; //* SMOOTH_FACTOR;
 
     d->idx += d->inc;
     
-    if (d->idx >= d->maxDelay) d->idx = 0.f;
+    if (d->idx >= d->maxDelay) d->idx = 0.0f;
 
     return d->lastOut;
 }
--- a/LEAF/Src/leaf-filter.c
+++ b/LEAF/Src/leaf-filter.c
@@ -1,12 +1,10 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    LEAFFilter.c
+    leaf-filter.c
     Created: 20 Jan 2017 12:01:10pm
     Author:  Michael R Mulshine
 
-  ==============================================================================
-*/
+==============================================================================*/
 
 #if _WIN32 || _WIN64
 
--- a/LEAF/Src/leaf-formant.c
+++ b/LEAF/Src/leaf-formant.c
@@ -1,12 +1,10 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    leaf-formant.cpp
+    leaf-formant.c
     Created: 30 Nov 2018 11:03:30am
     Author:  airship
 
-  ==============================================================================
-*/
+==============================================================================*/
 
 #if _WIN32 || _WIN64
 
--- a/LEAF/Src/leaf-math.c
+++ b/LEAF/Src/leaf-math.c
@@ -21,57 +21,56 @@
 // The C-embedded Audio Library.
 #define TWO_TO_16 65536.f
 
-#define EXPONENTIAL_TABLE_SIZE 65536
-
-float interpolate3max(float *buf, const int peakindex)
-{
-    float a = buf[peakindex-1];
-    float b = buf[peakindex];
-    float c = buf[peakindex+1];
-    float realpeak;
-
-    realpeak = b + (float)0.125 * (c - a) * (c - a) / ((float)2. * b - a - c);
-
-    return(realpeak);
-}
-
-float interpolate3phase(float *buf, const int peakindex)
-{
-    float a = buf[peakindex-1];
-    float b = buf[peakindex];
-    float c = buf[peakindex+1];
-    float fraction;
-
-    fraction = ((float)0.5 * (c - a)) / ((float)2. * b - a - c);
-
-    return(fraction);
-}
-
-// alternative implementation for abs()
-// REQUIRES: 32 bit integers
-int fastabs_int(int in){
-    unsigned int r;
-    int const mask = in >> 31;
-
-    r = (in ^ mask) - mask;
-
-    return (r);
-}
-
-// alternative implementation for abs()
-// REQUIRES: 32 bit floats
-float fastabs(float f)
-{
-    union
-    {
-        float f;
-        unsigned int ui;
-    }alias;
-
-    alias.f = f;
-    alias.ui &= 0x7fffffff;
+#define EXPONENTIAL_TABLE_SIZE 65536
+
+float interpolate3max(float *buf, const int peakindex)
+{
+    float a = buf[peakindex-1];
+    float b = buf[peakindex];
+    float c = buf[peakindex+1];
+    float realpeak;
+    
+    realpeak = b + (float)0.125 * (c - a) * (c - a) / ((float)2. * b - a - c);
+    
+    return(realpeak);
+}
+
+float interpolate3phase(float *buf, const int peakindex)
+{
+    float a = buf[peakindex-1];
+    float b = buf[peakindex];
+    float c = buf[peakindex+1];
+    float fraction;
+    
+    fraction = ((float)0.5 * (c - a)) / ((float)2. * b - a - c);
+    
+    return(fraction);
+}
+
+// alternative implementation for abs()
+// REQUIRES: 32 bit integers
+int fastabs_int(int in){
+    unsigned int r;
+    int const mask = in >> 31;
+    
+    r = (in ^ mask) - mask;
+    
+    return (r);
+}
+
+// alternative implementation for abs()
+// REQUIRES: 32 bit floats
+float fastabs(float f)
+{
+    union
+    {
+        float f;
+        unsigned int ui;
+    }alias;
+    
+    alias.f = f;
+    alias.ui &= 0x7fffffff;
     return alias.f;
-
 }
 
 // dope af
@@ -117,47 +116,47 @@
     float shaperOut = w*(c+ 0.05f*xc2)*(m_drive + 0.75f);
     shaperOut *= 0.5f;    // post_scale
     return shaperOut;
+}
+
+// reduce sample resolution
+float hold = 0.f;
+int reduct_count = 0;
+
+
+float LEAF_reduct (float input, float ratio)
+{
+    reduct_count++;
+    if (reduct_count > 1.f / ratio)
+    {
+        hold = input;
+        reduct_count = 0;
+    }
+    
+    return hold;
+}
+
+// round input to nearest rnd
+float LEAF_round (float input, float rnd)
+{
+    rnd = fabsf(rnd);
+    
+    if (rnd <= 0.0000001f) return input;
+    
+    float scale = 1.f / rnd;
+    
+    return roundf(input * scale) / scale;
+}
+
+union unholy_t unholy;
+
+float LEAF_bitwise_xor(float input, uint32_t op)
+{
+    unholy.f = input;
+    unholy.i = (unholy.i ^ op);
+    
+    return unholy.f;
 }
 
-// reduce sample resolution
-float hold = 0.f;
-int reduct_count = 0;
-
-
-float LEAF_reduct (float input, float ratio)
-{
-    reduct_count++;
-    if (reduct_count > 1.f / ratio)
-    {
-        hold = input;
-        reduct_count = 0;
-    }
-
-    return hold;
-}
-
-// round input to nearest rnd
-float LEAF_round (float input, float rnd)
-{
-    rnd = fabsf(rnd);
-
-    if (rnd <= 0.0000001f) return input;
-
-    float scale = 1.f / rnd;
-
-    return roundf(input * scale) / scale;
-}
-
-union unholy_t unholy;
-
-float LEAF_bitwise_xor(float input, uint32_t op)
-{
-    unholy.f = input;
-    unholy.i = (unholy.i ^ op);
-
-    return unholy.f;
-}
-
 float LEAF_reedTable(float input, float offset, float slope) 
 {
     float output = offset + (slope * input);
@@ -196,19 +195,18 @@
     } else {
         return val;
     }
+}
+
+int   LEAF_clipInt(int min, int val, int max)
+{
+    if (val < min) {
+        return min;
+    } else if (val > max) {
+        return max;
+    } else {
+        return val;
+    }
 }
-
-int   LEAF_clipInt(int min, int val, int max)
-{
-    if (val < min) {
-        return min;
-    } else if (val > max) {
-        return max;
-    } else {
-        return val;
-    }
-}
-
 
 oBool     LEAF_isPrime(uint64_t number )
 {
--- a/LEAF/Src/leaf-mempool.c
+++ b/LEAF/Src/leaf-mempool.c
@@ -121,7 +121,11 @@
 
 void* leaf_alloc(size_t size)
 {
-    return mpool_alloc(size, &leaf_pool);
+	void* block = mpool_alloc(size, &leaf_pool);
+
+	if (block == NULL) leaf_mempool_overrun();
+
+    return block;
 }
 
 void mpool_free(void* ptr, mpool_t* pool)
@@ -189,5 +193,10 @@
  */
 static inline size_t mpool_align(size_t size) {
     return (size + (MPOOL_ALIGN_SIZE - 1)) & ~(MPOOL_ALIGN_SIZE - 1);
+}
+
+void leaf_mempool_overrun(void)
+{
+
 }
 
--- a/LEAF/Src/leaf-midi.c
+++ b/LEAF/Src/leaf-midi.c
@@ -1,12 +1,10 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    leaf-midi.cpp
+    leaf-midi.c
     Created: 30 Nov 2018 11:29:16am
     Author:  airship
 
-  ==============================================================================
-*/
+==============================================================================*/
 
 #if _WIN32 || _WIN64
 
--- a/LEAF/Src/leaf-oscillator.c
+++ b/LEAF/Src/leaf-oscillator.c
@@ -1,12 +1,10 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    LEAFOscillator.c
+    leaf-oscillator.c
     Created: 20 Jan 2017 12:00:58pm
     Author:  Michael R Mulshine
 
-  ==============================================================================
-*/
+==============================================================================*/
 
 #if _WIN32 || _WIN64
 
--- a/LEAF/Src/leaf-pitch.c
+++ b/LEAF/Src/leaf-pitch.c
@@ -1,12 +1,10 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    leaf-pitch.cpp
+    leaf-pitch.c
     Created: 30 Nov 2018 11:02:59am
     Author:  airship
 
-  ==============================================================================
-*/
+==============================================================================*/
 
 #if _WIN32 || _WIN64
 
--- a/LEAF/Src/leaf-reverb.c
+++ b/LEAF/Src/leaf-reverb.c
@@ -1,12 +1,10 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    LEAFReverb.c
+    leaf-reverb.c
     Created: 20 Jan 2017 12:02:04pm
     Author:  Michael R Mulshine
 
-  ==============================================================================
-*/
+==============================================================================*/
 
 #if _WIN32 || _WIN64
 
--- /dev/null
+++ b/LEAF/Src/leaf-sample.c
@@ -1,0 +1,430 @@
+/*
+  ==============================================================================
+
+    leaf-sample.c
+    Created: 20 Jan 2017 12:02:17pm
+    Author:  Michael R Mulshine
+
+  ==============================================================================
+*/
+
+
+#if _WIN32 || _WIN64
+
+#include "..\Inc\leaf-sample.h"
+#include "..\leaf.h"
+
+#else
+
+#include "../Inc/leaf-sample.h"
+#include "../leaf.h"
+
+#endif
+
+//==============================================================================
+
+void  tBuffer_init (tBuffer* const s, uint32_t length)
+{
+    s->buff = (float*) leaf_alloc( sizeof(float) * length);
+    
+    
+    s->length = length;
+    s->active = 0;
+    s->idx = 0;
+    s->mode = RecordOneShot;
+    
+    tBuffer_clear(s);
+}
+
+void  tBuffer_free (tBuffer* const s)
+{
+    leaf_free(s->buff);
+    leaf_free(s);
+}
+
+void tBuffer_tick (tBuffer* const s, float sample)
+{
+    if (s->active == 1)
+    {
+        s->buff[s->idx] = sample;
+        
+        s->idx += 1;
+        
+        if (s->idx >= s->length)
+        {
+            if (s->mode == RecordOneShot)
+            {
+                tBuffer_stop(s);
+            }
+            else if (s->mode == RecordLoop)
+            {
+                s->idx = 0;
+            }
+        }
+    }
+}
+
+void  tBuffer_read(tBuffer* const s, float* buff, uint32_t len)
+{
+    for (int i = 0; i < s->length; i++)
+    {
+        if (i < len)    s->buff[i] = buff[i];
+        else            s->buff[i] = 0.f;
+    }
+}
+
+float tBuffer_get (tBuffer* const s, int idx)
+{
+    if ((idx < 0) || (idx >= s->length)) return 0.f;
+    
+    return s->buff[idx];
+}
+
+void  tBuffer_record(tBuffer* const s)
+{
+    s->active = 1;
+    s->idx = 0;
+}
+
+void  tBuffer_stop(tBuffer* const s)
+{
+    s->active = 0;
+}
+
+void  tBuffer_setRecordMode (tBuffer* const s, RecordMode mode)
+{
+    s->mode = mode;
+}
+
+void  tBuffer_clear (tBuffer* const s)
+{
+    for (int i = 0; i < s->length; i++)
+    {
+        s->buff[i] = 0.f;
+    }
+}
+
+//================================tSampler=====================================
+
+void tSampler_init         (tSampler* const p, tBuffer* s)
+{
+    p->samp = s;
+    
+    p->active = 0;
+    
+    p->start = 0;
+    p->end = p->samp->length - 1;
+    
+    p->len = p->end - p->start;
+    
+    p->idx = 0.f;
+    p->inc = 1.f;
+    p->iinc = 1.f;
+    
+    p->dir = 1;
+    p->flip = 1;
+    p->bnf = 1;
+    
+    p->mode = PlayNormal;
+    
+    p->cfxlen = 500; // default 300 sample crossfade
+    
+    tRamp_init(&p->gain, 7.0f, 1);
+    tRamp_setVal(&p->gain, 0.f);
+}
+
+void tSampler_free         (tSampler* const p)
+{
+    leaf_free(p->samp);
+    leaf_free(p);
+}
+
+float tSampler_tick        (tSampler* const p)
+{
+    if (p->active == 0 || (p->len < 4))         return 0.f;
+    
+    float sample = 0.f;
+    float cfxsample = 0.f;
+    int numsamps;
+    float g1 = 1.f, g2 = 0.f;
+    
+    float* buff = p->samp->buff;
+    
+    int dir = p->bnf * p->dir * p->flip;
+    
+    int idx;
+    float alpha;
+
+    if (dir > 0)
+    {
+    	idx = (int) p->idx;
+    	alpha = p->idx - idx;
+    }
+    else
+    {
+    	idx = (int) (p->idx + 1.f); // we think this is because flooring on int works different when reading backwards
+    	alpha = (p->idx+1.f) - idx;
+    }
+    
+    int32_t start = p->start, end = p->end;
+    if (p->flip < 0)
+    {
+        start = p->end;
+        end = p->start;
+    }
+    
+    // Check dir (direction) to interpolate properly
+    if (dir > 0)
+    {
+        // FORWARD NORMAL SAMPLE
+        int i1 = idx-1;
+        int i3 = idx+1;
+        int i4 = idx+2;
+
+        sample =     LEAF_interpolate_hermite (buff[i1],
+                                               buff[idx],
+                                               buff[i3],
+                                               buff[i4],
+                                               alpha);
+        
+        // num samples to end of loop
+        numsamps = (dir > 0) ? (end - idx) : (idx - start);
+        numsamps *= p->iinc;
+        
+        if (p->mode == PlayLoop)
+        {
+            if (numsamps <= p->cfxlen)
+            {
+                // CROSSFADE SAMPLE
+                float idxx =  p->idx - p->len;
+                int cdx = (int)(idxx);
+                
+                i1 = cdx-1;
+                i3 = cdx+1;
+                i4 = cdx+2;
+                
+                cfxsample =     LEAF_interpolate_hermite (buff[i1],
+                                                          buff[cdx],
+                                                          buff[i3],
+                                                          buff[i4],
+                                                          alpha);
+                
+                g2 = (float) (p->cfxlen - numsamps) / (float) p->cfxlen;
+            }
+        }
+    }
+    else
+    {
+        // REVERSE
+        int i1 = idx+1;
+        int i3 = idx-1;
+        int i4 = idx-2;
+    
+        sample =     LEAF_interpolate_hermite (buff[i1],
+                                               buff[idx],
+                                               buff[i3],
+                                               buff[i4],
+                                               1.0f-alpha);
+        
+        numsamps = (idx - start) / p->inc;
+        
+        if (p->mode == PlayLoop)
+        {
+            if (numsamps <= p->cfxlen)
+            {
+                // CROSSFADE SAMPLE
+                float idxx =  p->idx + p->len + 1.f;
+                int cdx = (int)(idxx);
+                alpha = idxx - cdx;
+                
+                i1 = cdx+1;
+                i3 = cdx-1;
+                i4 = cdx-2;
+                
+                cfxsample =     LEAF_interpolate_hermite (buff[i1],
+                                                          buff[cdx],
+                                                          buff[i3],
+                                                          buff[i4],
+                                                          1.f-alpha);
+                
+                g2 = (float) (p->cfxlen - numsamps) / (float) p->cfxlen;
+            }
+        }
+    }
+    
+    p->idx += (dir * p->inc);
+    
+    if (p->mode == PlayNormal)
+    {
+        if (numsamps < (0.007f * leaf.sampleRate))
+        {
+            tRamp_setDest(&p->gain, 0.f);
+            p->active = -1;
+        }
+    }
+    else if (p->mode == PlayLoop )
+    {
+        if (idx <= start)
+        {
+            p->idx += (float)(p->len);
+        }
+        else if (idx >= end)
+        {
+            p->idx -= (float)(p->len);
+        }
+    }
+    else // == PlayBackAndForth
+    {
+        if (p->idx < start)
+        {
+            p->bnf = -p->bnf;
+            p->idx = start;
+        }
+        else if (p->idx > end)
+        {
+            p->bnf = -p->bnf;
+            p->idx = end;
+        }
+    }
+
+    g1 = 1.f - g2;
+    
+    sample = sample * g1 + cfxsample * g2;
+    
+    sample = sample * tRamp_tick(&p->gain);
+    
+    if (p->active < 0)
+    {
+        if (tRamp_sample(&p->gain) <= 0.00001f)
+        {
+            if (p->retrigger == 1)
+            {
+                p->active = 1;
+                p->retrigger = 0;
+                tRamp_setDest(&p->gain, 1.f);
+                
+                if (p->dir > 0)
+                {
+                    if (p->flip > 0)    p->idx = p->start;
+                    else                p->idx = p->end;
+                }
+                else
+                {
+                    if (p->flip > 0)    p->idx = p->end;
+                    else                p->idx = p->start;
+                }
+            }
+            else
+            {
+                p->active = 0;
+            }
+            
+        }
+    }
+    
+    return sample;
+}
+
+void tSampler_setSample    (tSampler* const p, tBuffer* s)
+{
+    p->samp = s;
+}
+
+void tSampler_setMode      (tSampler* const p, PlayMode mode)
+{
+    p->mode = mode;
+}
+
+void tSampler_setCrossfadeLength  (tSampler* const p, uint32_t length)
+{
+    uint32_t cfxlen = LEAF_clip(0, length, 1000);
+    
+    //if (cfxlen > p->len)  cfxlen = p->len * 0.25f;
+    
+    p->cfxlen = cfxlen;
+}
+
+void tSampler_play         (tSampler* const p)
+{
+    if (p->active != 0)
+    {
+        p->active = -1;
+        p->retrigger = 1;
+        
+        tRamp_setDest(&p->gain, 0.f);
+    }
+    else
+    {
+        p->active = 1;
+        p->retrigger = 0;
+        
+        tRamp_setDest(&p->gain, 1.f);
+        
+        if (p->dir > 0)
+        {
+            if (p->flip > 0)    p->idx = p->start;
+            else                p->idx = p->end;
+        }
+        else
+        {
+            if (p->flip > 0)    p->idx = p->end;
+            else                p->idx = p->start;
+        }
+    }
+}
+
+void tSampler_stop         (tSampler* const p)
+{
+    p->active = -1;
+    
+    tRamp_setDest(&p->gain, 0.f);
+}
+
+static void handleStartEndChange(tSampler* const p)
+{
+    p->len = abs(p->end - p->start);
+    
+    //if (p->len < p->cfxlen) p->cfxlen = p->len * 0.9f;
+    
+    if (p->start > p->end)
+    {
+        p->flip = -1;
+    }
+    else
+    {
+        p->flip = 1;
+    }
+}
+
+void tSampler_setStart     (tSampler* const p, int32_t start)
+{
+    p->start = LEAF_clipInt(0, start, (p->samp->length - 1));
+    
+    handleStartEndChange(p);
+}
+
+void tSampler_setEnd       (tSampler* const p, int32_t end)
+{
+    p->end = LEAF_clipInt(0, end, (p->samp->length - 1));
+    
+    handleStartEndChange(p);
+}
+
+void tSampler_setRate      (tSampler* const p, float rate)
+{
+    if (rate < 0.f)
+    {
+        rate = -rate;
+        p->dir = -1;
+    }
+    else
+    {
+        p->dir = 1;
+    }
+    
+    p->inc = LEAF_clip(0.f, rate, 8.0f);
+    p->iinc = 1.f / p->inc;
+}
+
+
+//==============================================================================
--- a/LEAF/Src/leaf-string.c
+++ b/LEAF/Src/leaf-string.c
@@ -1,12 +1,10 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    leaf-string.cpp
+    leaf-string.c
     Created: 30 Nov 2018 10:41:42am
     Author:  airship
 
-  ==============================================================================
-*/
+==============================================================================*/
 
 #if _WIN32 || _WIN64
 
--- a/LEAF/Src/leaf-utilities.c
+++ b/LEAF/Src/leaf-utilities.c
@@ -1,12 +1,10 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    LEAFUtilities.c
+    leaf-utilities.c
     Created: 20 Jan 2017 12:02:17pm
     Author:  Michael R Mulshine
 
-  ==============================================================================
-*/
+==============================================================================*/
 
 
 #if _WIN32 || _WIN64
--- a/LEAF/Src/leaf-vocoder.c
+++ b/LEAF/Src/leaf-vocoder.c
@@ -1,12 +1,10 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    LEAFInstrument.c
+    leaf-vocoder.c
     Created: 20 Jan 2017 12:01:54pm
     Author:  Michael R Mulshine
 
-  ==============================================================================
-*/
+==============================================================================*/
 
 #if _WIN32 || _WIN64
 
--- a/LEAF/Src/leaf-wavefolder.c
+++ b/LEAF/Src/leaf-wavefolder.c
@@ -1,12 +1,10 @@
-/*
-  ==============================================================================
+/*==============================================================================
 
-    leaf-wavefolder.cpp
+    leaf-wavefolder.c
     Created: 30 Nov 2018 11:56:49am
     Author:  airship
 
-  ==============================================================================
-*/
+==============================================================================*/
 
 #if _WIN32 || _WIN64
 
--- a/LEAF/leaf.h
+++ b/LEAF/leaf.h
@@ -11,10 +11,10 @@
 #ifndef LEAF_H_INCLUDED
 #define LEAF_H_INCLUDED
 
-#define DEBUG 0
+#define LEAF_DEBUG 0
 
-#if DEBUG
-#include "../JuceLibraryCode/JuceHeader.h"
+#if LEAF_DEBUG
+#include "../LEAF_JUCEPlugin/JuceLibraryCode/JuceHeader.h"
 #endif
 
 #if _WIN32 || _WIN64
@@ -31,7 +31,9 @@
 #include ".\Inc\leaf-string.h"
 #include ".\Inc\leaf-pitch.h"
 #include ".\Inc\leaf-formant.h"
-#include ".\Inc\leaf-midi.h"
+#include ".\Inc\leaf-midi.h"
+#include ".\Inc\leaf-sample.h"
+#include ".\Inc\leaf-crusher.h"
 #include ".\Inc\leaf-wavefolder.h"
 #include ".\Inc\leaf-wavetables.h"
 #include ".\Inc\leaf-crusher.h"
@@ -50,7 +52,9 @@
 #include "./Inc/leaf-string.h"
 #include "./Inc/leaf-pitch.h"
 #include "./Inc/leaf-formant.h"
-#include "./Inc/leaf-midi.h"
+#include "./Inc/leaf-midi.h"
+#include "./Inc/leaf-sample.h"
+#include "./Inc/leaf-crusher.h"
 #include "./Inc/leaf-wavefolder.h"
 #include "./Inc/leaf-wavetables.h"
 #include "./Inc/leaf-crusher.h"
--- a/LEAF_JUCEPlugin/LEAF.jucer
+++ b/LEAF_JUCEPlugin/LEAF.jucer
@@ -39,6 +39,8 @@
           <FILE id="OS2D83" name="leaf-utilities.h" compile="0" resource="0"
                 file="../LEAF/Inc/leaf-utilities.h"/>
           <FILE id="Szb5LP" name="leaf-vocoder.h" compile="0" resource="0" file="../LEAF/Inc/leaf-vocoder.h"/>
+          <FILE id="T6KXi7" name="leaf-sample.h" compile="0" resource="0" file="../LEAF/Inc/leaf-sample.h"/>
+          <FILE id="bpUZCA" name="leaf-crusher.h" compile="0" resource="0" file="../LEAF/Inc/leaf-crusher.h"/>
           <FILE id="PRkOp2" name="leaf-wavefolder.h" compile="0" resource="0"
                 file="../LEAF/Inc/leaf-wavefolder.h"/>
           <FILE id="KpGzKv" name="leaf-wavetables.h" compile="0" resource="0"
@@ -60,6 +62,8 @@
           <FILE id="uKHzgz" name="leaf-utilities.c" compile="1" resource="0"
                 file="../LEAF/Src/leaf-utilities.c"/>
           <FILE id="u1aLLR" name="leaf-vocoder.c" compile="1" resource="0" file="../LEAF/Src/leaf-vocoder.c"/>
+          <FILE id="nmtoFJ" name="leaf-sample.c" compile="1" resource="0" file="../LEAF/Src/leaf-sample.c"/>
+          <FILE id="Oymcac" name="leaf-crusher.c" compile="1" resource="0" file="../LEAF/Src/leaf-crusher.c"/>
           <FILE id="LVoaGm" name="leaf-wavefolder.c" compile="1" resource="0"
                 file="../LEAF/Src/leaf-wavefolder.c"/>
           <FILE id="HRk07h" name="leaf-wavetables.c" compile="1" resource="0"
--- a/LEAF_JUCEPlugin/Source/LEAFLink.cpp
+++ b/LEAF_JUCEPlugin/Source/LEAFLink.cpp
@@ -15,17 +15,14 @@
 
 std::vector<juce::String> cButtonNames =  std::vector<juce::String>
 {
-    
+
 };
 
 std::vector<juce::String> cSliderNames =  std::vector<juce::String>
 {
-    "mix",
-    "predelay",
-    "input filter",
-    "feedback filter",
-    "feedback gain",
-    "size"
+    "delay",
+    "feedback",
+    "mix"
 };
 
 std::vector<juce::String> cComboBoxNames =  std::vector<juce::String>
@@ -140,7 +137,7 @@
     return value;
 }
 
-float randomNumberGenerator(void)
+float getRandomFloat(void)
 {
     return ((float)rand()/RAND_MAX);
 }
--- a/LEAF_JUCEPlugin/Source/LEAFLink.h
+++ b/LEAF_JUCEPlugin/Source/LEAFLink.h
@@ -47,6 +47,6 @@
 void setSliderModelValue(String name, float val);
 void setSliderValue(String name, float val);
 float getSliderValue(String name);
-float randomNumberGenerator(void);
+float getRandomFloat(void);
 
 #endif  // UTILITIES_H_INCLUDED
--- a/LEAF_JUCEPlugin/Source/MyTest.cpp
+++ b/LEAF_JUCEPlugin/Source/MyTest.cpp
@@ -14,92 +14,105 @@
 
 static void leaf_pool_report(void);
 static void leaf_pool_dump(void);
-static void run_pool_test(void);
-
-tDattorro reverb;
-
-
-tTapeDelay delay;
-
-float size;
-tRamp dtime;
-
+static void run_pool_test(void);
 
+float mix = 0.f;
+float fx = 1.f;
+
+#define NUM_GRAINS 20
+
+tBuffer buff;
+tSampler samp[NUM_GRAINS];
+
+tTapeDelay delay;
+
+float feedback = 0.f;
+
+
 void    LEAFTest_init            (float sampleRate, int blockSize)
 {
-    LEAF_init(sampleRate, blockSize, &randomNumberGenerator);
+    LEAF_init(sampleRate, blockSize, &getRandomFloat);
+    
+    // Init and set record loop
+    tBuffer_init (&buff, leaf.sampleRate * 1.f); // 0.5-second buffers
+    tBuffer_setRecordMode (&buff, RecordLoop);
+    tBuffer_record(&buff);
+    
+    for (int i = 0; i < NUM_GRAINS; i++)
+    {
+        // Init and set play loop
+        tSampler_init (&samp[i], &buff);
+        tSampler_setMode (&samp[i], PlayLoop);
 
-    tDattorro_init(&reverb);
-
-    //tTapeDelay_init(&delay, 0.5f * leaf.sampleRate, leaf.sampleRate);
-    
-    tRamp_init(&dtime, 500.0f, 1);
-    
-
-    setSliderValue("mix", reverb.mix);
-    setSliderValue("predelay", reverb.predelay / 200.0f);
-    setSliderValue("input filter", reverb.input_filter / 20000.0f);
-    setSliderValue("feedback filter", reverb.feedback_filter / 20000.0f);
-    setSliderValue("feedback gain", reverb.feedback_gain);
-    setSliderValue("size", reverb.size / 4.0f);
-    
-    
+        /*
+        float speed = ((getRandomFloat() < 0.5f) ? 0.5f : 1.f);
+        float dir = (getRandomFloat() < 0.5f) ? -1 : 1;
+        
+        tSampler_setRate(&samp[i], speed * dir);
+         */
+        
+        tSampler_setRate(&samp[i], 1.f);
+        
+        // Record and play
+        tSampler_play(&samp[i]);
+    }
+    
+    tTapeDelay_init(&delay, leaf.sampleRate * 0.05f, leaf.sampleRate * 1.f); // 1 second delay, starts out at 50 ms
+    
     leaf_pool_report();
 }
 
 int timer = 0;
-
-
-#define CLICK 0
 
+float lastOut;
+
 float   LEAFTest_tick            (float input)
-{
-#if CLICK
-    input = 0.0f;
-    
-    timer++;
-    if (timer == (1 * leaf.sampleRate))
-    {
-        timer = 0;
-        
-        input = 1.0f;
-    }
-#endif
-    //tTapeDelay_setDelay(&delay, tRamp_tick(&dtime));
-    
-    //return tTapeDelay_tick(&delay, input);
-    
-    
-    tDattorro_setSize(&reverb, tRamp_tick(&dtime));
-    
-    return tDattorro_tick(&reverb, input);
-    
+{
+    float sample = 0.f;
+    
+    tBuffer_tick(&buff, input);
+    
+    for (int i = 0; i < NUM_GRAINS; i++)
+    {
+        sample += tSampler_tick(&samp[i]);
+    }
+    
+    sample /= NUM_GRAINS;
+    
+    sample = tTapeDelay_tick(&delay, (1.f - feedback) * sample + feedback * lastOut);
+    
+    lastOut = sample;
+
+    return  (sample * mix) +
+            (input * (1.f - mix));
 }
 
+bool lastState = false, lastPlayState = false;
 void    LEAFTest_block           (void)
-{
-  
-    float val = getSliderValue("mix");
-    tDattorro_setMix(&reverb, val);
+{
+    float val = getSliderValue("mix");
+    
+    mix = val;
+    
+    val = getSliderValue("delay");
+    
+    tTapeDelay_setDelay(&delay, val * leaf.sampleRate);
+    
+    val = getSliderValue("feedback");
+    
+    feedback = val;
     
-    val = getSliderValue("predelay");
-    tDattorro_setInputDelay(&reverb, val * 200.0f);
-    
-    val = getSliderValue("input filter");
-    tDattorro_setInputFilter(&reverb, val * 20000.0f);
-    
-    val = getSliderValue("feedback filter");
-    tDattorro_setFeedbackFilter(&reverb, val * 20000.0f);
-    
-    val = getSliderValue("feedback gain");
-    tDattorro_setFeedbackGain(&reverb, val);
-    
-    val = getSliderValue("size");
-    tRamp_setDest(&dtime, val * reverb.size_max);
-    
-    
-    //float val = getSliderValue("size");
-    //tRamp_setDest(&dtime, val * leaf.sampleRate + 1);
+    for (int i = 0; i < NUM_GRAINS; i++)
+    {
+        if (getRandomFloat() < 0.01f)
+        {
+            tSampler_setStart(&samp[i], leaf.sampleRate * 0.05f + leaf.sampleRate * getRandomFloat() * 0.95f);
+            
+            uint64_t end = (leaf.sampleRate * 0.05f + getRandomFloat() * leaf.sampleRate * 0.45f + samp[i].start);
+            
+            tSampler_setEnd(&samp[i],  end % buff.length); // 10 - 1010 ms
+        }
+    }
     
 }
 
@@ -176,8 +189,6 @@
     {
         buffer[i] = (float)(i*2);
     }
-    
-    DBG("FREE BUFFER 2");
     leaf_free(buffer);
     
     leaf_pool_report();
--- a/LEAF_JUCEPlugin/Source/UIComponent.cpp
+++ b/LEAF_JUCEPlugin/Source/UIComponent.cpp
@@ -144,9 +144,9 @@
     setSliderValue(s->getName(), s->getValue());
 }
 
-void UIComponent::buttonClicked (Button* b)
+void UIComponent::buttonStateChanged (Button* b)
 {
-    setButtonState(b->getName(), true);
+    setButtonState(b->getName(), b->getState());
 }
 
 void UIComponent::comboBoxChanged (ComboBox* cb)
--- a/LEAF_JUCEPlugin/Source/UIComponent.h
+++ b/LEAF_JUCEPlugin/Source/UIComponent.h
@@ -35,7 +35,8 @@
     
     void sliderValueChanged(Slider* s) override;
     
-    void buttonClicked (Button* b) override;
+    void buttonClicked(Button*b) override {};
+    void buttonStateChanged(Button* b) override;
     
     void textEditorTextChanged (TextEditor&) override;