added HPF function enables synthesis of 3500-4000hZ as some samples have unvoiced...
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 16 Nov 2010 09:32:48 +0000 (09:32 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 16 Nov 2010 09:32:48 +0000 (09:32 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@234 01035d8c-6547-0410-b346-abe4f91aad63

codec2/src/sine.c

index c79ded8868c090d06574385bdf0b90d035e016d9..974f315ebb0b398fa5d430d705faa71dff6a5f0d 100644 (file)
@@ -39,6 +39,8 @@
 #include "sine.h"
 #include "four1.h"
 
+#define HPF_BETA 0.125
+
 /*---------------------------------------------------------------------------*\
                                                                              
                                HEADERS                                     
@@ -166,6 +168,26 @@ void make_analysis_window(float w[],COMP W[])
 
 }
 
+/*---------------------------------------------------------------------------*\
+                                                       
+  FUNCTION....: hpf         
+  AUTHOR......: David Rowe                           
+  DATE CREATED: 16 Nov 2010
+
+  High pass filter with a -3dB point of about 160Hz.
+
+    y(n) = -HPF_BETA*y(n-1) + x(n) - x(n-1)
+\*---------------------------------------------------------------------------*/
+
+float hpf(float x, float states[])
+{
+    states[0] += -HPF_BETA*states[0] + x - states[1];
+    states[1] = x;
+
+    return states[0];
+}
+
 /*---------------------------------------------------------------------------*\
                                                        
   FUNCTION....: dft_speech          
@@ -577,15 +599,6 @@ void synthesise(
        Sw_[FFT_DEC-b].imag = -Sw_[b].imag;
     }
 
-    /* zero out anything above 3500 Hz */
-
-    for(i=(3500.0/4000.0)*FFT_DEC/2; i<FFT_DEC/2; i++) {
-       Sw_[i].real = 0.0;
-       Sw_[i].imag = 0.0;
-       Sw_[FFT_DEC-i].real = 0.0;
-       Sw_[FFT_DEC-i].imag = 0.0;
-    }
-
     /* Perform inverse DFT */
 
     four1(&Sw_[-1].imag,FFT_DEC,1);