From b409a4b0c6131e01fc5a03c0fc31caa4829b0dec Mon Sep 17 00:00:00 2001
From: Johnathan Corgan <jcorgan@corganenterprises.com>
Date: Mon, 18 Jul 2011 15:54:43 -0700
Subject: gr-vocoder: re-implemented gr-codec2-vocoder inside gr-vocoder

---
 gr-vocoder/lib/codec2/fft.c | 101 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 101 insertions(+)
 create mode 100644 gr-vocoder/lib/codec2/fft.c

(limited to 'gr-vocoder/lib/codec2/fft.c')

diff --git a/gr-vocoder/lib/codec2/fft.c b/gr-vocoder/lib/codec2/fft.c
new file mode 100644
index 0000000000..73c46c846f
--- /dev/null
+++ b/gr-vocoder/lib/codec2/fft.c
@@ -0,0 +1,101 @@
+/*---------------------------------------------------------------------------*\
+                                                 
+  FILE........: fft.c                                                  
+  AUTHOR......: Bruce Robertson                                      
+  DATE CREATED: 20/11/2010                            
+                                                         
+  Bridging function to the kiss_fft package.      
+                                                               
+\*---------------------------------------------------------------------------*/
+
+/*
+  Copyright (C) 2010 Bruce Robertson
+
+  All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License version 2.1, as
+  published by the Free Software Foundation.  This program is
+  distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+  License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <assert.h>
+#include "kiss_fft.h"
+
+/*---------------------------------------------------------------------------*\
+                                                                            
+                                GLOBALS                                       
+                                                                             
+\*---------------------------------------------------------------------------*/
+
+kiss_fft_cpx *fin;
+kiss_fft_cpx *fout;
+kiss_fft_cfg cfg_forward;
+kiss_fft_cfg cfg_reverse;
+
+/*---------------------------------------------------------------------------*\
+                                                                             
+  initialize_fft(int n)                                                                  
+                                                                             
+  Initialisation function for kiss_fft. This assumes that all calls to fft() 
+  use the same datatypes and are one arrays of the same size.
+
+\*---------------------------------------------------------------------------*/
+
+void
+initialize_fft (int n)
+{
+  fin = KISS_FFT_MALLOC (n * sizeof (kiss_fft_cpx));
+  assert(fin != NULL);
+  fout = KISS_FFT_MALLOC (n * sizeof (kiss_fft_cpx));
+  assert(fout != NULL);
+  cfg_forward = kiss_fft_alloc (n, 0, NULL, NULL);
+  assert(cfg_forward != NULL);
+  cfg_reverse = kiss_fft_alloc (n, 1, NULL, NULL);
+  assert(cfg_reverse != NULL);
+}
+
+/*---------------------------------------------------------------------------*\
+                                                                             
+  fft(float x[], int n, int isign)                                                
+  Function that calls kiss_fft with the signature of four1 from NRC.
+
+\*---------------------------------------------------------------------------*/
+
+
+void
+fft (float x[], int n, int isign)
+{
+  if (cfg_forward == NULL)
+    {
+      initialize_fft (n);
+    }
+  int isReverse = 0;
+  int c;
+  for (c = 0; c < n * 2; c += 2)
+    {
+      fin[c / 2].r = x[c];
+      fin[c / 2].i = -x[c + 1];
+    }
+  kiss_fft_cfg cfg;
+  if (isign == -1)
+    {
+      cfg = cfg_reverse;
+    }
+  else
+    {
+      cfg = cfg_forward;
+    }
+  kiss_fft (cfg, fin, fout);
+  for (c = 0; c < n * 2; c += 2)
+    {
+      x[c] = fout[(c) / 2].r;
+      x[c + 1] = -fout[(c) / 2].i;
+    }
+}
-- 
cgit v1.2.3