shithub: leaf

Download patch

ref: 8329ace1da902a9cecb0b33f94ccd7574073ff1d
parent: 479c76dacf9488757e5a9734376f0b8068bdca93
author: Matthew Wang <mjw7@princeton.edu>
date: Fri Jul 2 10:34:27 EDT 2021

removed tWaveOsc and tWaveOscS; removed unneeded arguments from tWaveSynth and tWaveSynthS; renamed tWaveSynth and tWaveSynthS to tWaveOsc and tWaveOscS

--- a/TestPlugin/Source/MyTest.cpp
+++ b/TestPlugin/Source/MyTest.cpp
@@ -33,12 +33,12 @@
 
 tWaveTable wt;
 tWaveTableS cwt;
-tWaveSynth ws;
+tWaveOsc ws;
 
 tBuffer samp;
 tMBSampler sampler;
 
-const int numWavetables = 1;
+const int numWavetables = 4;
 tWaveTable wavetables[numWavetables];
 tSimpleRetune retune;
 
@@ -80,13 +80,12 @@
     tPhasor_init(&phasor, &leaf);
     tPhasor_setFreq(&phasor, 220.f);
     
-    float* set[4];
-    set[0] = (float*)__leaf_table_sinewave;
-    set[1] = (float*)__leaf_table_triangle[0];
-    set[2] = (float*)__leaf_table_squarewave[0];
-    set[3] = (float*)__leaf_table_sawtooth[0];
+    tWaveTable_init(&wavetables[0], (float*)__leaf_table_sinewave, 2048, 20000.f, &leaf);
+    tWaveTable_init(&wavetables[1], (float*)__leaf_table_triangle, 2048, 20000.f, &leaf);
+    tWaveTable_init(&wavetables[2], (float*)__leaf_table_squarewave, 2048, 20000.f, &leaf);
+    tWaveTable_init(&wavetables[3], (float*)__leaf_table_sawtooth, 2048, 20000.f, &leaf);
     
-//    tWaveSynth_init(&ws, set, 2048, 4, 10000.f, &leaf);
+    tWaveOsc_init(&ws, wavetables, numWavetables, &leaf);
     
     lastLoadedAudioSize = 0;
     loadedAudio.clear();
@@ -103,14 +102,10 @@
 
 float   LEAFTest_tick            (float input)
 {
-    tSimpleRetune_tuneVoice(&retune, 0, mtof(roundf(ftom(tSimpleRetune_getInputFrequency(&retune)))));
-    return tSimpleRetune_tick(&retune, input);
-    
-    
     float out = 0.0f;
-    for (int i = 0; i < fmin(loadedAudio.size(), numWavetables); ++i)
+    for (int i = 0; i < numWavetables; ++i)
     {
-//        out += tWaveTable_tick(&wavetables[i]);
+        out += tWaveOsc_tick(&ws);
     }
     return out;
 }
@@ -125,12 +120,12 @@
     tMBSaw_setFreq(&bsaw, val * 10000.f);
 //    tWaveTable_setFreq(&wt, val * 160000.f - 80000.0f);
 //    tWaveTableS_setFreq(&cwt, val * 10000.);
-    tWaveSynth_setFreq(&ws, val * 10000.f);
+    tWaveOsc_setFreq(&ws, val * 2000.f);
 //    tRetune_tuneVoice(&retune, 0, val * 3.0f + 0.5f);
 //    tSimpleRetune_tuneVoice(&sretune, 0, 300);
 
     val = getSliderValue("slider2");
-    tWaveSynth_setIndex(&ws, val);
+    tWaveOsc_setIndex(&ws, val);
 //    tRetune_setPitchFactor(&retune, val * 3.0f + 0.5f, 1);
     
     val = getSliderValue("slider3");
--- a/leaf/Inc/leaf-oscillators.h
+++ b/leaf/Inc/leaf-oscillators.h
@@ -1005,72 +1005,24 @@
                                   float maxFreq, tMempool* const mempool);
     void    tWaveTable_free(tWaveTable* const osc);
     void    tWaveTable_setSampleRate (tWaveTable* const osc, float sr);
-   
-    //==============================================================================
     
