diff options
34 files changed, 241 insertions, 1385 deletions
diff --git a/docs/doxygen/other/pfb_intro.dox b/docs/doxygen/other/pfb_intro.dox index 429e8fe5b6..504ae87b87 100644 --- a/docs/doxygen/other/pfb_intro.dox +++ b/docs/doxygen/other/pfb_intro.dox @@ -64,9 +64,9 @@ defined to use a sample rate of \p filter_size times the signal's sampling rate. A helpful wrapper for the arbitrary resampler is found in -<b>gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py</b>, -which is exposed in Python as <b>blks2.pfb_arb_resampler_ccf</b> and -<b>blks2.pfb_arb_resampler_fff</b>. This block is set up so that the +<b>gr-filter/python/pfb.py</b>, +which is exposed in Python as <b>filter.pfb.arb_resampler_ccf</b> and +<b>filter.pfb.arb_resampler_fff</b>. This block is set up so that the user only needs to pass it the real number \p rate as the resampling rate. With just this information, this hierarchical block automatically creates a filter that fully passes the signal bandwidth diff --git a/docs/sphinx/source/blks2/blks.rst b/docs/sphinx/source/blks2/blks.rst index c28c7af0f8..6510169710 100644 --- a/docs/sphinx/source/blks2/blks.rst +++ b/docs/sphinx/source/blks2/blks.rst @@ -1,31 +1,9 @@ gnuradio.blks2: Signal Processing Blocks ======================================== -.. autopyblock:: gnuradio.blks2.am_demod_cf -.. autopyblock:: gnuradio.blks2.ctcss_gen_f -.. autopyblock:: gnuradio.blks2.demod_10k0a3e_cf -.. autopyblock:: gnuradio.blks2.demod_200kf3e_cf -.. autopyblock:: gnuradio.blks2.demod_20k0f3e_cf -.. autopyblock:: gnuradio.blks2.fm_demod_cf -.. autopyblock:: gnuradio.blks2.logpwrfft_c -.. autopyblock:: gnuradio.blks2.logpwrfft_f -.. autopyblock:: gnuradio.blks2.pfb_arb_resampler_ccf -.. autopyblock:: gnuradio.blks2.pfb_arb_resampler_fff -.. autopyblock:: gnuradio.blks2.pfb_channelizer_ccf -.. autopyblock:: gnuradio.blks2.pfb_decimator_ccf -.. autopyblock:: gnuradio.blks2.pfb_interpolator_ccf .. autopyblock:: gnuradio.blks2.rational_resampler_ccc .. autopyblock:: gnuradio.blks2.rational_resampler_ccf .. autopyblock:: gnuradio.blks2.rational_resampler_fff .. autopyblock:: gnuradio.blks2.analysis_filterbank -.. autopyblock:: gnuradio.blks2.fm_deemph -.. autopyblock:: gnuradio.blks2.fm_preemph -.. autopyblock:: gnuradio.blks2.nbfm_rx -.. autopyblock:: gnuradio.blks2.nbfm_tx .. autopyblock:: gnuradio.blks2.stream_to_vector_decimator -.. autopyblock:: gnuradio.blks2.standard_squelch .. autopyblock:: gnuradio.blks2.synthesis_filterbank -.. autopyblock:: gnuradio.blks2.wfm_rcv -.. autopyblock:: gnuradio.blks2.wfm_rcv_fmdet -.. autopyblock:: gnuradio.blks2.wfm_rcv_pll -.. autopyblock:: gnuradio.blks2.wfm_tx diff --git a/docs/sphinx/source/blks2/index.rst b/docs/sphinx/source/blks2/index.rst index 4df8e5a796..7a911d001b 100644 --- a/docs/sphinx/source/blks2/index.rst +++ b/docs/sphinx/source/blks2/index.rst @@ -8,35 +8,13 @@ Signal Processing Blocks .. autosummary:: :nosignatures: - - gnuradio.blks2.am_demod_cf - gnuradio.blks2.ctcss_gen_f - gnuradio.blks2.demod_10k0a3e_cf - gnuradio.blks2.demod_200kf3e_cf - gnuradio.blks2.demod_20k0f3e_cf - gnuradio.blks2.fm_demod_cf - gnuradio.blks2.logpwrfft_c - gnuradio.blks2.logpwrfft_f - gnuradio.blks2.pfb_arb_resampler_ccf - gnuradio.blks2.pfb_arb_resampler_fff - gnuradio.blks2.pfb_channelizer_ccf - gnuradio.blks2.pfb_decimator_ccf - gnuradio.blks2.pfb_interpolator_ccf + gnuradio.blks2.rational_resampler_ccc gnuradio.blks2.rational_resampler_ccf gnuradio.blks2.rational_resampler_fff gnuradio.blks2.analysis_filterbank - gnuradio.blks2.fm_deemph - gnuradio.blks2.fm_preemph - gnuradio.blks2.nbfm_rx - gnuradio.blks2.nbfm_tx gnuradio.blks2.stream_to_vector_decimator - gnuradio.blks2.standard_squelch gnuradio.blks2.synthesis_filterbank - gnuradio.blks2.wfm_rcv - gnuradio.blks2.wfm_rcv_fmdet - gnuradio.blks2.wfm_rcv_pll - gnuradio.blks2.wfm_tx Utility Functions ----------------- diff --git a/docs/sphinx/source/gr/index.rst b/docs/sphinx/source/gr/index.rst index df218ab9f8..06f88c4ee1 100644 --- a/docs/sphinx/source/gr/index.rst +++ b/docs/sphinx/source/gr/index.rst @@ -249,12 +249,8 @@ Signal Level Control (AGC) .. autosummary:: :nosignatures: - gnuradio.gr.ctcss_squelch_ff gnuradio.gr.peak_detector2_fb - gnuradio.gr.pwr_squelch_cc - gnuradio.gr.pwr_squelch_ff gnuradio.gr.regenerate_bb - gnuradio.gr.simple_squelch_cc gnuradio.gr.mute_cc gnuradio.gr.mute_ff gnuradio.gr.mute_ii diff --git a/docs/sphinx/source/gr/level_blk.rst b/docs/sphinx/source/gr/level_blk.rst index 1be9f2ffaa..0eacb67230 100644 --- a/docs/sphinx/source/gr/level_blk.rst +++ b/docs/sphinx/source/gr/level_blk.rst @@ -1,13 +1,9 @@ gnuradio.gr: Signal Level Control (AGC) ======================================= -.. autooldblock:: gnuradio.gr.ctcss_squelch_ff .. autooldblock:: gnuradio.gr.dpll_bb .. autooldblock:: gnuradio.gr.peak_detector2_fb -.. autooldblock:: gnuradio.gr.pwr_squelch_cc -.. autooldblock:: gnuradio.gr.pwr_squelch_ff .. autooldblock:: gnuradio.gr.regenerate_bb -.. autooldblock:: gnuradio.gr.simple_squelch_cc .. autooldblock:: gnuradio.gr.mute_cc .. autooldblock:: gnuradio.gr.mute_ff .. autooldblock:: gnuradio.gr.mute_ii diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index ced366903c..ff73dd91f6 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -178,7 +178,6 @@ set(gr_core_general_triple_threats gr_copy gr_cpfsk_bc gr_cpm - gr_ctcss_squelch_ff gr_decode_ccsds_27_fb gr_deinterleave gr_delay @@ -216,8 +215,6 @@ set(gr_core_general_triple_threats gr_peak_detector2_fb gr_phase_modulator_fc gr_prefs - gr_pwr_squelch_cc - gr_pwr_squelch_ff gr_quadrature_demod_cf gr_rail_ff gr_regenerate_bb @@ -228,10 +225,7 @@ set(gr_core_general_triple_threats gr_short_to_float gr_short_to_char gr_simple_correlator - gr_simple_squelch_cc gr_skiphead - gr_squelch_base_cc - gr_squelch_base_ff gr_stream_mux gr_stream_to_streams gr_stream_to_vector diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 6cac23aac4..96b7e48d63 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -61,7 +61,6 @@ #include <gr_interleave.h> #include <gr_deinterleave.h> #include <gr_delay.h> -#include <gr_simple_squelch_cc.h> #include <gr_rms_cf.h> #include <gr_rms_ff.h> #include <gr_nlog10_ff.h> @@ -92,9 +91,6 @@ #include <gr_multiply_const_ff.h> #include <gr_multiply_conjugate_cc.h> #include <gr_feval.h> -#include <gr_pwr_squelch_cc.h> -#include <gr_pwr_squelch_ff.h> -#include <gr_ctcss_squelch_ff.h> #include <gr_bin_statistics_f.h> #include <gr_peak_detector2_fb.h> #include <gr_repeat.h> @@ -154,7 +150,6 @@ %include "gr_interleave.i" %include "gr_deinterleave.i" %include "gr_delay.i" -%include "gr_simple_squelch_cc.i" %include "gr_rms_cf.i" %include "gr_rms_ff.i" %include "gr_nlog10_ff.i" @@ -185,9 +180,6 @@ %include "gr_multiply_const_ff.i" %include "gr_multiply_conjugate_cc.i" %include "gr_feval.i" -%include "gr_pwr_squelch_cc.i" -%include "gr_pwr_squelch_ff.i" -%include "gr_ctcss_squelch_ff.i" %include "gr_bin_statistics_f.i" %include "gr_peak_detector2_fb.i" %include "gr_repeat.i" diff --git a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.cc b/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.cc deleted file mode 100644 index d31763a6bf..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.cc +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 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_ctcss_squelch_ff.h> - -static float ctcss_tones[] = { - 67.0, 71.9, 74.4, 77.0, 79.7, 82.5, 85.4, 88.5, 91.5, 94.8, - 97.4, 100.0, 103.5, 107.2, 110.9, 114.8, 118.8, 123.0, 127.3, 131.8, - 136.5, 141.3, 146.2, 151.4, 156.7, 162.2, 167.9, 173.8, 179.9, 186.2, - 192.8, 203.5, 210.7, 218.1, 225.7, 233.6, 241.8, 250.3 -}; - -static int max_tone_index = 37; - -gr_ctcss_squelch_ff_sptr -gr_make_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, bool gate) -{ - return gnuradio::get_initial_sptr(new gr_ctcss_squelch_ff(rate, freq, level, len, ramp, gate)); -} - -int gr_ctcss_squelch_ff::find_tone(float freq) -{ - for (int i = 0; i <= max_tone_index; i++) - if (ctcss_tones[i] == freq) // FIXME: make almost equal - return i; - - return -1; -} - -gr_ctcss_squelch_ff::gr_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, bool gate) : - gr_squelch_base_ff("ctcss_squelch_ff", ramp, gate) -{ - d_freq = freq; - d_level = level; - - // Default is 100 ms detection time - if (len == 0) - d_len = (int)(rate/10.0); - else - d_len = len; - - int i = find_tone(freq); - - // Non-standard tones or edge tones get 2% guard band, otherwise - // guards are set at adjacent ctcss tone frequencies - float f_l, f_r; - if (i == -1 || i == 0) - f_l = freq*0.98; - else - f_l = ctcss_tones[i-1]; - - if (i == -1 || i == max_tone_index) - f_r = freq*1.02; - else - f_r = ctcss_tones[i+1]; - - d_goertzel_l = gri_goertzel(rate, d_len, f_l); - d_goertzel_c = gri_goertzel(rate, d_len, freq); - d_goertzel_r = gri_goertzel(rate, d_len, f_r); - - d_mute = true; -} - -std::vector<float> gr_ctcss_squelch_ff::squelch_range() const -{ - std::vector<float> r(3); - r[0] = 0.0; - r[1] = 1.0; - r[2] = (r[1]-r[0])/100; // step size - - return r; -} - -void gr_ctcss_squelch_ff::update_state(const float &in) -{ - d_goertzel_l.input(in); - d_goertzel_c.input(in); - d_goertzel_r.input(in); - - float d_out_l, d_out_c, d_out_r; - if (d_goertzel_c.ready()) { - d_out_l = abs(d_goertzel_l.output()); - d_out_c = abs(d_goertzel_c.output()); - d_out_r = abs(d_goertzel_r.output()); - - //printf("d_out_l=%f d_out_c=%f d_out_r=%f\n", d_out_l, d_out_c, d_out_r); - d_mute = (d_out_c < d_level || d_out_c < d_out_l || d_out_c < d_out_r); - } -} diff --git a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.h b/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.h deleted file mode 100644 index ef3d13ba7b..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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_CTCSS_SQUELCH_FF_H -#define INCLUDED_GR_CTCSS_SQUELCH_FF_H - -#include <gr_core_api.h> -#include <gr_squelch_base_ff.h> -#include <gri_goertzel.h> - -class gr_ctcss_squelch_ff; -typedef boost::shared_ptr<gr_ctcss_squelch_ff> gr_ctcss_squelch_ff_sptr; - -GR_CORE_API gr_ctcss_squelch_ff_sptr -gr_make_ctcss_squelch_ff(int rate, float freq, float level=0.01, int len=0, int ramp=0, bool gate=false); - -/*! - * \brief gate or zero output if ctcss tone not present - * \ingroup level_blk - */ -class GR_CORE_API gr_ctcss_squelch_ff : public gr_squelch_base_ff -{ -private: - float d_freq; - float d_level; - int d_len; - bool d_mute; - - gri_goertzel d_goertzel_l; - gri_goertzel d_goertzel_c; - gri_goertzel d_goertzel_r; - - friend GR_CORE_API gr_ctcss_squelch_ff_sptr gr_make_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, bool gate); - gr_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, bool gate); - - int find_tone(float freq); - -protected: - virtual void update_state(const float &in); - virtual bool mute() const { return d_mute; } - -public: - std::vector<float> squelch_range() const; - float level() const { return d_level; } - void set_level(float level) { d_level = level; } - int len() const { return d_len; } -}; - -#endif /* INCLUDED_GR_CTCSS_SQUELCH_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.i b/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.i deleted file mode 100644 index b160c5dfd7..0000000000 --- a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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,ctcss_squelch_ff); - -%include gr_squelch_base_ff.i - -gr_ctcss_squelch_ff_sptr -gr_make_ctcss_squelch_ff(int rate, float freq, float level=0.01, int len=0, int ramp=0, bool gate=false); - -class gr_ctcss_squelch_ff : public gr_squelch_base_ff -{ - gr_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, bool gate); - -public: - std::vector<float> squelch_range() const; - float level() const { return d_level; } - void set_level(float level) { d_level = level; } - int len() const { return d_len; } -}; diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.cc b/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.cc deleted file mode 100644 index 90eab13eba..0000000000 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 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_pwr_squelch_cc.h> - -gr_pwr_squelch_cc_sptr -gr_make_pwr_squelch_cc(double threshold, double alpha, int ramp, bool gate) -{ - return gnuradio::get_initial_sptr(new gr_pwr_squelch_cc(threshold, alpha, ramp, gate)); -} - -gr_pwr_squelch_cc::gr_pwr_squelch_cc(double threshold, double alpha, int ramp, bool gate) : - gr_squelch_base_cc("pwr_squelch_cc", ramp, gate), - d_iir(alpha) -{ - set_threshold(threshold); -} - -std::vector<float> gr_pwr_squelch_cc::squelch_range() const -{ - std::vector<float> r(3); - r[0] = -50.0; // min FIXME - r[1] = +50.0; // max FIXME - r[2] = (r[1] - r[0]) / 100; // step size - - return r; -} - -void gr_pwr_squelch_cc::update_state(const gr_complex &in) -{ - d_pwr = d_iir.filter(in.real()*in.real()+in.imag()*in.imag()); -} diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.h b/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.h deleted file mode 100644 index b2b4624f58..0000000000 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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_PWR_SQUELCH_CC_H -#define INCLUDED_GR_PWR_SQUELCH_CC_H - -#include <gr_core_api.h> -#include <cmath> -#include <gr_squelch_base_cc.h> -#include <gr_single_pole_iir.h> - -class gr_pwr_squelch_cc; -typedef boost::shared_ptr<gr_pwr_squelch_cc> gr_pwr_squelch_cc_sptr; - -GR_CORE_API gr_pwr_squelch_cc_sptr -gr_make_pwr_squelch_cc(double db, double alpha = 0.0001, int ramp=0, bool gate=false); - -/*! - * \brief gate or zero output when input power below threshold - * \ingroup level_blk - */ -class GR_CORE_API gr_pwr_squelch_cc : public gr_squelch_base_cc -{ -private: - double d_threshold; - double d_pwr; - gr_single_pole_iir<double,double,double> d_iir; - - friend GR_CORE_API gr_pwr_squelch_cc_sptr gr_make_pwr_squelch_cc(double db, double alpha, int ramp, bool gate); - gr_pwr_squelch_cc(double db, double alpha, int ramp, bool gate); - -protected: - virtual void update_state(const gr_complex &in); - virtual bool mute() const { return d_pwr < d_threshold; } - -public: - std::vector<float> squelch_range() const; - - double threshold() const { return 10*log10(d_threshold); } - void set_threshold(double db) { d_threshold = std::pow(10.0, db/10); } - void set_alpha(double alpha) { d_iir.set_taps(alpha); } -}; - -#endif /* INCLUDED_GR_PWR_SQUELCH_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.i b/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.i deleted file mode 100644 index c8cafd7aac..0000000000 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.i +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009 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,pwr_squelch_cc); - -// retrieve info on the base class, without generating wrappers since -// the base class has a pure virual method. -%import "gr_squelch_base_cc.i" - -gr_pwr_squelch_cc_sptr -gr_make_pwr_squelch_cc(double db, double alpha=0.0001, int ramp=0, bool gate=false); - -class gr_pwr_squelch_cc : public gr_squelch_base_cc -{ -private: - gr_pwr_squelch_cc(double db, double alpha, int ramp, bool gate); - -public: - double threshold() const { return 10*log10(d_threshold); } - void set_threshold(double db) { d_threshold = std::pow(10.0, db/10); } - void set_alpha(double alpha) { d_iir.set_taps(alpha); } - std::vector<float> squelch_range() const; -}; diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.cc b/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.cc deleted file mode 100644 index cfa867243d..0000000000 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2010 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_pwr_squelch_ff.h> - -gr_pwr_squelch_ff_sptr -gr_make_pwr_squelch_ff(double threshold, double alpha, int ramp, bool gate) -{ - return gnuradio::get_initial_sptr(new gr_pwr_squelch_ff(threshold, alpha, ramp, gate)); -} - -gr_pwr_squelch_ff::gr_pwr_squelch_ff(double threshold, double alpha, int ramp, bool gate) : - gr_squelch_base_ff("pwr_squelch_ff", ramp, gate), - d_iir(alpha) -{ - set_threshold(threshold); -} - -std::vector<float> gr_pwr_squelch_ff::squelch_range() const -{ - std::vector<float> r(3); - r[0] = -50.0; // min FIXME - r[1] = +50.0; // max FIXME - r[2] = (r[1] - r[0]) / 100; // step size - - return r; -} - -void gr_pwr_squelch_ff::update_state(const float &in) -{ - d_pwr = d_iir.filter(in*in); -} diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.h b/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.h deleted file mode 100644 index d5148c4096..0000000000 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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_PWR_SQUELCH_FF_H -#define INCLUDED_GR_PWR_SQUELCH_FF_H - -#include <gr_core_api.h> -#include <cmath> -#include <gr_squelch_base_ff.h> -#include <gr_single_pole_iir.h> - -class gr_pwr_squelch_ff; -typedef boost::shared_ptr<gr_pwr_squelch_ff> gr_pwr_squelch_ff_sptr; - -GR_CORE_API gr_pwr_squelch_ff_sptr -gr_make_pwr_squelch_ff(double db, double alpha = 0.0001, int ramp=0, bool gate=false); - -/*! - * \brief gate or zero output when input power below threshold - * \ingroup level_blk - */ -class GR_CORE_API gr_pwr_squelch_ff : public gr_squelch_base_ff -{ -private: - double d_threshold; - double d_pwr; - gr_single_pole_iir<double,double,double> d_iir; - - friend GR_CORE_API gr_pwr_squelch_ff_sptr gr_make_pwr_squelch_ff(double db, double alpha, int ramp, bool gate); - gr_pwr_squelch_ff(double db, double alpha, int ramp, bool gate); - -protected: - virtual void update_state(const float &in); - virtual bool mute() const { return d_pwr < d_threshold; } - -public: - std::vector<float> squelch_range() const; - - double threshold() const { return 10*log10(d_threshold); } - void set_threshold(double db) { d_threshold = std::pow(10.0, db/10); } - void set_alpha(double alpha) { d_iir.set_taps(alpha); } -}; - -#endif /* INCLUDED_GR_PWR_SQUELCH_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.i b/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.i deleted file mode 100644 index 2682f27586..0000000000 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.i +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009 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,pwr_squelch_ff); - -// retrieve info on the base class, without generating wrappers since -// the base class has a pure virual method. -%import "gr_squelch_base_ff.i" - -gr_pwr_squelch_ff_sptr -gr_make_pwr_squelch_ff(double db, double alpha=0.0001, int ramp=0, bool gate=false); - -class gr_pwr_squelch_ff : public gr_squelch_base_ff -{ -private: - gr_pwr_squelch_ff(double db, double alpha, int ramp, bool gate); - -public: - double threshold() const { return 10*log10(d_threshold); } - void set_threshold(double db) { d_threshold = std::pow(10.0, db/10); } - void set_alpha(double alpha) { d_iir.set_taps(alpha); } - std::vector<float> squelch_range() const; -}; diff --git a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.cc b/gnuradio-core/src/lib/general/gr_simple_squelch_cc.cc deleted file mode 100644 index 5d90a3da48..0000000000 --- a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.cc +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 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_simple_squelch_cc.h> -#include <gr_io_signature.h> -#include <cmath> - -gr_simple_squelch_cc_sptr -gr_make_simple_squelch_cc(double threshold_db, double alpha) -{ - return gnuradio::get_initial_sptr(new gr_simple_squelch_cc(threshold_db, alpha)); -} - -gr_simple_squelch_cc::gr_simple_squelch_cc (double threshold_db, double alpha) - : gr_sync_block ("simple_squelch_cc", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(1, 1, sizeof(gr_complex))), - d_iir(alpha), d_unmuted(false) -{ - set_threshold (threshold_db); -} - -gr_simple_squelch_cc::~gr_simple_squelch_cc() -{ -} - - -int -gr_simple_squelch_cc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - for (int i = 0; i < noutput_items; i++){ - double mag_sqrd = in[i].real()*in[i].real() + in[i].imag()*in[i].imag(); - double f = d_iir.filter(mag_sqrd); - if (f >= d_threshold) - out[i] = in[i]; - else - out[i] = 0; - } - - d_unmuted = d_iir.prev_output() >= d_threshold; - return noutput_items; -} - -void -gr_simple_squelch_cc::set_threshold(double decibels) -{ - // convert to absolute threshold (mag squared) - d_threshold = std::pow(10.0, decibels/10); -} - -double -gr_simple_squelch_cc::threshold() const -{ - return 10 * log10(d_threshold); -} - -void -gr_simple_squelch_cc::set_alpha(double alpha) -{ - d_iir.set_taps(alpha); -} - -std::vector<float> -gr_simple_squelch_cc::squelch_range() const -{ - std::vector<float> r(3); - r[0] = -50.0; // min FIXME - r[1] = +50.0; // max FIXME - r[2] = (r[1] - r[0]) / 100; // step size - - return r; -} diff --git a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.h b/gnuradio-core/src/lib/general/gr_simple_squelch_cc.h deleted file mode 100644 index 4bf62c7ec6..0000000000 --- a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_SIMPLE_SQUELCH_CC_H -#define INCLUDED_GR_SIMPLE_SQUELCH_CC_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_single_pole_iir.h> - -class gr_simple_squelch_cc; -typedef boost::shared_ptr<gr_simple_squelch_cc> gr_simple_squelch_cc_sptr; - -GR_CORE_API gr_simple_squelch_cc_sptr -gr_make_simple_squelch_cc (double threshold_db, double alpha = 0.0001); - -/*! - * \brief simple squelch block based on average signal power and threshold in dB. - * \ingroup level_blk - */ -class GR_CORE_API gr_simple_squelch_cc : public gr_sync_block -{ - double d_threshold; - gr_single_pole_iir<double,double,double> d_iir; - bool d_unmuted; - - friend GR_CORE_API gr_simple_squelch_cc_sptr - gr_make_simple_squelch_cc (double threshold_db, double alpha); - - gr_simple_squelch_cc (double threshold_db, double alpha); - -public: - ~gr_simple_squelch_cc (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - bool unmuted () const { return d_unmuted; } - - void set_alpha (double alpha); - void set_threshold (double decibels); - - double threshold() const; - std::vector<float> squelch_range() const; - -}; - -#endif /* INCLUDED_GR_SIMPLE_SQUELCH_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.i b/gnuradio-core/src/lib/general/gr_simple_squelch_cc.i deleted file mode 100644 index 17b469e156..0000000000 --- a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.i +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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,simple_squelch_cc); - -gr_simple_squelch_cc_sptr -gr_make_simple_squelch_cc (double threshold_db, double alpha = 0.0001); - -class gr_simple_squelch_cc : public gr_sync_block -{ -public: - bool unmuted () const { return d_unmuted; } - void set_alpha (double alpha); - void set_threshold (double decibels); - - double threshold() const; - std::vector<float> squelch_range() const; -}; diff --git a/gnuradio-core/src/lib/general/gr_squelch_base_cc.cc b/gnuradio-core/src/lib/general/gr_squelch_base_cc.cc deleted file mode 100644 index b32a0a6954..0000000000 --- a/gnuradio-core/src/lib/general/gr_squelch_base_cc.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 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_squelch_base_cc.h> -#include <gr_io_signature.h> - -gr_squelch_base_cc::gr_squelch_base_cc(const char *name, int ramp, bool gate) : - gr_block(name, - gr_make_io_signature(1, 1, sizeof(gr_complex)), - gr_make_io_signature(1, 1, sizeof(gr_complex))) -{ - set_ramp(ramp); - set_gate(gate); - d_state = ST_MUTED; - d_envelope = d_ramp ? 0.0 : 1.0; - d_ramped = 0; -} - -int gr_squelch_base_cc::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - int j = 0; - - for (int i = 0; i < noutput_items; i++) { - update_state(in[i]); - - // Adjust envelope based on current state - switch(d_state) { - case ST_MUTED: - if (!mute()) - d_state = d_ramp ? ST_ATTACK : ST_UNMUTED; // If not ramping, go straight to unmuted - break; - - case ST_UNMUTED: - if (mute()) - d_state = d_ramp ? ST_DECAY : ST_MUTED; // If not ramping, go straight to muted - break; - - case ST_ATTACK: - d_envelope = 0.5-std::cos(M_PI*(++d_ramped)/d_ramp)/2.0; // FIXME: precalculate window for speed - if (d_ramped >= d_ramp) { // use >= in case d_ramp is set to lower value elsewhere - d_state = ST_UNMUTED; - d_envelope = 1.0; - } - break; - - case ST_DECAY: - d_envelope = 0.5-std::cos(M_PI*(--d_ramped)/d_ramp)/2.0; // FIXME: precalculate window for speed - if (d_ramped == 0.0) - d_state = ST_MUTED; - break; - }; - - // If unmuted, copy input times envelope to output - // Otherwise, if not gating, copy zero to output - if (d_state != ST_MUTED) - out[j++] = in[i]*gr_complex(d_envelope, 0.0); - else - if (!d_gate) - out[j++] = 0.0; - } - - consume_each(noutput_items); // Use all the inputs - return j; // But only report outputs copied -} diff --git a/gnuradio-core/src/lib/general/gr_squelch_base_cc.h b/gnuradio-core/src/lib/general/gr_squelch_base_cc.h deleted file mode 100644 index f1814473fb..0000000000 --- a/gnuradio-core/src/lib/general/gr_squelch_base_cc.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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_SQUELCH_BASE_CC_H -#define INCLUDED_GR_SQUELCH_BASE_CC_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class GR_CORE_API gr_squelch_base_cc : public gr_block -{ -private: - int d_ramp; - int d_ramped; - bool d_gate; - double d_envelope; - enum { ST_MUTED, ST_ATTACK, ST_UNMUTED, ST_DECAY } d_state; - -protected: - virtual void update_state(const gr_complex &sample) {}; - virtual bool mute() const { return false; }; - -public: - gr_squelch_base_cc(const char *name, int ramp, bool gate); - - int ramp() const { return d_ramp; } - void set_ramp(int ramp) { d_ramp = ramp; } - bool gate() const { return d_gate; } - void set_gate(bool gate) { d_gate = gate; } - bool unmuted() const { return (d_state == ST_UNMUTED || d_state == ST_ATTACK); } - - virtual std::vector<float> squelch_range() const = 0; - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_SQUELCH_BASE_CC_H */ diff --git a/gnuradio-core/src/lib/general/gr_squelch_base_cc.i b/gnuradio-core/src/lib/general/gr_squelch_base_cc.i deleted file mode 100644 index 6501b7d2bf..0000000000 --- a/gnuradio-core/src/lib/general/gr_squelch_base_cc.i +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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. - */ - -#include <gr_block.h> - -class gr_squelch_base_cc : public gr_block -{ -private: - enum { ST_MUTED, ST_ATTACK, ST_UNMUTED, ST_DECAY } d_state; - -public: - gr_squelch_base_cc(const char *name, int ramp, bool gate); - - int ramp() const { return d_ramp; } - void set_ramp(int ramp) { d_ramp = ramp; } - bool gate() const { return d_gate; } - void set_gate(bool gate) { d_gate = gate; } - bool unmuted() const { return (d_state == ST_UNMUTED || d_state == ST_ATTACK); } - - virtual std::vector<float> squelch_range() const = 0; -}; diff --git a/gnuradio-core/src/lib/general/gr_squelch_base_ff.cc b/gnuradio-core/src/lib/general/gr_squelch_base_ff.cc deleted file mode 100644 index 4bf8cff971..0000000000 --- a/gnuradio-core/src/lib/general/gr_squelch_base_ff.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 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_squelch_base_ff.h> -#include <gr_io_signature.h> - -gr_squelch_base_ff::gr_squelch_base_ff(const char *name, int ramp, bool gate) : - gr_block(name, - gr_make_io_signature(1, 1, sizeof(float)), - gr_make_io_signature(1, 1, sizeof(float))) -{ - set_ramp(ramp); - set_gate(gate); - d_state = ST_MUTED; - d_envelope = d_ramp ? 0.0 : 1.0; - d_ramped = 0; -} - -int gr_squelch_base_ff::general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - int j = 0; - - for (int i = 0; i < noutput_items; i++) { - update_state(in[i]); - - // Adjust envelope based on current state - switch(d_state) { - case ST_MUTED: - if (!mute()) - d_state = d_ramp ? ST_ATTACK : ST_UNMUTED; // If not ramping, go straight to unmuted - break; - - case ST_UNMUTED: - if (mute()) - d_state = d_ramp ? ST_DECAY : ST_MUTED; // If not ramping, go straight to muted - break; - - case ST_ATTACK: - d_envelope = 0.5-std::cos(M_PI*(++d_ramped)/d_ramp)/2.0; // FIXME: precalculate window for speed - if (d_ramped >= d_ramp) { // use >= in case d_ramp is set to lower value elsewhere - d_state = ST_UNMUTED; - d_envelope = 1.0; - } - break; - - case ST_DECAY: - d_envelope = 0.5-std::cos(M_PI*(--d_ramped)/d_ramp)/2.0; // FIXME: precalculate window for speed - if (d_ramped == 0.0) - d_state = ST_MUTED; - break; - }; - - // If unmuted, copy input times envelope to output - // Otherwise, if not gating, copy zero to output - if (d_state != ST_MUTED) - out[j++] = in[i]*d_envelope; - else - if (!d_gate) - out[j++] = 0.0; - } - - consume_each(noutput_items); // Use all the inputs - return j; // But only report outputs copied -} diff --git a/gnuradio-core/src/lib/general/gr_squelch_base_ff.h b/gnuradio-core/src/lib/general/gr_squelch_base_ff.h deleted file mode 100644 index eb52635b45..0000000000 --- a/gnuradio-core/src/lib/general/gr_squelch_base_ff.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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_SQUELCH_BASE_FF_H -#define INCLUDED_GR_SQUELCH_BASE_FF_H - -#include <gr_core_api.h> -#include <gr_block.h> - -class GR_CORE_API gr_squelch_base_ff : public gr_block -{ -private: - int d_ramp; - int d_ramped; - bool d_gate; - double d_envelope; - enum { ST_MUTED, ST_ATTACK, ST_UNMUTED, ST_DECAY } d_state; - -protected: - virtual void update_state(const float &sample) {}; - virtual bool mute() const { return false; }; - -public: - gr_squelch_base_ff(const char *name, int ramp, bool gate); - - int ramp() const { return d_ramp; } - void set_ramp(int ramp) { d_ramp = ramp; } - bool gate() const { return d_gate; } - void set_gate(bool gate) { d_gate = gate; } - bool unmuted() const { return (d_state == ST_UNMUTED || d_state == ST_ATTACK); } - - virtual std::vector<float> squelch_range() const = 0; - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_SQUELCH_BASE_FF_H */ diff --git a/gnuradio-core/src/lib/general/gr_squelch_base_ff.i b/gnuradio-core/src/lib/general/gr_squelch_base_ff.i deleted file mode 100644 index a4e5c7115c..0000000000 --- a/gnuradio-core/src/lib/general/gr_squelch_base_ff.i +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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. - */ - -#include <gr_block.h> - -class gr_squelch_base_ff : public gr_block -{ -private: - enum { ST_MUTED, ST_ATTACK, ST_UNMUTED, ST_DECAY } d_state; - -public: - gr_squelch_base_ff(const char *name, int ramp, bool gate); - - int ramp() const { return d_ramp; } - void set_ramp(int ramp) { d_ramp = ramp; } - bool gate() const { return d_gate; } - void set_gate(bool gate) { d_gate = gate; } - bool unmuted() const { return (d_state == ST_UNMUTED || d_state == ST_ATTACK); } - - virtual std::vector<float> squelch_range() const = 0; -}; diff --git a/gr-analog/examples/fmtest.py b/gr-analog/examples/fmtest.py new file mode 100755 index 0000000000..ca02ee5729 --- /dev/null +++ b/gr-analog/examples/fmtest.py @@ -0,0 +1,226 @@ +#!/usr/bin/env python +# +# Copyright 2009,2012 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. +# + +from gnuradio import gr, filter +from gnuradio import analog +import sys, math, time + +try: + import scipy + from scipy import fftpack +except ImportError: + print "Error: Program requires scipy (see: www.scipy.org)." + sys.exit(1) + +try: + import pylab +except ImportError: + print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." + sys.exit(1) + + +class fmtx(gr.hier_block2): + def __init__(self, lo_freq, audio_rate, if_rate): + + gr.hier_block2.__init__(self, "build_fm", + gr.io_signature(1, 1, gr.sizeof_float), + gr.io_signature(1, 1, gr.sizeof_gr_complex)) + + fmtx = analog.nbfm_tx(audio_rate, if_rate, max_dev=5e3, tau=75e-6) + + # Local oscillator + lo = analog.sig_source_c(if_rate, # sample rate + analog.GR_SIN_WAVE, # waveform type + lo_freq, # frequency + 1.0, # amplitude + 0) # DC Offset + mixer = gr.multiply_cc() + + self.connect(self, fmtx, (mixer, 0)) + self.connect(lo, (mixer, 1)) + self.connect(mixer, self) + +class fmtest(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + self._nsamples = 1000000 + self._audio_rate = 8000 + + # Set up N channels with their own baseband and IF frequencies + self._N = 5 + chspacing = 16000 + freq = [10, 20, 30, 40, 50] + f_lo = [0, 1*chspacing, -1*chspacing, 2*chspacing, -2*chspacing] + + self._if_rate = 4*self._N*self._audio_rate + + # Create a signal source and frequency modulate it + self.sum = gr.add_cc() + for n in xrange(self._N): + sig = analog.sig_source_f(self._audio_rate, analog.GR_SIN_WAVE, freq[n], 0.5) + fm = fmtx(f_lo[n], self._audio_rate, self._if_rate) + self.connect(sig, fm) + self.connect(fm, (self.sum, n)) + + self.head = gr.head(gr.sizeof_gr_complex, self._nsamples) + self.snk_tx = gr.vector_sink_c() + self.channel = filter.channel_model(0.1) + + self.connect(self.sum, self.head, self.channel, self.snk_tx) + + + # Design the channlizer + self._M = 10 + bw = chspacing/2.0 + t_bw = chspacing/10.0 + self._chan_rate = self._if_rate / self._M + self._taps = filter.firdes.low_pass_2(1, self._if_rate, bw, t_bw, + attenuation_dB=100, + window=filter.firdes.WIN_BLACKMAN_hARRIS) + tpc = math.ceil(float(len(self._taps)) / float(self._M)) + + print "Number of taps: ", len(self._taps) + print "Number of channels: ", self._M + print "Taps per channel: ", tpc + + self.pfb = filter.pfb.channelizer_ccf(self._M, self._taps) + + self.connect(self.channel, self.pfb) + + # Create a file sink for each of M output channels of the filter and connect it + self.fmdet = list() + self.squelch = list() + self.snks = list() + for i in xrange(self._M): + self.fmdet.append(analog.nbfm_rx(self._audio_rate, self._chan_rate)) + self.squelch.append(analog.standard_squelch(self._audio_rate*10)) + self.snks.append(gr.vector_sink_f()) + self.connect((self.pfb, i), self.fmdet[i], self.squelch[i], self.snks[i]) + + def num_tx_channels(self): + return self._N + + def num_rx_channels(self): + return self._M + +def main(): + + fm = fmtest() + + tstart = time.time() + fm.run() + tend = time.time() + + if 1: + fig1 = pylab.figure(1, figsize=(12,10), facecolor="w") + fig2 = pylab.figure(2, figsize=(12,10), facecolor="w") + fig3 = pylab.figure(3, figsize=(12,10), facecolor="w") + + Ns = 10000 + Ne = 100000 + + fftlen = 8192 + winfunc = scipy.blackman + + # Plot transmitted signal + fs = fm._if_rate + + d = fm.snk_tx.data()[Ns:Ns+Ne] + sp1_f = fig1.add_subplot(2, 1, 1) + + X,freq = sp1_f.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs, + window = lambda d: d*winfunc(fftlen), + visible=False) + X_in = 10.0*scipy.log10(abs(fftpack.fftshift(X))) + f_in = scipy.arange(-fs/2.0, fs/2.0, fs/float(X_in.size)) + p1_f = sp1_f.plot(f_in, X_in, "b") + sp1_f.set_xlim([min(f_in), max(f_in)+1]) + sp1_f.set_ylim([-120.0, 20.0]) + + sp1_f.set_title("Input Signal", weight="bold") + sp1_f.set_xlabel("Frequency (Hz)") + sp1_f.set_ylabel("Power (dBW)") + + Ts = 1.0/fs + Tmax = len(d)*Ts + + t_in = scipy.arange(0, Tmax, Ts) + x_in = scipy.array(d) + sp1_t = fig1.add_subplot(2, 1, 2) + p1_t = sp1_t.plot(t_in, x_in.real, "b-o") + #p1_t = sp1_t.plot(t_in, x_in.imag, "r-o") + sp1_t.set_ylim([-5, 5]) + + # Set up the number of rows and columns for plotting the subfigures + Ncols = int(scipy.floor(scipy.sqrt(fm.num_rx_channels()))) + Nrows = int(scipy.floor(fm.num_rx_channels() / Ncols)) + if(fm.num_rx_channels() % Ncols != 0): + Nrows += 1 + + # Plot each of the channels outputs. Frequencies on Figure 2 and + # time signals on Figure 3 + fs_o = fm._audio_rate + for i in xrange(len(fm.snks)): + # remove issues with the transients at the beginning + # also remove some corruption at the end of the stream + # this is a bug, probably due to the corner cases + d = fm.snks[i].data()[Ns:Ne] + + sp2_f = fig2.add_subplot(Nrows, Ncols, 1+i) + X,freq = sp2_f.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs_o, + window = lambda d: d*winfunc(fftlen), + visible=False) + #X_o = 10.0*scipy.log10(abs(fftpack.fftshift(X))) + X_o = 10.0*scipy.log10(abs(X)) + #f_o = scipy.arange(-fs_o/2.0, fs_o/2.0, fs_o/float(X_o.size)) + f_o = scipy.arange(0, fs_o/2.0, fs_o/2.0/float(X_o.size)) + p2_f = sp2_f.plot(f_o, X_o, "b") + sp2_f.set_xlim([min(f_o), max(f_o)+0.1]) + sp2_f.set_ylim([-120.0, 20.0]) + sp2_f.grid(True) + + sp2_f.set_title(("Channel %d" % i), weight="bold") + sp2_f.set_xlabel("Frequency (kHz)") + sp2_f.set_ylabel("Power (dBW)") + + + Ts = 1.0/fs_o + Tmax = len(d)*Ts + t_o = scipy.arange(0, Tmax, Ts) + + x_t = scipy.array(d) + sp2_t = fig3.add_subplot(Nrows, Ncols, 1+i) + p2_t = sp2_t.plot(t_o, x_t.real, "b") + p2_t = sp2_t.plot(t_o, x_t.imag, "r") + sp2_t.set_xlim([min(t_o), max(t_o)+1]) + sp2_t.set_ylim([-1, 1]) + + sp2_t.set_xlabel("Time (s)") + sp2_t.set_ylabel("Amplitude") + + + pylab.show() + + +if __name__ == "__main__": + main() diff --git a/gnuradio-core/src/examples/tags/uhd_burst_detector.py b/gr-analog/examples/tags/uhd_burst_detector.py index 512fc715d7..3be0fb8c2e 100755 --- a/gnuradio-core/src/examples/tags/uhd_burst_detector.py +++ b/gr-analog/examples/tags/uhd_burst_detector.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,6 +22,7 @@ from gnuradio import eng_notation from gnuradio import gr +from gnuradio import filter, analog from gnuradio import uhd from gnuradio import window from gnuradio.eng_option import eng_option @@ -49,7 +50,7 @@ class uhd_burst_detector(gr.top_block): self.uhd_src.set_gain(self.gain, 0) taps = firdes.low_pass_2(1, 1, 0.4, 0.1, 60) - self.chanfilt = gr.fir_filter_ccc(10, taps) + self.chanfilt = filter.fir_filter_ccc(10, taps) self.tagger = gr.burst_tagger(gr.sizeof_gr_complex) # Dummy signaler to collect a burst on known periods @@ -58,11 +59,11 @@ class uhd_burst_detector(gr.top_block): # Energy detector to get signal burst ## use squelch to detect energy - self.det = gr.simple_squelch_cc(self.threshold, 0.01) + self.det = analog.simple_squelch_cc(self.threshold, 0.01) ## convert to mag squared (float) self.c2m = gr.complex_to_mag_squared() ## average to debounce - self.avg = gr.single_pole_iir_filter_ff(0.01) + self.avg = filter.single_pole_iir_filter_ff(0.01) ## rescale signal for conversion to short self.scale = gr.multiply_const_ff(2**16) ## signal input uses shorts diff --git a/gr-analog/grc/analog_block_tree.xml b/gr-analog/grc/analog_block_tree.xml index b5b2ecd568..8d429f564c 100644 --- a/gr-analog/grc/analog_block_tree.xml +++ b/gr-analog/grc/analog_block_tree.xml @@ -37,6 +37,7 @@ <block>analog_ctcss_squelch_ff</block> <block>analog_pwr_squelch_xx</block> <block>analog_simple_squelch_cc</block> + <block>analog_standard_squelch</block> <block>analog_rail_ff</block> </cat> <cat> diff --git a/grc/blocks/blks2_standard_squelch.xml b/gr-analog/grc/analog_standard_squelch.xml index f0baeb6624..264c57ab56 100644 --- a/grc/blocks/blks2_standard_squelch.xml +++ b/gr-analog/grc/analog_standard_squelch.xml @@ -6,9 +6,9 @@ --> <block> <name>Standard Squelch</name> - <key>blks2_standard_squelch</key> - <import>from gnuradio import blks2</import> - <make>blks2.standard_squelch(audio_rate=$audio_rate) + <key>analog_standard_squelch</key> + <import>from gnuradio import analog</import> + <make>analog.standard_squelch(audio_rate=$audio_rate) self.$(id).set_threshold($threshold)</make> <callback>set_threshold($threshold)</callback> <param> diff --git a/gr-analog/python/nbfm_rx.py b/gr-analog/python/nbfm_rx.py index e87cc84796..b2c86db70f 100644 --- a/gr-analog/python/nbfm_rx.py +++ b/gr-analog/python/nbfm_rx.py @@ -64,7 +64,7 @@ class nbfm_rx(gr.hier_block2): raise ValueError, "quad_rate is not an integer multiple of audio_rate" squelch_threshold = 20 # dB - #self.squelch = gr.simple_squelch_cc(squelch_threshold, 0.001) + #self.squelch = analog.simple_squelch_cc(squelch_threshold, 0.001) # FM Demodulator input: complex; output: float k = quad_rate/(2*math.pi*max_dev) @@ -79,7 +79,7 @@ class nbfm_rx(gr.hier_block2): quad_rate, # sampling rate 2.7e3, # Audio LPF cutoff 0.5e3, # Transition band - gr.firdes.WIN_HAMMING) # filter type + filter.firdes.WIN_HAMMING) # filter type print "len(audio_taps) =", len(audio_taps) diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml index e9caa1006d..f88da24577 100644 --- a/grc/blocks/block_tree.xml +++ b/grc/blocks/block_tree.xml @@ -135,10 +135,6 @@ <block>gr_sample_and_hold_xx</block> <block>gr_mute_xx</block> - <block>gr_simple_squelch_cc</block> - <block>blks2_standard_squelch</block> - <block>gr_pwr_squelch_xx</block> - <block>gr_ctcss_squelch_ff</block> <block>gr_threshold_ff</block> </cat> <cat> diff --git a/grc/blocks/gr_ctcss_squelch_ff.xml b/grc/blocks/gr_ctcss_squelch_ff.xml deleted file mode 100644 index a34c75374c..0000000000 --- a/grc/blocks/gr_ctcss_squelch_ff.xml +++ /dev/null @@ -1,79 +0,0 @@ -<?xml version="1.0"?> -<!-- -# -# Copyright 2011 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. ---> - -<!-- -################################################### -##CTCSS Squelch -################################################### - --> -<block> - <name>CTCSS Squelch</name> - <key>gr_ctcss_squelch_ff</key> - <import>from gnuradio import gr</import> - <make>gr.ctcss_squelch_ff($rate, $freq, $level, $len, $ramp, $gate)</make> - <callback>set_level($level)</callback> - <param> - <name>Sampling Rate (Hz)</name> - <key>rate</key> - <value>samp_rate</value> - <type>real</type> - </param> - <param> - <name>Tone Frequency</name> - <key>freq</key> - <value>100.0</value> - <type>real</type> - </param> - <param> - <name>Level</name> - <key>level</key> - <value>0.01</value> - <type>real</type> - </param> - <param> - <name>Length</name> - <key>len</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Ramp</name> - <key>ramp</key> - <value>0</value> - <type>int</type> - </param> - <param> - <name>Gate</name> - <key>gate</key> - <value>False</value> - <type>bool</type> - </param> - <sink> - <name>in</name> - <type>float</type> - </sink> - <source> - <name>out</name> - <type>float</type> - </source> -</block> diff --git a/grc/blocks/gr_pwr_squelch_xx.xml b/grc/blocks/gr_pwr_squelch_xx.xml deleted file mode 100644 index 08d6211770..0000000000 --- a/grc/blocks/gr_pwr_squelch_xx.xml +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Power Squelch -################################################### - --> -<block> - <name>Power Squelch</name> - <key>gr_pwr_squelch_xx</key> - <import>from gnuradio import gr</import> - <make>gr.pwr_squelch_$(type.fcn)($threshold, $alpha, $ramp, $gate)</make> - <callback>set_threshold($threshold)</callback> - <callback>set_alpha($alpha)</callback> - <param> - <name>Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex</name> - <key>complex</key> - <opt>fcn:cc</opt> - </option> - <option> - <name>Float</name> - <key>float</key> - <opt>fcn:ff</opt> - </option> - </param> - <param> - <name>Threshold (dB)</name> - <key>threshold</key> - <type>real</type> - </param> - <param> - <name>Alpha</name> - <key>alpha</key> - <type>real</type> - </param> - <param> - <name>Ramp</name> - <key>ramp</key> - <type>int</type> - </param> - <param> - <name>Gate</name> - <key>gate</key> - <type>enum</type> - <option> - <name>Yes</name> - <key>True</key> - </option> - <option> - <name>No</name> - <key>False</key> - </option> - </param> - <sink> - <name>in</name> - <type>$type</type> - </sink> - <source> - <name>out</name> - <type>$type</type> - </source> -</block> diff --git a/grc/blocks/gr_simple_squelch_cc.xml b/grc/blocks/gr_simple_squelch_cc.xml deleted file mode 100644 index 5c0727f5f8..0000000000 --- a/grc/blocks/gr_simple_squelch_cc.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Simple Squelch -################################################### - --> -<block> - <name>Simple Squelch</name> - <key>gr_simple_squelch_cc</key> - <import>from gnuradio import gr</import> - <make>gr.simple_squelch_cc($threshold, $alpha)</make> - <callback>set_threshold($threshold)</callback> - <callback>set_alpha($alpha)</callback> - <param> - <name>Threshold (dB)</name> - <key>threshold</key> - <type>real</type> - </param> - <param> - <name>Alpha</name> - <key>alpha</key> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>complex</type> - </sink> - <source> - <name>out</name> - <type>complex</type> - </source> -</block> |