summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/general
diff options
context:
space:
mode:
authorn4hy2009-04-15 02:21:52 +0000
committern4hy2009-04-15 02:21:52 +0000
commit58bd4ceaee4884652a682297a49957137cafa56d (patch)
treef998d984a0c5f48e7617cb8380cfb894c68e04ce /gnuradio-core/src/lib/general
parentccfb7f87fe5e68025f4956dfe2ba34d0b5236f17 (diff)
downloadgnuradio-58bd4ceaee4884652a682297a49957137cafa56d.tar.gz
gnuradio-58bd4ceaee4884652a682297a49957137cafa56d.tar.bz2
gnuradio-58bd4ceaee4884652a682297a49957137cafa56d.zip
new fm detector added based on FIR derivative detector. Stereo sep better than pll based one and more efficient. Tweaking probably needed, usrp_wfm_rcv_fmdet added to demo
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10847 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src/lib/general')
-rw-r--r--gnuradio-core/src/lib/general/Makefile.am3
-rw-r--r--gnuradio-core/src/lib/general/general.i2
-rw-r--r--gnuradio-core/src/lib/general/gr_fmdet_cf.cc93
-rw-r--r--gnuradio-core/src/lib/general/gr_fmdet_cf.h58
-rw-r--r--gnuradio-core/src/lib/general/gr_fmdet_cf.i31
5 files changed, 187 insertions, 0 deletions
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am
index fa3ccd5a6..4ceb72486 100644
--- a/gnuradio-core/src/lib/general/Makefile.am
+++ b/gnuradio-core/src/lib/general/Makefile.am
@@ -79,6 +79,7 @@ libgeneral_la_SOURCES = \
gr_float_to_complex.cc \
gr_float_to_short.cc \
gr_float_to_uchar.cc \
+ gr_fmdet_cf.cc \
gr_frequency_modulator_fc.cc \
gr_fxpt.cc \
gr_framer_sink_1.cc \
@@ -230,6 +231,7 @@ grinclude_HEADERS = \
gr_float_to_complex.h \
gr_float_to_short.h \
gr_float_to_uchar.h \
+ gr_fmdet_cf.h \
gr_framer_sink_1.h \
gr_frequency_modulator_fc.h \
gr_fxpt.h \
@@ -394,6 +396,7 @@ swiginclude_HEADERS = \
gr_float_to_complex.i \
gr_float_to_short.i \
gr_float_to_uchar.i \
+ gr_fmdet_cf.i \
gr_frequency_modulator_fc.i \
gr_framer_sink_1.i \
gr_glfsr_source_b.i \
diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i
index e7d9e978e..0cb54870e 100644
--- a/gnuradio-core/src/lib/general/general.i
+++ b/gnuradio-core/src/lib/general/general.i
@@ -85,6 +85,7 @@
#include <gr_lms_dfe_cc.h>
#include <gr_lms_dfe_ff.h>
#include <gr_dpll_bb.h>
+#include <gr_fmdet_cf.h>
#include <gr_pll_freqdet_cf.h>
#include <gr_pll_refout_cc.h>
#include <gr_pll_carriertracking_cc.h>
@@ -204,6 +205,7 @@
%include "gr_lms_dfe_cc.i"
%include "gr_lms_dfe_ff.i"
%include "gr_dpll_bb.i"
+%include "gr_fmdet_cf.i"
%include "gr_pll_freqdet_cf.i"
%include "gr_pll_refout_cc.i"
%include "gr_pll_carriertracking_cc.i"
diff --git a/gnuradio-core/src/lib/general/gr_fmdet_cf.cc b/gnuradio-core/src/lib/general/gr_fmdet_cf.cc
new file mode 100644
index 000000000..c5166003c
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_fmdet_cf.cc
@@ -0,0 +1,93 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_fmdet_cf.h>
+#include <gr_io_signature.h>
+#include <math.h>
+#include <gr_math.h>
+
+#define M_TWOPI (2*M_PI)
+
+gr_fmdet_cf_sptr
+gr_make_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl)
+{
+ return gr_fmdet_cf_sptr (new gr_fmdet_cf (samplerate, freq_low, freq_high, scl));
+}
+
+gr_fmdet_cf::gr_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl)
+ : gr_sync_block ("fmdet_cf",
+ gr_make_io_signature (1, 1, sizeof (gr_complex)),
+ gr_make_io_signature (1, 1, sizeof (float))),
+ d_S1(0.1),d_S2(0.1),
+ d_S3(0.1),d_S4(0.1)
+{
+ #include <stdio.h>
+ float delta;
+ d_freqhi = freq_high;
+ d_freqlo = freq_low;
+ delta = (d_freqhi - d_freqlo);
+ d_scl = scl;
+ d_bias = 0.5*scl*(d_freqhi+d_freqlo)/delta;
+ fprintf(stderr,"delta = %f d_scl=%f d_bias=%f\n",delta,d_scl,d_bias),fflush(stderr);
+}
+
+int
+gr_fmdet_cf::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const gr_complex *iptr = (gr_complex *) input_items[0];
+ float *optr = (float *) output_items[0];
+
+ int size = noutput_items;
+
+ gr_complex Sdot,S0,S1=d_S1,S2=d_S2,S3=d_S3,S4=d_S4;
+
+ while (size-- > 0) {
+ S0=*iptr++;
+
+ Sdot = gr_complex(d_scl*
+ (-S0.real() + 8.0*S1.real() - 8.0*S3.real() + S4.real()),
+ d_scl*
+ (-S0.imag() + 8.0*S1.imag() - 8.0*S3.imag() + S4.imag()));
+ d_freq = (S2.real()*Sdot.imag()-S2.imag()*Sdot.real())/
+ (S2.real()*S2.real()+S2.imag()*S2.imag());
+
+ S4=S3;
+ S3=S2;
+ S2=S1;
+ S1=S0;
+
+
+ *optr++ = d_freq-d_bias;
+ }
+ d_S1=S1;
+ d_S2=S2;
+ d_S3=S3;
+ d_S4=S4;
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_fmdet_cf.h b/gnuradio-core/src/lib/general/gr_fmdet_cf.h
new file mode 100644
index 000000000..7e8be31b1
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_fmdet_cf.h
@@ -0,0 +1,58 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_FMDET_CF_H
+#define INCLUDED_GR_FMDET_CF_H
+
+#include <gr_sync_block.h>
+
+class gr_fmdet_cf;
+typedef boost::shared_ptr<gr_fmdet_cf> gr_fmdet_cf_sptr;
+
+gr_fmdet_cf_sptr gr_make_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl);
+
+/*!
+ * \brief Implements an IQ slope detector
+ *
+ *
+ * input: stream of complex; output: stream of floats
+ *
+ * This implements a limiting slope detector. The limiter is in the
+ * normalization by the magnitude of the sample
+ */
+
+class gr_fmdet_cf : public gr_sync_block
+{
+ friend gr_fmdet_cf_sptr gr_make_fmdet_cf (float samplerate, float freq_low,
+ float freq_high, float scl);
+
+ gr_complex d_S1,d_S2,d_S3,d_S4;
+ float d_freq,d_freqlo,d_freqhi,d_scl,d_bias;
+ gr_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl);
+
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+};
+
+#endif
diff --git a/gnuradio-core/src/lib/general/gr_fmdet_cf.i b/gnuradio-core/src/lib/general/gr_fmdet_cf.i
new file mode 100644
index 000000000..e1da717ce
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_fmdet_cf.i
@@ -0,0 +1,31 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,fmdet_cf)
+
+gr_fmdet_cf_sptr gr_make_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl);
+
+class gr_fmdet_cf : public gr_sync_block
+{
+ private:
+ gr_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl);
+};