-    /*!
-     @defgroup twavetableosc tWaveOsc
-     @ingroup oscillators
-     @brief Anti-aliased wavetable oscillator.
-     @{
-     
-     @fn float   tWaveTable_tick         (tWaveTable* const osc)
-     @brief Tick a tWaveTable oscillator.
-     @param osc A pointer to the relevant tWaveTable.
-     @return The ticked sample as a float from -1 to 1.
-     
-     @fn void    tWaveTable_setFreq      (tWaveTable* const osc, float freq)
-     @brief Set the frequency of a tWaveTable oscillator.
-     @param osc A pointer to the relevant tWaveTable.
-     @param freq The frequency to set the oscillator to.
-     
-     @} */
-    
-    typedef struct _tWaveOsc
-    {
-        tMempool mempool;
-        tWaveTable table;
-        float inc, freq;
-        float phase;
-        float phaseOffset;
-        float invSampleRate;
-        
-        int oct;
-        float w;
-        float aa;
-    } _tWaveOsc;
-    
-    typedef _tWaveOsc* tWaveOsc;
-    
-    void    tWaveOsc_init(tWaveOsc* const osc, tWaveTable* const table, LEAF* const leaf);
-    void    tWaveOsc_initToPool(tWaveOsc* const osc, tWaveTable* const table, tMempool* const mempool);
-    void    tWaveOsc_free(tWaveOsc* const osc);
-    
-    float   tWaveOsc_tick(tWaveOsc* const osc);
-    void    tWaveOsc_setFreq(tWaveOsc* const osc, float freq);
-    void    tWaveOsc_setAntiAliasing(tWaveOsc* const osc, float aa);
-    void    tWaveOsc_setPhaseOffset(tWaveOsc* const osc, float phase);
-    void    tWaveOsc_setSampleRate (tWaveOsc* const osc, float sr);
-    
     //==============================================================================
     
     /*!
-     @defgroup twavesynth tWaveSynth
+     @defgroup twaveosc tWaveOsc
      @ingroup oscillators
      @brief Set of anti-aliased wavetable oscillators that can be faded between.
      @{
      
-     @fn void    tWaveSynth_init(tWaveSynth* const osc, const float** tables, int n, int size, float maxFreq, LEAF* const leaf)
-     @brief Initialize a tWaveSynth to the default mempool of a LEAF instance.
-     @param osc A pointer to the tWaveSynth to initialize.
+     @fn void    tWaveOsc_init(tWaveOsc* const osc, const float** tables, int n, int size, float maxFreq, LEAF* const leaf)
+     @brief Initialize a tWaveOsc to the default mempool of a LEAF instance.
+     @param osc A pointer to the tWaveOsc to initialize.
      @param tables An array of pointers to wavetable data.
      @param n The number of wavetables.
-     @param size The number of samples in each of the wavetables.
-     @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed.
      @param leaf A pointer to the leaf instance.
      
-     @fn void  tWaveSynth_initToPool(tWaveSynth* const osc, const float** tables, int n, int size, float maxFreq, tMempool* const mempool)
-     @brief Initialize a tWaveSynth to a specified mempool.
+     @fn void  tWaveOsc_initToPool(tWaveOsc* const osc, const float** tables, int n, int size, float maxFreq, tMempool* const mempool)
+     @brief Initialize a tWaveOsc to a specified mempool.
      @param osc A pointer to the tWaveTable to initialize.
      @param tables An array of pointers to wavetable data.
      @param n The number of wavetables.
@@ -1078,27 +1030,27 @@
      @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed.
      @param mempool A pointer to the tMempool to use.
      
-     @fn void    tWaveSynth_free         (tWaveSynth* const osc)
-     @brief Free a tWaveSynth from its mempool.
-     @param osc A pointer to the tWaveSynth to free.
+     @fn void    tWaveOsc_free         (tWaveOsc* const osc)
+     @brief Free a tWaveOsc from its mempool.
+     @param osc A pointer to the tWaveOsc to free.
      
-     @fn float   tWaveSynth_tick         (tWaveSynth* const osc)
-     @brief Tick a tWaveSynth oscillator.
-     @param osc A pointer to the relevant tWaveSynth.
+     @fn float   tWaveOsc_tick         (tWaveOsc* const osc)
+     @brief Tick a tWaveOsc oscillator.
+     @param osc A pointer to the relevant tWaveOsc.
      @return The ticked sample as a float from -1 to 1.
      
-     @fn void    tWaveSynth_setFreq      (tWaveSynth* const osc, float freq)
-     @brief Set the frequency of a tWaveSynth oscillator.
-     @param osc A pointer to the relevant tWaveSynth.
+     @fn void    tWaveOsc_setFreq      (tWaveOsc* const osc, float freq)
+     @brief Set the frequency of a tWaveOsc oscillator.
+     @param osc A pointer to the relevant tWaveOsc.
      @param freq The frequency to set the oscillator to.
      
-     @fn void    tWaveSynth_setIndex(tWaveSynth* const osc, float index)
+     @fn void    tWaveOsc_setIndex(tWaveOsc* const osc, float index)
      @brief Set the output index of the wavetable set.
      @param index The new index from 0.0 to 1.0 as a smooth fade from the first wavetable in the set to the last.
      
      @} */
     
-    typedef struct _tWaveSynth
+    typedef struct _tWaveOsc
        {
            tMempool mempool;
            tWaveTable* tables;
@@ -1123,25 +1075,21 @@
            float aa;
            int numSubTables;
 
-       } _tWaveSynth;
+       } _tWaveOsc;
     
-    typedef _tWaveSynth* tWaveSynth;
+    typedef _tWaveOsc* tWaveOsc;
     
-    void tWaveSynth_init(tWaveSynth* const cy, tWaveTable* tables, int size,
-                                int numTables, float maxFreq, LEAF* const leaf);
-
-    void tWaveSynth_initToPool(tWaveSynth* const cy, tWaveTable* tables, int size,
-                                      int numTables, float maxFreq, tMempool* const mp);
-    void    tWaveSynth_free(tWaveSynth* const osc);
+    void tWaveOsc_init(tWaveOsc* const cy, tWaveTable* tables, int numTables, LEAF* const leaf);
+    void tWaveOsc_initToPool(tWaveOsc* const cy, tWaveTable* tables, int numTables, tMempool* const mp);
+    void    tWaveOsc_free(tWaveOsc* const osc);
     
-    float   tWaveSynth_tick(tWaveSynth* const osc);
+    float   tWaveOsc_tick(tWaveOsc* const osc);
+    void 	tWaveOsc_setFreq(tWaveOsc* const cy, float freq);
+    void    tWaveOsc_setAntiAliasing(tWaveOsc* const osc, float aa);
+    void    tWaveOsc_setIndex(tWaveOsc* const osc, float index);
+    void 	tWaveOsc_setTables(tWaveOsc* const cy, tWaveTable* tables, int numTables);
+    void    tWaveOsc_setSampleRate (tWaveOsc* const osc, float sr);
 
