shithub: leaf

Download patch

ref: 6db1777c89302524bdbec4c0e909d3c93ab76523
parent: a899e1ac27ea18e300713f6e49f2ed7541290797
author: Matthew Wang <mjw7@princeton.edu>
date: Wed May 26 12:55:07 EDT 2021

use uint phase for table oscs

--- a/TestPlugin/Source/MyTest.cpp
+++ b/TestPlugin/Source/MyTest.cpp
@@ -85,10 +85,8 @@
     set[1] = (float*)__leaf_table_triangle[0];
     set[2] = (float*)__leaf_table_squarewave[0];
     set[3] = (float*)__leaf_table_sawtooth[0];
-    int sizes[4];
-    for (int i = 0; i < 4; i++) sizes[i] = 2048;
     
-    tWaveSynth_init(&ws, 1, set, sizes, 4, 10000.f, &leaf);
+//    tWaveSynth_init(&ws, set, 2048, 4, 10000.f, &leaf);
     
     lastLoadedAudioSize = 0;
     loadedAudio.clear();
@@ -127,7 +125,7 @@
     tMBSaw_setFreq(&bsaw, val * 10000.f);
 //    tWaveTable_setFreq(&wt, val * 160000.f - 80000.0f);
 //    tWaveTableS_setFreq(&cwt, val * 10000.);
-    tWaveSynth_setFreq(&ws, 0, val * 10000.f);
+    tWaveSynth_setFreq(&ws, val * 10000.f);
 //    tRetune_tuneVoice(&retune, 0, val * 3.0f + 0.5f);
 //    tSimpleRetune_tuneVoice(&sretune, 0, 300);
 
--- a/leaf/Inc/leaf-oscillators.h
+++ b/leaf/Inc/leaf-oscillators.h
@@ -80,6 +80,7 @@
     
     float   tCycle_tick         (tCycle* const osc);
     void    tCycle_setFreq      (tCycle* const osc, float freq);
+    void    tCycle_setPhase     (tCycle* const osc, float phase);
     void    tCycle_setSampleRate(tCycle* const osc, float sr);
     
     //==============================================================================
@@ -118,14 +119,16 @@
 
     typedef struct _tTriangle
     {
-        
         tMempool mempool;
         // Underlying phasor
-        float phase;
-        float inc,freq;
+        uint32_t phase;
+        uint32_t inc;
+        float freq;
         int oct;
         float w;
         float invSampleRate;
+        float invSampleRateTimesTwoTo32;
+        uint32_t mask;
     } _tTriangle;
     
     typedef _tTriangle* tTriangle;
@@ -136,6 +139,7 @@
     
     float   tTriangle_tick          (tTriangle* const osc);
     void    tTriangle_setFreq       (tTriangle* const osc, float freq);
+    void    tTriangle_setPhase      (tTriangle* const osc, float phase);
     void    tTriangle_setSampleRate (tTriangle* const osc, float sr);
     
     //==============================================================================
@@ -174,14 +178,16 @@
     
     typedef struct _tSquare
     {
-        
         tMempool mempool;
         // Underlying phasor
-        float phase;
-        float inc,freq;
+        uint32_t phase;
+        uint32_t inc;
+        float freq;
         int oct;
         float w;
         float invSampleRate;
+        float invSampleRateTimesTwoTo32;
+        uint32_t mask;
     } _tSquare;
     
     typedef _tSquare* tSquare;
@@ -192,6 +198,7 @@
 
     float   tSquare_tick        (tSquare* const osc);
     void    tSquare_setFreq     (tSquare* const osc, float freq);
