shithub: leaf

Download patch

ref: 677746b688a08a63d3204052ae1998f648ba5c44
parent: 8908d00ecbf9b10450869dffb5dc06b10c896d34
author: mulshine <mulshine@princeton.edu>
date: Thu Feb 7 13:43:51 EST 2019

LEAF_reduct.

--- a/LEAF/Inc/leaf-math.h
+++ b/LEAF/Inc/leaf-math.h
@@ -78,7 +78,7 @@
 float LEAF_shaper     (float input, float m_drive);
 float LEAF_reedTable  (float input, float offset, float slope);
     
-float LEAF_reduct (float input, float srr);
+float LEAF_reduct (float input, int );
 float LEAF_round (float input, float rnd);
 float LEAF_bitwise_or(float input, uint32_t op);
 
--- a/LEAF/Src/leaf-math.c
+++ b/LEAF/Src/leaf-math.c
@@ -120,25 +120,19 @@
 }
 
 // reduce sample resolution
-float LEAF_reduct (float input, float sr)
+float hold = 0.f;
+int count = 0;
+
+float LEAF_reduct (float input, int st)
 {
-    float samp = input;
+    count++;
+    if (count > st)
+    {
+        hold = input;
+        count = 0;
+    }
     
-    samp *= sr;
-    
-    // method 1 
-    samp = ceilf(samp);
-    
-    samp /= sr;
-    
-    /*
-    // method 2
-    samp = floorf(samp + 0.5f) - 0.5f;
-    
-    samp /= srr;
-    */
-    
-    return samp;
+    return hold;
 }
 
 // round input to nearest rnd
--- a/LEAF_JUCEPlugin/Source/MyTest.cpp
+++ b/LEAF_JUCEPlugin/Source/MyTest.cpp
@@ -62,7 +62,7 @@
     
     val = getSliderValue("op");
     
-    tCrusher_setOperation(&crusher, (int)(val * 8.0f));
+    tCrusher_setOperation(&crusher, val);
     
     /*
     float samp = -1.f + 2.f * val;