summaryrefslogtreecommitdiff
path: root/gr-vocoder/lib/codec2/fft.c
diff options
context:
space:
mode:
authorTom Rondeau2011-09-26 23:23:14 -0400
committerTom Rondeau2011-09-26 23:23:14 -0400
commit4fec8eba2eb3d362319c8e09bf370edaa10cd1b9 (patch)
treee41ff025b20b5c4ad8928fa0651a06dca884dc6f /gr-vocoder/lib/codec2/fft.c
parent79e7183bda0e3850c79dee7f086a8676311607fa (diff)
parente3b56bfd879f16c2fa1f284f330ed3df6a211ec1 (diff)
downloadgnuradio-4fec8eba2eb3d362319c8e09bf370edaa10cd1b9.tar.gz
gnuradio-4fec8eba2eb3d362319c8e09bf370edaa10cd1b9.tar.bz2
gnuradio-4fec8eba2eb3d362319c8e09bf370edaa10cd1b9.zip
Merge branch 'next' into digital
Conflicts: gnuradio-core/src/lib/general/general.i gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.cc gnuradio-core/src/lib/general/gr_pll_freqdet_cf.cc gnuradio-core/src/lib/general/gr_pll_refout_cc.cc gnuradio-core/src/python/gnuradio/gr/qa_pll_carriertracking.py gnuradio-core/src/python/gnuradio/gr/qa_pll_freqdet.py gnuradio-core/src/python/gnuradio/gr/qa_pll_refout.py gr-digital/lib/digital_constellation_receiver_cb.cc gr-digital/python/Makefile.am gr-digital/python/__init__.py gr-digital/python/generic_mod_demod.py gr-digital/python/pkt.py gr-digital/python/psk2.py gr-digital/python/qam.py
Diffstat (limited to 'gr-vocoder/lib/codec2/fft.c')
-rw-r--r--gr-vocoder/lib/codec2/fft.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/gr-vocoder/lib/codec2/fft.c b/gr-vocoder/lib/codec2/fft.c
new file mode 100644
index 000000000..a33e4d2c8
--- /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)
+{
+ int isReverse = 0;
+ int c;
+ kiss_fft_cfg cfg;
+ if (cfg_forward == NULL)
+ {
+ initialize_fft (n);
+ }
+ for (c = 0; c < n * 2; c += 2)
+ {
+ fin[c / 2].r = x[c];
+ fin[c / 2].i = -x[c + 1];
+ }
+ 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;
+ }
+}