+    void    tSquare_setPhase     (tSquare* const osc, float phase);
     void    tSquare_setSampleRate (tSquare* const osc, float sr);
     
     /*!
@@ -233,14 +240,16 @@
     
     typedef struct _tSawtooth
     {
-        
         tMempool mempool;
         // Underlying phasor
-        float phase;
-        float inc,freq;
+        uint32_t phase;
+        uint32_t inc;
+        float freq;
         int oct;
         float w;
         float invSampleRate;
+        float invSampleRateTimesTwoTo32;
+        uint32_t mask;
     } _tSawtooth;
     
     typedef _tSawtooth* tSawtooth;
@@ -251,6 +260,7 @@
 
     float   tSawtooth_tick          (tSawtooth* const osc);
     void    tSawtooth_setFreq       (tSawtooth* const osc, float freq);
+    void    tSawtooth_setPhase      (tSawtooth* const osc, float phase);
     void    tSawtooth_setSampleRate (tSawtooth* const osc, float sr);
     
     //==============================================================================
--- a/leaf/Inc/leaf-physical.h
+++ b/leaf/Inc/leaf-physical.h
@@ -603,7 +603,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
@@ -43,17 +43,6 @@
     mpool_free((char*)c, c->mempool);
 }
 
-void     tCycle_setFreq(tCycle* const cy, float freq)
-{
-    _tCycle* c = *cy;
-    
-    //if (!isfinite(freq)) return;
-    
-    c->freq  = freq;
-
-    c->inc = freq * c->invSampleRateTimesTwoTo32;
-}
-
 //need to check bounds and wrap table properly to allow through-zero FM
 float   tCycle_tick(tCycle* const cy)
 {
@@ -79,6 +68,25 @@
     return (samp0 + (samp1 - samp0) * frac);
 }
 
+void     tCycle_setFreq(tCycle* const cy, float freq)
+{
+    _tCycle* c = *cy;
+    
+    //if (!isfinite(freq)) return;
+    
+    c->freq  = freq;
+    c->inc = freq * c->invSampleRateTimesTwoTo32;
+}
+
+void    tCycle_setPhase(tCycle* const cy, float phase)
+{
+    _tCycle* c = *cy;
+    
+    int i = phase;
+    phase -= i;
+    c->phase = phase * TWO_TO_32;
+}
+
 void     tCycle_setSampleRate (tCycle* const cy, float sr)
 {
     _tCycle* c = *cy;
@@ -103,9 +111,11 @@
     c->mempool = m;
     LEAF* leaf = c->mempool->leaf;
     
-    c->inc      =  0.0f;
-    c->phase    =  0.0f;
+    c->inc      =  0;
+    c->phase    =  0;
     c->invSampleRate = leaf->invSampleRate;
+    c->invSampleRateTimesTwoTo32 = (c->invSampleRate * TWO_TO_32);
+    c->mask = TRI_TABLE_SIZE - 1;
     tTriangle_setFreq(cy, 220);
 }
 
@@ -116,26 +126,6 @@
     mpool_free((char*)c, c->mempool);
 }
 
-void tTriangle_setFreq(tTriangle* const cy, float freq)
-{
-    _tTriangle* 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 * (TRI_TABLE_SIZE * c->invSampleRate));
-    
-    c->w = log2f_approx(c->w);//+ 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;
-    c->oct = (int)c->w;
-    c->w -= c->oct;
-    if (c->oct >= 10) c->oct = 9;
-}
-
-
 float   tTriangle_tick(tTriangle* const cy)
 {
     _tTriangle* c = *cy;
@@ -148,23 +138,22 @@
     
     // Phasor increment
     c->phase += c->inc;
-    if (c->phase >= 1.0f) c->phase -= 1.0f;
-    if (c->phase < 0.0f) c->phase += 1.0f;
-
+    
     // Wavetable synthesis
-    temp = TRI_TABLE_SIZE * c->phase;
+    temp = ((float)c->phase * 0.000000476837158f);
     
-    idx = (int)temp;
+    idx = ((int)temp) & c->mask;
     frac = temp - (float)idx;
     samp0 = __leaf_table_triangle[c->oct][idx];
-    if (++idx >= TRI_TABLE_SIZE) idx = 0;
+    idx = (idx + 1) & c->mask;
     samp1 = __leaf_table_triangle[c->oct][idx];
     
     float oct0 = (samp0 + (samp1 - samp0) * frac);
     
-    idx = (int)temp;
+    idx = ((int)temp) & c->mask;
+    frac = temp - (float)idx;
     samp0 = __leaf_table_triangle[c->oct+1][idx];
-    if (++idx >= TRI_TABLE_SIZE) idx = 0;
+    idx = (idx + 1) & c->mask;
     samp1 = __leaf_table_triangle[c->oct+1][idx];
     
     float oct1 = (samp0 + (samp1 - samp0) * frac);
@@ -172,11 +161,38 @@
     return oct0 + (oct1 - oct0) * c->w;
 }
 
+void tTriangle_setFreq(tTriangle* const cy, float freq)
+{
+    _tTriangle* c = *cy;
+    
+    c->freq = freq;
+    c->inc = freq * c->invSampleRateTimesTwoTo32;
+    
+    // abs for negative frequencies
+    c->w = fabsf(c->freq * (TRI_TABLE_SIZE * c->invSampleRate));
+    
+    c->w = log2f_approx(c->w);//+ 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;
+    c->oct = (int)c->w;
+    c->w -= c->oct;
+    if (c->oct >= 10) c->oct = 9;
+}
+
+void tTriangle_setPhase(tTriangle* const cy, float phase)
+{
+    _tTriangle* c = *cy;
+    
+    int i = phase;
+    phase -= i;
+    c->phase = phase * TWO_TO_32;
+}
+
 void     tTriangle_setSampleRate (tTriangle* const cy, float sr)
 {
     _tTriangle* c = *cy;
     
     c->invSampleRate = 1.0f/sr;
+    c->invSampleRateTimesTwoTo32 = c->invSampleRate * TWO_TO_32;
     tTriangle_setFreq(cy, c->freq);
 }
 #endif // LEAF_INCLUDE_TRIANGLE_TABLE
@@ -196,9 +212,11 @@
     c->mempool = m;
     LEAF* leaf = c->mempool->leaf;
     
-    c->inc      =  0.0f;
-    c->phase    =  0.0f;
+    c->inc      =  0;
+    c->phase    =  0;
     c->invSampleRate = leaf->invSampleRate;
+    c->invSampleRateTimesTwoTo32 = (c->invSampleRate * TWO_TO_32);
+    c->mask = SQR_TABLE_SIZE - 1;
     tSquare_setFreq(cy, 220);
 }
 
@@ -209,25 +227,6 @@
     mpool_free((char*)c, c->mempool);
 }
 
-void    tSquare_setFreq(tSquare* const cy, float freq)
-{
-    _tSquare* 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 * (SQR_TABLE_SIZE * c->invSampleRate));
-    
-    c->w = log2f_approx(c->w);//+ 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;
-    c->oct = (int)c->w;
-    c->w -= c->oct;
-    if (c->oct >= 10) c->oct = 9;
-}
-
 float   tSquare_tick(tSquare* const cy)
 {
     _tSquare* c = *cy;
@@ -240,23 +239,22 @@
     
     // Phasor increment
     c->phase += c->inc;
-    if (c->phase >= 1.0f) c->phase -= 1.0f;
-    if (c->phase < 0.0f) c->phase += 1.0f;
-
+    
     // Wavetable synthesis
-    temp = SQR_TABLE_SIZE * c->phase;
+    temp = ((float)c->phase * 0.000000476837158f);
     
-    idx = (int)temp;
+    idx = ((int)temp) & c->mask;
     frac = temp - (float)idx;
     samp0 = __leaf_table_squarewave[c->oct][idx];
-    if (++idx >= SQR_TABLE_SIZE) idx = 0;
+    idx = (idx + 1) & c->mask;
     samp1 = __leaf_table_squarewave[c->oct][idx];
     
     float oct0 = (samp0 + (samp1 - samp0) * frac);
     
-    idx = (int)temp;
+    idx = ((int)temp) & c->mask;
+    frac = temp - (float)idx;
     samp0 = __leaf_table_squarewave[c->oct+1][idx];
-    if (++idx >= SQR_TABLE_SIZE) idx = 0;
+    idx = (idx + 1) & c->mask;
     samp1 = __leaf_table_squarewave[c->oct+1][idx];
     
     float oct1 = (samp0 + (samp1 - samp0) * frac);
@@ -264,11 +262,38 @@
     return oct0 + (oct1 - oct0) * c->w;
 }
 
+void    tSquare_setFreq(tSquare* const cy, float freq)
+{
+    _tSquare* c = *cy;
+    
+    c->freq  = freq;
+    c->inc = freq * c->invSampleRateTimesTwoTo32;
+    
+    // abs for negative frequencies
+    c->w = fabsf(c->freq * (SQR_TABLE_SIZE * c->invSampleRate));
+    
+    c->w = log2f_approx(c->w);//+ 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;
+    c->oct = (int)c->w;
+    c->w -= c->oct;
+    if (c->oct >= 10) c->oct = 9;
+}
+
+void    tSquare_setPhase(tSquare* const cy, float phase)
+{
+    _tSquare* c = *cy;
+    
+    int i = phase;
+    phase -= i;
+    c->phase = phase * TWO_TO_32;
+}
+
 void     tSquare_setSampleRate (tSquare* const cy, float sr)
 {
     _tSquare* c = *cy;
     
     c->invSampleRate = 1.0f/sr;
+    c->invSampleRateTimesTwoTo32 = c->invSampleRate * TWO_TO_32;
     tSquare_setFreq(cy, c->freq);
 }
 #endif // LEAF_INCLUDE_SQUARE_TABLE
@@ -288,9 +313,11 @@
     c->mempool = m;
     LEAF* leaf = c->mempool->leaf;
     
-    c->inc      = 0.0f;
-    c->phase    = 0.0f;
+    c->inc      = 0;
+    c->phase    = 0;
     c->invSampleRate = leaf->invSampleRate;
+    c->invSampleRateTimesTwoTo32 = (c->invSampleRate * TWO_TO_32);
+    c->mask = SAW_TABLE_SIZE - 1;
     tSawtooth_setFreq(cy, 220);
 }
 
@@ -301,25 +328,6 @@
     mpool_free((char*)c, c->mempool);
 }
 
-void    tSawtooth_setFreq(tSawtooth* const cy, float freq)
-{
-    _tSawtooth* 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 * (SAW_TABLE_SIZE * c->invSampleRate));
-    
-    c->w = log2f_approx(c->w);//+ 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 >= 10) c->oct = 9;
-}
-
 float   tSawtooth_tick(tSawtooth* const cy)
 {
     _tSawtooth* c = *cy;
@@ -332,23 +340,22 @@
     
     // Phasor increment
     c->phase += c->inc;
-    while (c->phase >= 1.0f) c->phase -= 1.0f;
-    while (c->phase < 0.0f) c->phase += 1.0f;
     
     // Wavetable synthesis
-    temp = SAW_TABLE_SIZE * c->phase;
+    temp = ((float)c->phase * 0.000000476837158f);
     
-    idx = (int)temp;
+    idx = ((int)temp) & c->mask;
     frac = temp - (float)idx;
     samp0 = __leaf_table_sawtooth[c->oct][idx];
-    if (++idx >= SAW_TABLE_SIZE) idx = 0;
+    idx = (idx + 1) & c->mask;
     samp1 = __leaf_table_sawtooth[c->oct][idx];
     
     float oct0 = (samp0 + (samp1 - samp0) * frac);
     
-    idx = (int)temp;
+    idx = ((int)temp) & c->mask;
+    frac = temp - (float)idx;
     samp0 = __leaf_table_sawtooth[c->oct+1][idx];
-    if (++idx >= SAW_TABLE_SIZE) idx = 0;
+    idx = (idx + 1) & c->mask;
     samp1 = __leaf_table_sawtooth[c->oct+1][idx];
     
     float oct1 = (samp0 + (samp1 - samp0) * frac);
@@ -356,11 +363,38 @@
     return oct0 + (oct1 - oct0) * c->w;
 }
 
+void    tSawtooth_setFreq(tSawtooth* const cy, float freq)
+{
+    _tSawtooth* c = *cy;
+    
+    c->freq  = freq;
+    c->inc = freq * c->invSampleRateTimesTwoTo32;
+    
+    // abs for negative frequencies
+    c->w = fabsf(c->freq * (SAW_TABLE_SIZE * c->invSampleRate));
+    
+    c->w = log2f_approx(c->w);//+ 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 >= 10) c->oct = 9;
+}
+
+void tSawtooth_setPhase(tSawtooth* const cy, float phase)
+{
+    _tSawtooth* c = *cy;
+    
+    int i = phase;
+    phase -= i;
+    c->phase = phase * TWO_TO_32;
+}
+
 void     tSawtooth_setSampleRate (tSawtooth* const cy, float sr)
 {
     _tSawtooth* c = *cy;
     
     c->invSampleRate = 1.0f/sr;
+    c->invSampleRateTimesTwoTo32 = c->invSampleRate * TWO_TO_32;
     tSawtooth_setFreq(cy, c->freq);
 }
 #endif // LEAF_INCLUDE_SAWTOOTH_TABLE
@@ -2065,7 +2099,6 @@
     float floatPhase = (double)c->phase * 2.32830643654e-10;
     float s1 = 0.f, s2 = 0.f;
 
-
     float temp;
     int idx;
     float frac;
@@ -2074,7 +2107,6 @@
 
     int oct = c->oct;
 
-
     int sizeMask = c->tables[c->o1]->sizeMask;
     float** tables = c->tables[c->o1]->tables;
 
@@ -2088,8 +2120,6 @@
 
     float oct0 = (samp0 + (samp1 - samp0) * frac);
 
-
-
     temp = sizeMask * floatPhase;
     idx = (int)temp;
     frac = temp - (float)idx;
@@ -2101,7 +2131,6 @@
 
     s1 = oct0 + (oct1 - oct0) * c->w;
 
-
     sizeMask = c->tables[c->o2]->sizeMask;
     tables = c->tables[c->o2]->tables;
 
@@ -2252,7 +2281,7 @@
     c->tables[0] = c->baseTable;
     for (int t = 1; t < c->numTables; ++t)
     {
-        c->sizes[t] = c->sizes[t-1] / 2;
+        c->sizes[t] = c->sizes[t-1] / 2 > 128 ? c->sizes[t-1] / 2 : 128;
         c->sizeMasks[t] = (c->sizes[t] - 1);
         c->tables[t] = (float*) mpool_alloc(sizeof(float) * c->sizes[t], c->mempool);
     }
@@ -2264,21 +2293,38 @@
     }
     
     // Make bandlimited copies
+    f = c->sampleRate * 0.25; //start at half nyquist
     // Not worth going over order 8 I think, and even 8 is only marginally better than 4.
-    tButterworth_initToPool(&c->bl, 8, -1.0f, c->sampleRate * 0.25f, mp);
+    tButterworth_initToPool(&c->bl, 8, -1.0f, f, mp);
     tOversampler_initToPool(&c->ds, 2, 1, mp);
     for (int t = 1; t < c->numTables; ++t)
     {
-        // Similar to tWaveTable, doing multiple passes here helps, but not sure what number is optimal
-        for (int p = 0; p < 12; ++p)
+        // Size is going down; we need to downsample
+        if (c->sizes[t] < c->sizes[t-1])
         {
-            for (int i = 0; i < c->sizes[t]; ++i)
+            // Similar to tWaveTable, doing multiple passes here helps, but not sure what number is optimal
+            for (int p = 0; p < 12; ++p)
             {
-                c->dsBuffer[0] = tButterworth_tick(&c->bl, c->tables[t-1][i*2]);
-                c->dsBuffer[1] = tButterworth_tick(&c->bl, c->tables[t-1][(i*2)+1]);
-                c->tables[t][i] = tOversampler_downsample(&c->ds, c->dsBuffer);
+                for (int i = 0; i < c->sizes[t]; ++i)
+                {
+                    c->dsBuffer[0] = tButterworth_tick(&c->bl, c->tables[t-1][i*2]);
+                    c->dsBuffer[1] = tButterworth_tick(&c->bl, c->tables[t-1][(i*2)+1]);
+                    c->tables[t][i] = tOversampler_downsample(&c->ds, c->dsBuffer);
+                }
             }
         }
+        else
+        {
+            tButterworth_setF2(&c->bl, f);
+            for (int p = 0; p < 12; ++p)
+            {
+                for (int i = 0; i < c->sizes[t]; ++i)
+                {
+                    c->tables[t][i] = tButterworth_tick(&c->bl, c->tables[t-1][i]);
+                }
+            }
+            f *= 0.5f; //halve the cutoff for next pass
+        }
     }
     tOversampler_free(&c->ds);
     tButterworth_free(&c->bl);
@@ -2542,7 +2588,6 @@
 //================================================================================================
 //================================================================================================
 
-
 void tWaveSynthS_init(tWaveSynthS* const cy, tWaveTableS* tables, int size,
                             int numTables, float maxFreq, LEAF* const leaf)
 {
@@ -2563,7 +2608,7 @@
     
     //c->oscs = (tWaveSubOscS*) mpool_alloc(sizeof(tWaveSubOscS*) * c->numTables, m);
 
-    int i = 0;
+//    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?
--- a/leaf/Src/leaf-physical.c
+++ b/leaf/Src/leaf-physical.c
@@ -1050,24 +1050,24 @@
     if (pickP > prepP)
     {
         float fullPickPoint =  ((pickP*wLen) - lowLen);
-        pickPInt = (uint) fullPickPoint; // where does the input go? that's the pick point
+        pickPInt = (uint32_t) fullPickPoint; // where does the input go? that's the pick point
         float pickPFloat = fullPickPoint - pickPInt;
 
         tHermiteDelay_addTo(&p->delUF, input * (1.0f - pickPFloat), pickPInt);
         tHermiteDelay_addTo(&p->delUF, input * pickPFloat, pickPInt + 1);
-        tHermiteDelay_addTo(&p->delUB, input * (1.0f - pickPFloat), (uint) (upLen - pickPInt));
-        tHermiteDelay_addTo(&p->delUB, input * pickPFloat, (uint) (upLen - pickPInt - 1));
+        tHermiteDelay_addTo(&p->delUB, input * (1.0f - pickPFloat), (uint32_t) (upLen - pickPInt));
+        tHermiteDelay_addTo(&p->delUB, input * pickPFloat, (uint32_t) (upLen - pickPInt - 1));
     }
     else
     {
          float fullPickPoint =  pickP * wLen;
-        pickPInt = (uint) fullPickPoint; // where does the input go? that's the pick point
+        pickPInt = (uint32_t) fullPickPoint; // where does the input go? that's the pick point
         float pickPFloat = fullPickPoint - pickPInt;
 
         tHermiteDelay_addTo(&p->delLF, input * (1.0f - pickPFloat), pickPInt);
         tHermiteDelay_addTo(&p->delLF, input * pickPFloat, pickPInt + 1);
-        tHermiteDelay_addTo(&p->delLB, input * (1.0f - pickPFloat), (uint) (lowLen - pickPInt));
-        tHermiteDelay_addTo(&p->delLB, input * pickPFloat, (uint) (lowLen - pickPInt - 1));
+        tHermiteDelay_addTo(&p->delLB, input * (1.0f - pickPFloat), (uint32_t) (lowLen - pickPInt));
+        tHermiteDelay_addTo(&p->delLB, input * pickPFloat, (uint32_t) (lowLen - pickPInt - 1));
     }
 /*
     if (pickP > prepP)
@@ -1120,24 +1120,24 @@
         if (pupos > prepP)
         {
             float fullPUPoint =  ((pupos*wLen) - lowLen);
-            PUPInt = (uint) fullPUPoint; // where does the input go? that's the pick point
+            PUPInt = (uint32_t) fullPUPoint; // where does the input go? that's the pick point
             float PUPFloat = fullPUPoint - PUPInt;
 
             pickupOut = tHermiteDelay_tapOut(&p->delUF, PUPInt) * (1.0f - PUPFloat);
             pickupOut += tHermiteDelay_tapOut(&p->delUF, PUPInt + 1) * PUPFloat;
-            pickupOut += tHermiteDelay_tapOut(&p->delUB, (uint) (upLen - PUPInt)) * (1.0f - PUPFloat);
-            pickupOut += tHermiteDelay_tapOut(&p->delUB, (uint) (upLen - PUPInt - 1))  * PUPFloat;
+            pickupOut += tHermiteDelay_tapOut(&p->delUB, (uint32_t) (upLen - PUPInt)) * (1.0f - PUPFloat);
+            pickupOut += tHermiteDelay_tapOut(&p->delUB, (uint32_t) (upLen - PUPInt - 1))  * PUPFloat;
         }
         else
         {
              float fullPUPoint =  pupos * wLen;
-            PUPInt = (uint) fullPUPoint; // where does the input go? that's the pick point
+            PUPInt = (uint32_t) fullPUPoint; // where does the input go? that's the pick point
             float PUPFloat = fullPUPoint - PUPInt;
 
             pickupOut = tHermiteDelay_tapOut(&p->delLF, PUPInt) * (1.0f - PUPFloat);
             pickupOut += tHermiteDelay_tapOut(&p->delLF,  PUPInt + 1) * PUPFloat;
-            pickupOut += tHermiteDelay_tapOut(&p->delLB, (uint) (lowLen - PUPInt)) * (1.0f - PUPFloat);
-            pickupOut += tHermiteDelay_tapOut(&p->delLB, (uint) (lowLen - PUPInt - 1)) * PUPFloat;
+            pickupOut += tHermiteDelay_tapOut(&p->delLB, (uint32_t) (lowLen - PUPInt)) * (1.0f - PUPFloat);
+            pickupOut += tHermiteDelay_tapOut(&p->delLB, (uint32_t) (lowLen - PUPInt - 1)) * PUPFloat;
         }
 
         p->curr = pickupOut;
@@ -1232,18 +1232,14 @@
     return p->curr;
 }
 
-float   tLivingString2_udpateDelays(tLivingString2* const pl)
+void   tLivingString2_updateDelays(tLivingString2* const pl)
 {
     _tLivingString2* p = *pl;
 
-
-
     //need to determine which delay line to put it into (should be half amplitude into forward and backward lines for the correct portion of string)
 
     float lowLen=p->prpSmooth->dest*p->wlSmooth->dest;
     float upLen=(1.0f-p->prpSmooth->dest)*p->wlSmooth->dest;
-
-
 
     tHermiteDelay_setDelay(&p->delLF, lowLen);
     tHermiteDelay_setDelay(&p->delLB, lowLen);