-    void 	tWaveSynth_setFreq(tWaveSynth* const cy, float freq);
-    void    tWaveSynth_setAntiAliasing(tWaveSynth* const osc, float aa);
-    void    tWaveSynth_setIndex(tWaveSynth* const osc, float index);
-    void 	tWaveSynth_setTables(tWaveSynth* const cy, tWaveTable* tables, int numTables, int size);
-    void    tWaveSynth_setSampleRate (tWaveSynth* const osc, float sr);
-
     //==============================================================================
     
     /*!
@@ -1196,168 +1144,51 @@
     void    tWaveTableS_free(tWaveTableS* const osc);
     void    tWaveTableS_setSampleRate (tWaveTableS* const osc, float sr);
     
+
+    //==============================================================================
     /*!
      @defgroup twaveoscs tWaveOscS
      @ingroup oscillators
-     @brief A more space-efficient anti-aliased wavetable oscillator than tWaveOsc but with slightly worse fidelity.
+     @brief Set of anti-aliased wavetable oscillators that can be faded between.
      @{
      
-     @fn void   tWaveOscS_init  (tWaveOscS* const osc, float* table, int size, float maxFreq, LEAF* const leaf)
+     @fn void    tWaveOscS_init(tWaveOsc* const osc, const float** tables, int n, int size, float maxFreq, LEAF* const leaf)
      @brief Initialize a tWaveOscS to the default mempool of a LEAF instance.
      @param osc A pointer to the tWaveOscS to initialize.
-     @param table A pointer to the wavetable data.
-     @param size The number of samples in the wavetable.
-     @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed.
+     @param tables An array of pointers to wavetable data.
+     @param n The number of wavetables.
      @param leaf A pointer to the leaf instance.
      
-     @fn void   tWaveOscS_initToPool   (tWaveOscS* const osc, float* table, int size, float maxFreq, tMempool* const mempool)
+     @fn void  tWaveOscS_initToPool(tWaveOsc* const osc, const float** tables, int n, int size, float maxFreq, tMempool* const mempool)
      @brief Initialize a tWaveOscS to a specified mempool.
-     @param osc A pointer to the tWaveOscS to initialize.
-     @param table A pointer to the wavetable data.
-     @param size The number of samples in the wave table.
+     @param osc A pointer to the tWaveTableS to initialize.
+     @param tables An array of pointers to wavetable data.
+     @param n The number of wavetables.
+     @param size The number of samples in each of the wavetables.
      @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed.
      @param mempool A pointer to the tMempool to use.
      
-     @fn void   tWaveOscS_free         (tWaveOscS* const osc)
+     @fn void    tWaveOscS_free         (tWaveOsc* const osc)
      @brief Free a tWaveOscS from its mempool.
      @param osc A pointer to the tWaveOscS to free.
      
-     @fn float  tWaveOscS_tick         (tWaveOscS* const osc)
+     @fn float   tWaveOscS_tick         (tWaveOsc* const osc)
      @brief Tick a tWaveOscS oscillator.
      @param osc A pointer to the relevant tWaveOscS.
      @return The ticked sample as a float from -1 to 1.
      
-     @fn void   tWaveOscS_setFreq      (tWaveOscS* const osc, float freq)
+     @fn void    tWaveOscS_setFreq      (tWaveOsc* const osc, float freq)
      @brief Set the frequency of a tWaveOscS oscillator.
      @param osc A pointer to the relevant tWaveOscS.
      @param freq The frequency to set the oscillator to.
      
-     @} */
-    
-    typedef struct _tWaveOscS
-    {
-        tMempool mempool;
-        tWaveTableS table;
-        float inc, freq;
-        float phase;
-        float phaseOffset;
-        float invSampleRate;
-        int oct;
-        float w;
-        float aa;
-    } _tWaveOscS;
-    
-    typedef _tWaveOscS* tWaveOscS;
-    
-    void    tWaveOscS_init(tWaveOscS* const osc, tWaveTableS* const table, LEAF* const leaf);
-    void    tWaveOscS_initToPool(tWaveOscS* const osc, tWaveTableS* const table, tMempool* const mempool);
-    void    tWaveOscS_free(tWaveOscS* const osc);
-    
-    float   tWaveOscS_tick(tWaveOscS* const osc);
-    void    tWaveOscS_setFreq(tWaveOscS* const osc, float freq);
-    void    tWaveOscS_setAntiAliasing(tWaveOscS* const osc, float aa);
-    void    tWaveOscS_setPhaseOffset(tWaveOscS* const osc, float phase);
-    void    tWaveOscS_setSampleRate (tWaveOscS* const osc, float sr);
-    
-    //==============================================================================
-    /*!
-     @defgroup twaveoscs tWaveOscS
-     @ingroup oscillators
-     @brief A more space-efficient anti-aliased wavetable oscillator than tWaveOsc but with slightly worse fidelity.
-     @{
-
-     @fn void   tWaveOscS_init  (tWaveOscS* const osc, float* table, int size, float maxFreq, LEAF* const leaf)
-     @brief Initialize a tWaveOscS to the default mempool of a LEAF instance.
-     @param osc A pointer to the tWaveOscS to initialize.
-     @param table A pointer to the wavetable data.
-     @param size The number of samples in the wavetable.
-     @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed.
-     @param leaf A pointer to the leaf instance.
-
-     @fn void   tWaveOscS_initToPool   (tWaveOscS* const osc, float* table, int size, float maxFreq, tMempool* const mempool)
-     @brief Initialize a tWaveOscS to a specified mempool.
-     @param osc A pointer to the tWaveOscS to initialize.
-     @param table A pointer to the wavetable data.
-     @param size The number of samples in the wave table.
-     @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed.
-     @param mempool A pointer to the tMempool to use.
-
-     @fn void   tWaveOscS_free         (tWaveOscS* const osc)
-     @brief Free a tWaveOscS from its mempool.
-     @param osc A pointer to the tWaveOscS to free.
-
-     @fn float  tWaveOscS_tick         (tWaveOscS* const osc)
-     @brief Tick a tWaveOscS oscillator.
-     @param osc A pointer to the relevant tWaveOscS.
-     @return The ticked sample as a float from -1 to 1.
-
-     @fn void   tWaveOscS_setFreq      (tWaveOscS* const osc, float freq)
-     @brief Set the frequency of a tWaveOscS oscillator.
-     @param osc A pointer to the relevant tWaveOscS.
-     @param freq The frequency to set the oscillator to.
-
-     @} */
-    
-    typedef struct _tWaveSubOscS
-    {
-        tMempool mempool;
-        tWaveTableS table;
-
-    } _tWaveSubOscS;
-
-    typedef _tWaveSubOscS* tWaveSubOscS;
-
-    void    tWaveSubOscS_init(tWaveSubOscS* const osc, tWaveTableS* const table, LEAF* const leaf);
-    void    tWaveSubOscS_initToPool(tWaveSubOscS* const osc, tWaveTableS* const table, tMempool* const mempool);
-    void    tWaveSubOscS_free(tWaveSubOscS* const osc);
-    float 	tWaveSubOscS_tick(tWaveSubOscS* const cy, float phase, int oct, float w);
-
-    //==============================================================================
-    /*!
-     @defgroup twavesynths tWaveSynthS
-     @ingroup oscillators
-     @brief Set of anti-aliased wavetable oscillators that can be faded between.
-     @{
-     
-     @fn void    tWaveSynthS_init(tWaveSynth* const osc, const float** tables, int n, int size, float maxFreq, LEAF* const leaf)
-     @brief Initialize a tWaveSynthS to the default mempool of a LEAF instance.
-     @param osc A pointer to the tWaveSynthS to initialize.
-     @param tables An array of pointers to wavetable data.
-     @param n The number of wavetables.
-     @param size The number of samples in each of the wavetables.
-     @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed.
-     @param leaf A pointer to the leaf instance.
-     
-     @fn void  tWaveSynthS_initToPool(tWaveSynth* const osc, const float** tables, int n, int size, float maxFreq, tMempool* const mempool)
-     @brief Initialize a tWaveSynthS to a specified mempool.
-     @param osc A pointer to the tWaveTableS to initialize.
-     @param tables An array of pointers to wavetable data.
-     @param n The number of wavetables.
-     @param size The number of samples in each of the wavetables.
-     @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed.
-     @param mempool A pointer to the tMempool to use.
-     
-     @fn void    tWaveSynthS_free         (tWaveSynth* const osc)
-     @brief Free a tWaveSynthS from its mempool.
-     @param osc A pointer to the tWaveSynthS to free.
-     
-     @fn float   tWaveSynthS_tick         (tWaveSynth* const osc)
-     @brief Tick a tWaveSynthS oscillator.
-     @param osc A pointer to the relevant tWaveSynthS.
-     @return The ticked sample as a float from -1 to 1.
-     
-     @fn void    tWaveSynthS_setFreq      (tWaveSynth* const osc, float freq)
-     @brief Set the frequency of a tWaveSynthS oscillator.
-     @param osc A pointer to the relevant tWaveSynthS.
-     @param freq The frequency to set the oscillator to.
-     
-     @fn void    tWaveSynthS_setIndex(tWaveSynth* const osc, float index)
+     @fn void    tWaveOscS_setIndex(tWaveOsc* const osc, float index)
      @brief Set the output index of the wavetable set.
      @param index The new index from 0.0 to 1.0 as a smooth fade from the first wavetable in the set to the last.
      
      @} */
     
