changeset 39:39c76f4db5b7

Fixed xtract_init_mfcc
author Jamie Bullock <jamie@postlude.co.uk>
date Mon, 11 Dec 2006 11:21:04 +0000
parents 0ea4d6430cfc
children 678667039077
files ChangeLog src/init.c src/vector.c
diffstat 3 files changed, 25 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Dec 09 15:21:35 2006 +0000
+++ b/ChangeLog	Mon Dec 11 11:21:04 2006 +0000
@@ -1,3 +1,6 @@
+2006-11-10 Jamie Bullock <jamie@postlude.co.uk>
+    * version 0.3.1
+	* Fixed xtract_init_mfcc (array entries zeroed out if not set)
 2006-11-10 Jamie Bullock <jamie@postlude.co.uk>
     * version 0.3.0
 	* Corrected typos in scalar.c
--- a/src/init.c	Sat Dec 09 15:21:35 2006 +0000
+++ b/src/init.c	Mon Dec 11 11:21:04 2006 +0000
@@ -26,11 +26,10 @@
 
 int xtract_init_mfcc(int N, float nyquist, int style, float freq_max, float freq_min, int freq_bands, float **fft_tables){
 
-    int n,i, *fft_peak, M; 
+    int n, i, k, *fft_peak, M, next_peak; 
     float norm, mel_freq_max, mel_freq_min, norm_fact, height, inc, val, 
         freq_bw_mel, *mel_peak, *height_norm, *lin_peak;
 
-
     mel_peak = height_norm = lin_peak = NULL;
     fft_peak = NULL;
     norm = 1; 
@@ -48,7 +47,7 @@
     if(mel_peak == NULL || height_norm == NULL || 
                     lin_peak == NULL || fft_peak == NULL)
                     return MALLOC_FAILED;
-        
+    
     M = N >> 1;
 
     mel_peak[0] = mel_freq_min;
@@ -79,28 +78,41 @@
     i = 0;
    
     for(n = 0; n < freq_bands; n++){
+	
+	/*calculate the rise increment*/
         if(n > 0)
-            /*calculate the rise increment*/
             inc = height_norm[n] / (fft_peak[n] - fft_peak[n - 1]);
         else
             inc = height_norm[n] / fft_peak[n];
         val = 0;	
+	
+	/*zero the start of the array*/
+	for(k = 0; k < i; k++)
+	   fft_tables[n][k] = 0.f;
+	
+	/*fill in the rise */
         for(; i <= fft_peak[n]; i++){ 
-            /*fill in the 'rise' */
             fft_tables[n][i] = val;
             val += inc;
         }
+	
+        /*calculate the fall increment */
         inc = height_norm[n] / (fft_peak[n + 1] - fft_peak[n]);
-        /*calculate the fall increment */
+	
         val = 0;
-        for(i = fft_peak[n + 1]; i > fft_peak[n]; i--){ 
-            /*reverse fill the 'fall' */
+	next_peak = fft_peak[n + 1];
+	
+	/*reverse fill the 'fall' */
+        for(i = next_peak; i > fft_peak[n]; i--){ 
             fft_tables[n][i] = val;
             val += inc;
         }
+
+	/*zero the rest of the array*/
+	for(k = next_peak + 1; k < N; k++)
+	    fft_tables[n][k] = 0.f;
     }
 
-    
     free(mel_peak);
     free(lin_peak);
     free(height_norm);
--- a/src/vector.c	Sat Dec 09 15:21:35 2006 +0000
+++ b/src/vector.c	Mon Dec 11 11:21:04 2006 +0000
@@ -80,7 +80,7 @@
     int n, filter;
 
     f = (xtract_mel_filter *)argv;
-
+    
     for(filter = 0; filter < f->n_filters; filter++){
         for(n = 0; n < N; n++){
             result[filter] += data[n] * f->filters[filter][n];