[xiph-commits] r11916 - trunk/speex/libspeex

jm at svn.xiph.org jm at svn.xiph.org
Wed Oct 11 07:44:15 PDT 2006


Author: jm
Date: 2006-10-11 07:44:12 -0700 (Wed, 11 Oct 2006)
New Revision: 11916

Modified:
   trunk/speex/libspeex/filterbank.c
Log:
Added Bark filter bank. Need to make the Bark/Mel choice a proper option.


Modified: trunk/speex/libspeex/filterbank.c
===================================================================
--- trunk/speex/libspeex/filterbank.c	2006-10-11 14:22:11 UTC (rev 11915)
+++ trunk/speex/libspeex/filterbank.c	2006-10-11 14:44:12 UTC (rev 11916)
@@ -39,13 +39,16 @@
 #include "misc.h"
 #include <math.h>
 
+#define toBARK(n)   (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n))
+#define toMEL(n)    (2595.f*log10(1.f+(n)/700.f))
+
 FilterBank *filterbank_new(int banks, float max_freq, float sampling, int len, int type)
 {
    FilterBank *bank;
    float df, max_mel, mel_interval;
    int i;
    df = .5*sampling/len;
-   max_mel = 2595*log10(1+max_freq/700);
+   max_mel = toBARK(max_freq);
    mel_interval = max_mel/(banks-1);
    
    bank = speex_alloc(sizeof(FilterBank));
@@ -65,7 +68,7 @@
       float mel;
       float val;
       curr_freq = i*df;
-      mel = 2595*log10(1+curr_freq/700);
+      mel = toBARK(curr_freq);
       if (mel > max_mel)
          break;
       id1 = (int)(floor(mel/mel_interval));



More information about the commits mailing list