-    typedef struct _tWaveSynthS
+    typedef struct _tWaveOscS
     {
         tMempool mempool;
         
@@ -1365,7 +1196,6 @@
 
         tWaveTableS* tables;
 
-        tWaveSubOscS* oscs;
         int numTables;
         float index;
         float maxFreq;
@@ -1387,22 +1217,20 @@
         float aa;
         int numSubTables;
 
-    } _tWaveSynthS;
+    } _tWaveOscS;
     
-    typedef _tWaveSynthS* tWaveSynthS;
+    typedef _tWaveOscS* tWaveOscS;
     
-    void 	tWaveSynthS_init(tWaveSynthS* const cy, tWaveTableS* tables, int size,
-                                int numTables, float maxFreq, LEAF* const leaf);
-    void    tWaveSynthS_initToPool(tWaveSynthS* const osc, tWaveTableS* tables, int size,
-                                         int numTables, float maxFreq, tMempool* const mempool);
-    void    tWaveSynthS_free(tWaveSynthS* const osc);
+    void 	tWaveOscS_init(tWaveOscS* const cy, tWaveTableS* tables, int numTables, LEAF* const leaf);
+    void    tWaveOscS_initToPool(tWaveOscS* const osc, tWaveTableS* tables, int numTables, tMempool* const mempool);
+    void    tWaveOscS_free(tWaveOscS* const osc);
     
-    float   tWaveSynthS_tick(tWaveSynthS* const osc);
-    void    tWaveSynthS_setFreq(tWaveSynthS* const osc, float freq);
-    void    tWaveSynthS_setAntiAliasing(tWaveSynthS* const osc, float aa);
-    void    tWaveSynthS_setIndex(tWaveSynthS* const osc, float index);
-//    void    tWaveSynthS_setIndexTable(tWaveSynthS* const osc, int i, float* table, int size);
-    void    tWaveSynthS_setSampleRate (tWaveSynthS* const osc, float sr);
+    float   tWaveOscS_tick(tWaveOscS* const osc);
+    void    tWaveOscS_setFreq(tWaveOscS* const osc, float freq);
+    void    tWaveOscS_setAntiAliasing(tWaveOscS* const osc, float aa);
+    void    tWaveOscS_setIndex(tWaveOscS* const osc, float index);
+//    void    tWaveOscS_setIndexTable(tWaveOscS* const osc, int i, float* table, int size);
+    void    tWaveOscS_setSampleRate (tWaveOscS* const osc, float sr);
     
 #ifdef __cplusplus
 }
--- a/leaf/Inc/leaf-physical.h
+++ b/leaf/Inc/leaf-physical.h
@@ -604,7 +604,7 @@
     float   tLivingString2_tick                  (tLivingString2* const, float input);
     float   tLivingString2_tickEfficient                 (tLivingString2* const, float input);
 
-    float   tLivingString2_udpateDelays(tLivingString2* const pl); //necessary if using tickEfficient (so that parameter setting can be put in a slower process). included in standard tick.
+    void   tLivingString2_updateDelays(tLivingString2* const pl); //necessary if using tickEfficient (so that parameter setting can be put in a slower process). included in standard tick.
     float   tLivingString2_sample                (tLivingString2* const);
     void    tLivingString2_setFreq               (tLivingString2* const, float freq);
     void    tLivingString2_setWaveLength         (tLivingString2* const, float waveLength); // in samples
--- a/leaf/Src/leaf-oscillators.c
+++ b/leaf/Src/leaf-oscillators.c
@@ -1925,137 +1925,18 @@
     tButterworth_free(&c->bl);
 }
 
