aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamie Bullock <jamie@postlude.co.uk>2006-12-11 11:21:04 +0000
committerJamie Bullock <jamie@postlude.co.uk>2006-12-11 11:21:04 +0000
commit2c568a05c53589c255f4fe9d448ff00c454c88c9 (patch)
treeaa473cfa37f96574168d85c9f27dac6b4dae123b
parent9636bf2fdb2cdb27483b47d9ab6b238a25d374d5 (diff)
downloadLibXtract-2c568a05c53589c255f4fe9d448ff00c454c88c9.tar.gz
LibXtract-2c568a05c53589c255f4fe9d448ff00c454c88c9.tar.bz2
LibXtract-2c568a05c53589c255f4fe9d448ff00c454c88c9.zip
Fixed xtract_init_mfcc
-rw-r--r--ChangeLog3
-rw-r--r--src/init.c30
-rw-r--r--src/vector.c2
3 files changed, 25 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 6355511..c1a9d18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
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
* Added -Wall to CFLAGS and corrected problems relating to warnings
diff --git a/src/init.c b/src/init.c
index 81810e9..b9fc15b 100644
--- a/src/init.c
+++ b/src/init.c
@@ -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 @@ int xtract_init_mfcc(int N, float nyquist, int style, float freq_max, float freq
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 @@ int xtract_init_mfcc(int N, float nyquist, int style, float freq_max, float freq
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;
}
- inc = height_norm[n] / (fft_peak[n + 1] - fft_peak[n]);
+
/*calculate the fall increment */
+ inc = height_norm[n] / (fft_peak[n + 1] - fft_peak[n]);
+
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);
diff --git a/src/vector.c b/src/vector.c
index 8a656cb..091e3f5 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -80,7 +80,7 @@ int xtract_mfcc(float *data, int N, void *argv, float *result){
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];