changeset 172:772c03f47063

Dynamically allocate storage in simpltest example. Ooura doesn't seem to like the being passed memory on the stack on Linux. Fixes #11
author Jamie Bullock <jamie@jamiebullock.com>
date Tue, 18 Jun 2013 13:23:17 -0700
parents 661c1c732269
children 1a0907add40c
files examples/simpletest/simpletest.c
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/examples/simpletest/simpletest.c	Tue Jun 18 13:21:02 2013 -0700
+++ b/examples/simpletest/simpletest.c	Tue Jun 18 13:23:17 2013 -0700
@@ -92,13 +92,13 @@
     double mean = 0.0; 
     double f0 = 0.0;
     double centroid = 0.0;
-    double spectrum[BLOCKSIZE];
-    double windowed[BLOCKSIZE];
-    double peaks[BLOCKSIZE];
-    double harmonics[BLOCKSIZE];
+    double *spectrum = calloc(BLOCKSIZE, sizeof(double));
+    double *windowed = calloc(BLOCKSIZE, sizeof(double));
+    double *peaks = calloc(BLOCKSIZE, sizeof(double));
+    double *harmonics = calloc(BLOCKSIZE, sizeof(double));
     double *window = NULL;
-    double mfccs[MFCC_FREQ_BANDS * sizeof(double)];
-    double argd[4];
+    double *mfccs = calloc(MFCC_FREQ_BANDS, sizeof(double));
+    double argd[4] = {0};
     double samplerate = 44100.0;
     int n;
     xtract_mel_filter mel_filters;
@@ -182,6 +182,12 @@
     }
     free(mel_filters.filters);
 
+    free(spectrum);
+    free(windowed);
+    free(peaks);
+    free(harmonics); 
+    free(mfccs);
+
     return 0;
 
 }