-//=======================================================================================
-//=======================================================================================
-
-void tWaveOsc_init(tWaveOsc* const cy, tWaveTable* const table, LEAF* const leaf)
-{
-    tWaveOsc_initToPool(cy, table, &leaf->mempool);
-}
-
-void tWaveOsc_initToPool(tWaveOsc* const cy, tWaveTable* const table, tMempool* const mp)
-{
-    _tMempool* m = *mp;
-    _tWaveOsc* c = *cy = (_tWaveOsc*) mpool_alloc(sizeof(_tWaveOsc), m);
-    c->mempool = m;
-    LEAF* leaf = c->mempool->leaf;
-    
-    c->table = *table;
-
-    c->inc = 0.0f;
-    c->phase = 0.0f;
-    c->phaseOffset = 0.0f;
-    c->aa = 0.5f;
-    
-    c->invSampleRate = leaf->invSampleRate;
-    
-    tWaveOsc_setFreq(cy, 220);
-}
-
-void tWaveOsc_free(tWaveOsc* const cy)
-{
-    _tWaveOsc* c = *cy;
-    mpool_free((char*)c, c->mempool);
-}
-
-float tWaveOsc_tick(tWaveOsc* const cy)
-{
-    _tWaveOsc* c = *cy;
-    
-    float temp;
-    int idx;
-    float frac;
-    float samp0;
-    float samp1;
-    
-    int size = c->table->size;
-    int sizeMask = c->table->sizeMask;
-    float** tables = c->table->tables;
-    
-    // Phasor increment
-    c->phase += c->inc;
-    if (c->phase + c->phaseOffset >= 1.0f) c->phase -= 1.0f;
-    if (c->phase + c->phaseOffset < 0.0f) c->phase += 1.0f;
-    
-    // Wavetable synthesis
-    temp = size * (c->phase + c->phaseOffset);
-    
-    idx = (int)temp;
-    frac = temp - (float)idx;
-    samp0 = tables[c->oct][idx];
-    idx = (idx + 1) & sizeMask;
-    if (++idx >= size) idx = 0;
-    samp1 = tables[c->oct][idx];
-    
-    float oct0 = (samp0 + (samp1 - samp0) * frac);
-    
-    idx = (int)temp;
-    samp0 = tables[c->oct+1][idx];
-    idx = (idx + 1) & sizeMask;
-    samp1 = tables[c->oct+1][idx];
-    
-    float oct1 = (samp0 + (samp1 - samp0) * frac);
-    
-    return oct0 + (oct1 - oct0) * c->w;
-}
-
-void tWaveOsc_setFreq(tWaveOsc* const cy, float freq)
-{
-    _tWaveOsc* c = *cy;
-    
-    c->freq  = freq;
-    
-    c->inc = c->freq * c->invSampleRate;
-    c->inc -= (int)c->inc;
-    
-    // abs for negative frequencies
-    c->w = fabsf(c->freq * c->table->invBaseFreq);
-    
-    // Probably ok to use a log2 approx here; won't effect tuning at all, just crossfading between octave tables
-    c->w = log2f_approx(c->w) + c->aa; // adding an offset here will shift our table selection upward, reducing aliasing but lower high freq fidelity. +1.0f should remove all aliasing
-    if (c->w < 0.0f) c->w = 0.0f; // If c->w is < 0.0f, then freq is less than our base freq
-    c->oct = (int)c->w;
-    c->w -= c->oct;
-    
-    // When out of range of our tables, this will prevent a crash.
-    // Also causes a blip but fine since we're above maxFreq at this point.
-    if (c->oct >= c->table->numTables - 1) c->oct = c->table->numTables - 2;
-}
-
-void tWaveOsc_setAntiAliasing(tWaveOsc* const cy, float aa)
-{
-    _tWaveOsc* c = *cy;
-    c->aa = aa;
-    tWaveOsc_setFreq(cy, c->freq);
-}
-
-void tWaveOsc_setPhaseOffset(tWaveOsc* const cy, float phase)
-{
-    _tWaveOsc* c = *cy;
-    c->phaseOffset = phase - (int)phase;
-}
-
-void tWaveOsc_setSampleRate(tWaveOsc* const cy, float sr)
-{
-    _tWaveOsc* c = *cy;
-    c->invSampleRate = 1.0f/sr;
-    tWaveOsc_setFreq(cy, c->freq);
-}
-
 //================================================================================================
 //================================================================================================
 
-void tWaveSynth_init(tWaveSynth* const cy, tWaveTable* tables, int size,
-                            int numTables, float maxFreq, LEAF* const leaf)
+void tWaveOsc_init(tWaveOsc* const cy, tWaveTable* tables, int numTables, LEAF* const leaf)
 {
-    tWaveSynth_initToPool(cy, tables, size, numTables, maxFreq, &leaf->mempool);
+    tWaveOsc_initToPool(cy, tables, numTables, &leaf->mempool);
 }
 
-void tWaveSynth_initToPool(tWaveSynth* const cy, tWaveTable* tables, int size,
-                                  int numTables, float maxFreq, tMempool* const mp)
+void tWaveOsc_initToPool(tWaveOsc* const cy, tWaveTable* tables, int numTables, tMempool* const mp)
 {
     _tMempool* m = *mp;
-    _tWaveSynth* c = *cy = (_tWaveSynth*) mpool_alloc(sizeof(_tWaveSynth), m);
+    _tWaveOsc* c = *cy = (_tWaveOsc*) mpool_alloc(sizeof(_tWaveOsc), m);
 
     c->mempool = m;
 
@@ -2070,29 +1951,28 @@
     c->phase = 0;
     c->inc = 0;
     c->oct = 0;
-    c->size = size;
+    c->size = c->tables[0]->size;
     c->w = 0.0f;
     c->aa = 0.5f;
     c->sampleRate = leaf->sampleRate;
     // Determine base frequency
-    c->baseFreq = c->sampleRate / (float) size;
+    c->baseFreq = c->sampleRate / (float) c->size;
     c->invBaseFreq = 1.0f / c->baseFreq;
     c->numSubTables = c->tables[0]->numTables;
 
     c->invSampleRateTimesTwoTo32 = leaf->invSampleRate * TWO_TO_32;
-    c->maxFreq = maxFreq;
+    c->maxFreq = c->tables[0]->maxFreq;
 }
 
