shithub: leaf

Download patch

ref: 45186ffbb1de558193416ffba480e9003339fa0a
parent: c38c7953a9fe5ea86e0d08f18dfa680926a2cc7a
author: Matthew Wang <mjw7@princeton.edu>
date: Thu May 28 07:38:11 EDT 2020

add argument for passed in oversampling buffer

--- a/leaf/Inc/leaf-distortion.h
+++ b/leaf/Inc/leaf-distortion.h
@@ -69,7 +69,7 @@
     
     void    tOversampler_upsample       (tOversampler* const, float input, float* output);
     float   tOversampler_downsample     (tOversampler* const os, float* input);
-    float   tOversampler_tick           (tOversampler* const, float input, float (*effectTick)(float));
+    float   tOversampler_tick           (tOversampler* const, float input, float* oversample, float (*effectTick)(float));
     int     tOversampler_getLatency     (tOversampler* const os);
     
     //==============================================================================
--- a/leaf/Src/leaf-distortion.c
+++ b/leaf/Src/leaf-distortion.c
@@ -141,19 +141,17 @@
     mpool_free((char*)os, m);
 }
 
-float tOversampler_tick(tOversampler* const osr, float input, float (*effectTick)(float))
+float tOversampler_tick(tOversampler* const osr, float input, float* oversample, float (*effectTick)(float))
 {
     _tOversampler* os = *osr;
     
-    float buf[os->ratio];
+    tOversampler_upsample(osr, input, oversample);
     
-    tOversampler_upsample(osr, input, buf);
-    
     for (int i = 0; i < os->ratio; ++i) {
-        buf[i] = effectTick(buf[i]);
+        oversample[i] = effectTick(oversample[i]);
     }
     
-    return tOversampler_downsample(osr, buf);
+    return tOversampler_downsample(osr, oversample);
 }
 
 // From CMSIS DSP Library