shithub: leaf

Download patch

ref: 686fe2fdca41a805370b97dda125a6eb6ae32926
parent: 59b55dddf8ea5837b3b09fbda3a94b185c2274b0
author: Matthew Wang <mjw7@princeton.edu>
date: Thu May 28 08:18:28 EDT 2020

allocate arrays for minblep building

--- a/leaf/Inc/leaf-oscillators.h
+++ b/leaf/Inc/leaf-oscillators.h
@@ -898,6 +898,11 @@
         int minBlepSize;
         float* minBlepArray;
         float* minBlepDerivArray;
+        
+        float* realTime;
+        float* imagTime;
+        float* realFreq;
+        float* imagFreq;
     } _tMinBLEP;
     
     typedef _tMinBLEP* tMinBLEP;
--- a/leaf/Src/leaf-oscillators.c
+++ b/leaf/Src/leaf-oscillators.c
@@ -973,6 +973,11 @@
     mb->minBlepArray = (float*) mpool_alloc(sizeof(float) * mb->minBlepSize, m);
     mb->minBlepDerivArray = (float*) mpool_alloc(sizeof(float) * mb->minBlepSize, m);
     
+    mb->realTime = (float*) mpool_alloc(sizeof(float) * mb->minBlepSize, m);
+    mb->imagTime = (float*) mpool_alloc(sizeof(float) * mb->minBlepSize, m);
+    mb->realFreq = (float*) mpool_alloc(sizeof(float) * mb->minBlepSize, m);
+    mb->imagFreq = (float*) mpool_alloc(sizeof(float) * mb->minBlepSize, m);
+    
     tMinBLEP_buildBLEP(minblep);
 }
 
@@ -989,6 +994,11 @@
     mpool_free((char*)mb->minBlepArray, m);
     mpool_free((char*)mb->minBlepDerivArray, m);
     
+    mpool_free((char*)mb->realTime, m);
+    mpool_free((char*)mb->imagTime, m);
+    mpool_free((char*)mb->realFreq, m);
+    mpool_free((char*)mb->imagFreq, m);
+    
     mpool_free((char*)mb, m);
 }
 
@@ -1089,15 +1099,10 @@
 }
 
 // Compute Real Cepstrum Of Signal
-static void RealCepstrum(int n, float *signal, float *realCepstrum)
+static void RealCepstrum(int n, float *signal, float *realCepstrum, float* realTime, float* imagTime, float* realFreq, float* imagFreq)
 {
     int i;
     
-    float realTime[n];
-    float imagTime[n];
-    float realFreq[n];
-    float imagFreq[n];
-    
     // Compose Complex FFT Input
     
     for(i = 0; i < n; i++)
@@ -1128,13 +1133,9 @@
 }
 
 // Compute Minimum Phase Reconstruction Of Signal
-static void MinimumPhase(int n, float *realCepstrum, float *minimumPhase)
+static void MinimumPhase(int n, float *realCepstrum, float *minimumPhase, float* realTime, float* imagTime, float* realFreq, float* imagFreq)
 {
     int i, nd2;
-    float realTime[n];
-    float imagTime[n];
-    float realFreq[n];
-    float imagFreq[n];
     
     nd2 = n / 2;
     
@@ -1200,8 +1201,8 @@
     
     // Minimum Phase Reconstruction
     
-    RealCepstrum(n, m->minBlepArray, m->minBlepDerivArray);
-    MinimumPhase(n, m->minBlepDerivArray, m->minBlepArray);
+    RealCepstrum(n, m->minBlepArray, m->minBlepDerivArray, m->realTime, m->imagTime, m->realFreq, m->imagFreq);
+    MinimumPhase(n, m->minBlepDerivArray, m->minBlepArray, m->realTime, m->imagTime, m->realFreq, m->imagFreq);
     
     // Integrate Into MinBLEP
     a = 0.0f;