-void tWaveSynth_free(tWaveSynth* const cy)
+void tWaveOsc_free(tWaveOsc* const cy)
 {
-    _tWaveSynth* c = *cy;
+    _tWaveOsc* c = *cy;
     mpool_free((char*)c, c->mempool);
 }
 
-
-float tWaveSynth_tick(tWaveSynth* const cy)
+float tWaveOsc_tick(tWaveOsc* const cy)
 {
-    _tWaveSynth* c = *cy;
+    _tWaveOsc* c = *cy;
     
     // Phasor increment (unsigned 32bit int wraps automatically with overflow so no need for if branch checks, as you need with float)
     c->phase += c->inc;
@@ -2159,9 +2039,9 @@
     return s1 + (s2 - s1) * c->mix;
 }
 
-void tWaveSynth_setFreq(tWaveSynth* const cy, float freq)
+void tWaveOsc_setFreq(tWaveOsc* const cy, float freq)
 {
-    _tWaveSynth* c = *cy;
+    _tWaveOsc* c = *cy;
 
     c->freq  = freq;
 
@@ -2179,15 +2059,15 @@
     if (c->oct >= c->numSubTables - 1) c->oct = c->numSubTables - 2;
 }
 
-void tWaveSynth_setAntiAliasing(tWaveSynth* const cy, float aa)
+void tWaveOsc_setAntiAliasing(tWaveOsc* const cy, float aa)
 {
-    _tWaveSynth* c = *cy;
+    _tWaveOsc* c = *cy;
     c->aa = aa;
 }
 
-void tWaveSynth_setIndex(tWaveSynth* const cy, float index)
+void tWaveOsc_setIndex(tWaveOsc* const cy, float index)
 {
-    _tWaveSynth* c = *cy;
+    _tWaveOsc* c = *cy;
     c->index = index;
     float f = c->index * (c->numTables - 1);
 
@@ -2197,17 +2077,17 @@
     c->mix = f - c->o1;
 }
 
-void tWaveSynth_setTables(tWaveSynth* const cy, tWaveTable* tables, int numTables, int size)
+void tWaveOsc_setTables(tWaveOsc* const cy, tWaveTable* tables, int numTables)
 {
-    _tWaveSynth* c = *cy;
+    _tWaveOsc* c = *cy;
     LEAF* leaf = c->mempool->leaf;
     c->tables =  tables;
     c->numTables = numTables;
-    c->size = size;
+    c->size = c->tables[0]->size;
 
     c->sampleRate = leaf->sampleRate;
     // Determine base frequency
-    c->baseFreq = c->sampleRate / (float) size;
+    c->baseFreq = c->sampleRate / (float) c->size;
     c->invBaseFreq = 1.0f / c->baseFreq;
     c->numSubTables = c->tables[0]->numTables;
 
@@ -2214,9 +2094,9 @@
 }
 
 /*//// eventually gotta finish this so you can X/Y control the indices and fade between non-adjacent tables
-void tWaveSynthS_setIndexXY(tWaveSynthS* const cy, float indexX, float indexY)
+void tWaveOscS_setIndexXY(tWaveOscS* const cy, float indexX, float indexY)
 {
-    _tWaveSynthS* c = *cy;
+    _tWaveOscS* c = *cy;
     c->index = index;
     float f1 = c->index * (c->numTables - 1);
 
@@ -2229,9 +2109,9 @@
 }
 */
 
