shithub: leaf

Download patch

ref: 9dffd7c97f0263f5207db0a08dd4ab2d6af5b21d
parent: 20802a8e9240feec34bdb80485380f8e0a572733
author: mulshine <mulshine@princeton.edu>
date: Wed Dec 19 09:54:04 EST 2018

Synced cpp and c leaf source.

--- a/LEAF/Src_cpp/leaf-oscillator.cpp
+++ b/LEAF/Src_cpp/leaf-oscillator.cpp
@@ -307,6 +307,7 @@
 {
     p->phase = 0.0f;
     p->inc = 0.0f;
+
 }
 
 void    tPhasor_free(tPhasor* const p)
@@ -427,7 +428,7 @@
         w = ((20480.0f - c->freq) * INV_10240);
         out = (c->table[T10240][idx] * w) + (c->table[T20480][idx] * (1.0f - w));
     }
-    else
+    else if (c->freq <= 24000.0f)
     {
         out = c->table[T20480][idx];
     }
@@ -450,6 +451,9 @@
 {
     c->inc      =  0.0f;
     c->phase    =  0.0f;
+    c->tsize     = 2048;
+
+    tTriangle_setTableSize(c, c->tsize);
 }
 
 void   tTriangle_free(tTriangle* const c)
@@ -557,7 +561,7 @@
         w = ((20480.0f - c->freq) * INV_10240);
         out = (c->table[T10240][idx] * w) + (c->table[T20480][idx] * (1.0f - w));
     }
-    else
+    else if (c->freq <= 24000.0f)
     {
         out = c->table[T20480][idx];
     }
@@ -575,6 +579,9 @@
 {
     c->inc      =  0.0f;
     c->phase    =  0.0f;
+    c->tsize     = 2048;
+
+    tSquare_setTableSize(c, c->tsize);
 }
 
 void   tSquare_free(tSquare* const c)
@@ -622,8 +629,9 @@
     
     float out = 0.0f;
     float w = 0.0f;
+
     int idx = (int)(c->phase * c->tsize);
-    
+
     // Wavetable synthesis
     
     if (c->freq <= 20.0f)
@@ -680,7 +688,7 @@
         w = ((20480.0f - c->freq) * INV_10240);
         out = (c->table[T10240][idx] * w) + (c->table[T20480][idx] * (1.0f - w));
     }
-    else
+    else if (c->freq <= 24000.0f)
     {
         out = c->table[T20480][idx];
     }