shithub: leaf

Download patch

ref: 249e21c4a352ebbf990f72e8e4e760eece755989
parent: 63e93a55b13ab22f80e48c2ef8ce2657f5f0f824
author: Matthew Wang <mjw7@princeton.edu>
date: Wed May 6 13:17:00 EDT 2020

readd period detection alpha and tolerance

--- a/LEAF/Inc/leaf-analysis.h
+++ b/LEAF/Inc/leaf-analysis.h
@@ -239,6 +239,10 @@
         
         float fidelityThreshold;
         
+        float history;
+        float alpha;
+        float tolerance;
+        
     } _tPeriodDetection;
     
     typedef _tPeriodDetection* tPeriodDetection;
@@ -253,6 +257,8 @@
     void    tPeriodDetection_setHopSize         (tPeriodDetection* const, int hs);
     void    tPeriodDetection_setWindowSize      (tPeriodDetection* const, int ws);
     void    tPeriodDetection_setFidelityThreshold(tPeriodDetection* const, float threshold);
+    void     tPeriodDetection_setAlpha            (tPeriodDetection* const, float alpha);
+    void     tPeriodDetection_setTolerance        (tPeriodDetection* const, float tolerance);
     
     //==============================================================================
     
--- a/LEAF/Inc/leaf-effects.h
+++ b/LEAF/Inc/leaf-effects.h
@@ -298,6 +298,8 @@
     void    tAutotune_setHopSize            (tAutotune* const, int hs);
     void    tAutotune_setWindowSize         (tAutotune* const, int ws);
     void    tAutotune_setFidelityThreshold  (tAutotune* const, float threshold);
+    void    tAutotune_setAlpha              (tAutotune* const, float alpha);
+    void    tAutotune_setTolerance          (tAutotune* const, float tolerance);
     float   tAutotune_getInputPeriod        (tAutotune* const);
     float   tAutotune_getInputFreq          (tAutotune* const);
     
--- a/LEAF/Src/leaf-analysis.c
+++ b/LEAF/Src/leaf-analysis.c
@@ -944,3 +944,16 @@
     _tPeriodDetection* p = *pd;
     p->fidelityThreshold = threshold;
 }
+
+void tPeriodDetection_setAlpha            (tPeriodDetection* pd, float alpha)
+{
+    _tPeriodDetection* p = *pd;
+    p->alpha = LEAF_clip(0.0f, alpha, 1.0f);
+}
+
+void tPeriodDetection_setTolerance        (tPeriodDetection* pd, float tolerance)
+{
+    _tPeriodDetection* p = *pd;
+    if (tolerance < 0.0f) p->tolerance = 0.0f;
+    else p->tolerance = tolerance;
+}
--- a/LEAF/Src/leaf-effects.c
+++ b/LEAF/Src/leaf-effects.c
@@ -1545,6 +1545,18 @@
     tPeriodDetection_setFidelityThreshold(&r->pd, threshold);
 }
 
+void     tAutotune_setAlpha                (tAutotune* rt, float alpha)
+{
+    _tAutotune* r = *rt;
+    tPeriodDetection_setAlpha(&r->pd, alpha);
+}
+
+void     tAutotune_setTolerance            (tAutotune* rt, float tolerance)
+{
+    _tAutotune* r = *rt;
+    tPeriodDetection_setTolerance(&r->pd, tolerance);
+}
+
 float tAutotune_getInputPeriod(tAutotune* const rt)
 {
     _tAutotune* r = *rt;