-void tWaveSynth_setSampleRate(tWaveSynth* const cy, float sr)
+void tWaveOsc_setSampleRate(tWaveOsc* const cy, float sr)
 {
-    _tWaveSynth* c = *cy;
+    _tWaveOsc* c = *cy;
     //TODO: need to fix this -JS
     for (int i = 0; i < c->numTables; ++i)
     {
@@ -2407,215 +2287,22 @@
 //================================================================================================
 //================================================================================================
 
-void tWaveOscS_init(tWaveOscS* const cy, tWaveTableS* const table, LEAF* const leaf)
+void tWaveOscS_init(tWaveOscS* const cy, tWaveTableS* tables, int numTables, LEAF* const leaf)
 {
-    tWaveOscS_initToPool(cy, table, &leaf->mempool);
+    tWaveOscS_initToPool(cy, tables, numTables, &leaf->mempool);
 }
 
-void tWaveOscS_initToPool(tWaveOscS* const cy, tWaveTableS* const table, tMempool* const mp)
+void tWaveOscS_initToPool(tWaveOscS* const cy, tWaveTableS* tables, int numTables, tMempool* const mp)
 {
     _tMempool* m = *mp;
     _tWaveOscS* c = *cy = (_tWaveOscS*) mpool_alloc(sizeof(_tWaveOscS), m);
-    c->mempool = m;
-    LEAF* leaf = c->mempool->leaf;
-    
-    c->table = *table;
 
-    c->invSampleRate = leaf->invSampleRate;
-    c->inc = 0.0f;
-    c->phase = 0.0f;
-    c->phaseOffset = 0.0f;
-    c->aa = 0.5f;
-    
-    tWaveOscS_setFreq(cy, 220);
-}
-
-void tWaveOscS_free(tWaveOscS* const cy)
-{
-    _tWaveOscS* c = *cy;
-    mpool_free((char*)c, c->mempool);
-}
-
-float tWaveOscS_tick(tWaveOscS* const cy)
-{
-    _tWaveOscS* c = *cy;
-    
-    float temp;
-    int idx;
-    float frac;
-    float samp0;
-    float samp1;
-    
-    // Phasor increment
-    c->phase += c->inc;
-    if (c->phase >= 1.0f) c->phase -= 1.0f;
-    if (c->phase < 0.0f) c->phase += 1.0f;
-    
-    int* sizes = c->table->sizes;
-    int* sizeMasks = c->table->sizeMasks;
-    float** tables = c->table->tables;
-    
-    // Wavetable synthesis
-    temp = sizes[c->oct] * (c->phase + c->phaseOffset);
-    idx = (int)temp;
-    frac = temp - (float)idx;
-    samp0 = tables[c->oct][idx];
-    idx = (idx + 1) & sizeMasks[c->oct];
-    samp1 = tables[c->oct][idx];
-    
-    float oct0 = (samp0 + (samp1 - samp0) * frac);
-    
-    temp = sizes[c->oct+1] * (c->phase + c->phaseOffset);
-    idx = (int)temp;
-    frac = temp - (float)idx;
-    samp0 = tables[c->oct+1][idx];
-    idx = (idx + 1) & sizeMasks[c->oct + 1];
-    samp1 = tables[c->oct+1][idx];
-    
-    float oct1 = (samp0 + (samp1 - samp0) * frac);
-    
-    return oct0 + (oct1 - oct0) * c->w;
-}
-
-void tWaveOscS_setFreq(tWaveOscS* const cy, float freq)
-{
-    _tWaveOscS* c = *cy;
-
-    c->freq  = freq;
-    
-    c->inc = c->freq * c->invSampleRate;
-    c->inc -= (int)c->inc;
-    
-    // abs for negative frequencies
-    c->w = fabsf(c->freq * c->table->invBaseFreq);
-    
-    // Probably ok to use a log2 approx here; won't effect tuning at all, just crossfading between octave tables
-    // I bet we could turn this into a lookup and save a lot of processing
-    c->w = log2f_approx(c->w) + c->aa;//+ LEAF_SQRT2 - 1.0f; adding an offset here will shift our table selection upward, reducing aliasing but lower high freq fidelity. +1.0f should remove all aliasing
-    if (c->w < 0.0f) c->w = 0.0f; // If c->w is < 0.0f, then freq is less than our base freq
-    c->oct = (int)c->w;
-    c->w -= c->oct;
-    if (c->oct >= c->table->numTables - 1) c->oct = c->table->numTables - 2;
-}
-
-void tWaveOscS_setAntiAliasing(tWaveOscS* const cy, float aa)
-{
-    _tWaveOscS* c = *cy;
-    c->aa = aa;
-    tWaveOscS_setFreq(cy, c->freq);
-}
-
-void tWaveOscS_setPhaseOffset(tWaveOscS* const cy, float phase)
-{
-    _tWaveOscS* c = *cy;
-    c->phaseOffset = phase - (int)phase;
-}
-
-void tWaveOscS_setSampleRate(tWaveOscS* const cy, float sr)
-{
-    _tWaveOscS* c = *cy;
-    c->invSampleRate = 1.0f/sr;
-    tWaveOscS_setFreq(cy, c->freq);
-}
-
-//================================================================================================
-//================================================================================================
-
-
-
-
-
-void tWaveSubOscS_init(tWaveSubOscS* const cy, tWaveTableS* const table, LEAF* const leaf)
-{
-    tWaveSubOscS_initToPool(cy, table, &leaf->mempool);
-}
-
-void tWaveSubOscS_initToPool(tWaveSubOscS* const cy, tWaveTableS* const table, tMempool* const mp)
-{
-    _tMempool* m = *mp;
-    _tWaveSubOscS* c = *cy = (_tWaveSubOscS*) mpool_alloc(sizeof(_tWaveSubOscS), m);
     c->mempool = m;
 
-    c->table = *table;
-}
-
-void tWaveSubOscS_free(tWaveSubOscS* const cy)
-{
-    _tWaveSubOscS* c = *cy;
-    mpool_free((char*)c, c->mempool);
-}
-
-float tWaveSubOscS_tick(tWaveSubOscS* const cy, float phase, int oct, float w)
-{
-    _tWaveSubOscS* c = *cy;
-
-    float temp;
-    int idx;
-    float frac;
-    float samp0;
-    float samp1;
-
-    int* sizes = c->table->sizes;
-    int* sizeMasks = c->table->sizeMasks;
-    float** tables = c->table->tables;
-
-    // Wavetable synthesis
-    temp = sizes[oct] * phase;
-    idx = (int)temp;
-    frac = temp - (float)idx;
-    samp0 = tables[oct][idx];
-    idx = (idx + 1) & sizeMasks[oct];
-    samp1 = tables[oct][idx];
-
-    float oct0 = (samp0 + (samp1 - samp0) * frac);
-
-    temp = sizes[oct+1] * phase;
-    idx = (int)temp;
-    frac = temp - (float)idx;
-    samp0 = tables[oct+1][idx];
-    idx = (idx + 1) & sizeMasks[oct+1];
-    samp1 = tables[oct+1][idx];
-
-    float oct1 = (samp0 + (samp1 - samp0) * frac);
-
-    return oct0 + (oct1 - oct0) * w;
-}
-
-
-
-
-
-//================================================================================================
-//================================================================================================
-
-void tWaveSynthS_init(tWaveSynthS* const cy, tWaveTableS* tables, int size,
-                            int numTables, float maxFreq, LEAF* const leaf)
-{
-    tWaveSynthS_initToPool(cy, tables, size, numTables, maxFreq, &leaf->mempool);
-}
-
-void tWaveSynthS_initToPool(tWaveSynthS* const cy, tWaveTableS* tables, int size,
-                                  int numTables, float maxFreq, tMempool* const mp)
-{
-    _tMempool* m = *mp;
-    _tWaveSynthS* c = *cy = (_tWaveSynthS*) mpool_alloc(sizeof(_tWaveSynthS), m);
-
-    c->mempool = m;
-
     LEAF* leaf = c->mempool->leaf;
     c->tables =  tables;
     c->numTables = numTables;
     
-    //c->oscs = (tWaveSubOscS*) mpool_alloc(sizeof(tWaveSubOscS*) * c->numTables, m);
-
-//    int i = 0;
-    //for (int t = 0; t < numTables; ++t)
-    //{
-		//tWaveTableS_initToPool(&c->tables[i], table + (size*t), size, maxFreq, mp); //is the sizeoffloat necessary? is the pointer location in bytes or 32-bit words?
-		//tWaveSubOscS_initToPool(&c->oscs[i], tables[i], mp);
-		//i++;
-    //}
-    
     c->index = 0.0f;
     c->o1 = 0;
     c->o2 = 1;
@@ -2623,36 +2310,30 @@
     c->phase = 0;
     c->inc = 0;
     c->oct = 0;
-    c->size = size;
+    c->size = c->tables[0]->sizes[0];
     c->w = 0.0f;
     c->aa = 0.5f;
     c->sampleRate = leaf->sampleRate;
     // Determine base frequency
-    c->baseFreq = c->sampleRate / (float) size;
+    c->baseFreq = c->sampleRate / (float) c->size;
     c->invBaseFreq = 1.0f / c->baseFreq;
     c->numSubTables = c->tables[0]->numTables;
 
     c->invSampleRateTimesTwoTo32 = leaf->invSampleRate * TWO_TO_32;
-    c->maxFreq = maxFreq;
+    c->maxFreq = c->tables[0]->maxFreq;
 }
 
-void tWaveSynthS_free(tWaveSynthS* const cy)
+void tWaveOscS_free(tWaveOscS* const cy)
 {
-    _tWaveSynthS* c = *cy;
+    _tWaveOscS* c = *cy;
     
-    for (int i = 0; i < c->numTables; ++i)
-    {
-        //tWaveSubOscS_free(&c->oscs[i]);
-        //mpool_free((char*)c->oscs[i], c->mempool);
-    }
-    //mpool_free((char*)c->oscs, c->mempool);
     mpool_free((char*)c, c->mempool);
 }
 
 volatile int errorCounter = 0;
-float tWaveSynthS_tick(tWaveSynthS* const cy)
+float tWaveOscS_tick(tWaveOscS* const cy)
 {
-    _tWaveSynthS* c = *cy;
+    _tWaveOscS* c = *cy;
     
     // Phasor increment (unsigned 32bit int wraps automatically with overflow so no need for if branch checks, as you need with float)
     c->phase += c->inc;
@@ -2659,10 +2340,6 @@
     float floatPhase = (double)c->phase * 2.32830643654e-10;
     float s1 = 0.f, s2 = 0.f;
 
-    //s1 = tWaveSubOscS_tick(&c->oscs[c->o1], floatPhase, c->oct, c->w);
-    //s2 = tWaveSubOscS_tick(&c->oscs[c->o2], floatPhase, c->oct, c->w);
-
-
     float temp;
     int idx;
     float frac;
@@ -2671,7 +2348,6 @@
 
     int oct = c->oct;
 
-
     int* sizeMasks = c->tables[c->o1]->sizeMasks;
     float** tables = c->tables[c->o1]->tables;
 
@@ -2685,8 +2361,6 @@
 
     float oct0 = (samp0 + (samp1 - samp0) * frac);
 
-
-
     temp = sizeMasks[oct+1] * floatPhase;
     idx = (int)temp;
     frac = temp - (float)idx;
@@ -2698,7 +2372,6 @@
 
     s1 = oct0 + (oct1 - oct0) * c->w;
 
-
     sizeMasks = c->tables[c->o2]->sizeMasks;
     tables = c->tables[c->o2]->tables;
 
@@ -2727,9 +2400,9 @@
     return s1 + (s2 - s1) * c->mix;
 }
 
-void tWaveSynthS_setFreq(tWaveSynthS* const cy, float freq)
+void tWaveOscS_setFreq(tWaveOscS* const cy, float freq)
 {
-    _tWaveSynthS* c = *cy;
+    _tWaveOscS* c = *cy;
 
     c->freq  = freq;
 
@@ -2747,15 +2420,15 @@
     if (c->oct >= c->numSubTables - 1) c->oct = c->numSubTables - 2;
 }
 
-void tWaveSynthS_setAntiAliasing(tWaveSynthS* const cy, float aa)
+void tWaveOscS_setAntiAliasing(tWaveOscS* const cy, float aa)
 {
-    _tWaveSynthS* c = *cy;
+    _tWaveOscS* c = *cy;
     c->aa = aa;
 }
 
-void tWaveSynthS_setIndex(tWaveSynthS* const cy, float index)
+void tWaveOscS_setIndex(tWaveOscS* const cy, float index)
 {
-    _tWaveSynthS* c = *cy;
+    _tWaveOscS* c = *cy;
     c->index = index;
     float f = c->index * (c->numTables - 1);
 
@@ -2766,9 +2439,9 @@
 }
 
 /*//// eventually gotta finish this so you can X/Y control the indices and fade between non-adjacent tables
-void tWaveSynthS_setIndexXY(tWaveSynthS* const cy, float indexX, float indexY)
+void tWaveOscS_setIndexXY(tWaveOscS* const cy, float indexX, float indexY)
 {
-    _tWaveSynthS* c = *cy;
+    _tWaveOscS* c = *cy;
     c->index = index;
     float f1 = c->index * (c->numTables - 1);
 
@@ -2781,25 +2454,20 @@
 }
 */
 
-void tWaveSynthS_setSampleRate(tWaveSynthS* const cy, float sr)
+void tWaveOscS_setSampleRate(tWaveOscS* const cy, float sr)
 {
-    _tWaveSynthS* c = *cy;
+    _tWaveOscS* c = *cy;
     //TODO: need to fix this -JS
     for (int i = 0; i < c->numTables; ++i)
     {
         tWaveTableS_setSampleRate(&c->tables[i], sr);
-        //tWaveSubOscS_setSampleRate(&c->oscs[i], sr);
     }
 }
 //
-//void tWaveSynthS_setIndexTable(tWaveSynthS* const cy, int i, float* table, int size)
+//void tWaveOscS_setIndexTable(tWaveOscS* const cy, int i, float* table, int size)
 //{
-//    _tWaveSynthS* c = *cy;
+//    _tWaveOscS* c = *cy;
 //    if (i >= c->numTables) return;
 //    tWaveTableS_free(&c->tables[i]);
 //    tWaveTableS_initToPool(&c->tables[i], table, size, c->maxFreq, &c->mempool);
-//    for (int v = 0; v < c->numVoices; ++v)
-//    {
-//        tWaveOscS_setFreq(&c->oscs[i][v], c->oscs[i][v]->freq);
-//    }
 //}
--- a/leaf/Src/leaf-physical.c
+++ b/leaf/Src/leaf-physical.c
@@ -1233,7 +1233,7 @@
 }
 
 
-float   tLivingString2_udpateDelays(tLivingString2* const pl)
+void tLivingString2_updateDelays(tLivingString2* const pl)
 {
     _tLivingString2* p = *pl;