GNU Radio 3.6.5 C++ API

pwr_squelch_ff_impl.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2006,2012 Free Software Foundation, Inc.
00004  *
00005  * This file is part of GNU Radio
00006  *
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  *
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef INCLUDED_ANALOG_PWR_SQUELCH_FF_IMPL_H
00024 #define INCLUDED_ANALOG_PWR_SQUELCH_FF_IMPL_H
00025 
00026 #include <analog/pwr_squelch_ff.h>
00027 #include "squelch_base_ff_impl.h"
00028 #include <filter/single_pole_iir.h>
00029 #include <cmath>
00030 
00031 namespace gr {
00032   namespace analog {
00033     
00034     class ANALOG_API pwr_squelch_ff_impl :
00035       public pwr_squelch_ff, squelch_base_ff_impl
00036     {
00037     private:
00038       double d_threshold;
00039       double d_pwr;
00040       filter::single_pole_iir<double,double,double> d_iir;
00041 
00042     protected:
00043       virtual void update_state(const float &in);
00044       virtual bool mute() const { return d_pwr < d_threshold; }
00045 
00046     public:
00047       pwr_squelch_ff_impl(double db, double alpha=0.0001,
00048                           int ramp=0, bool gate=false);
00049       ~pwr_squelch_ff_impl();
00050 
00051       std::vector<float> squelch_range() const;
00052 
00053       double threshold() const { return 10*log10(d_threshold); }
00054       void set_threshold(double db) { d_threshold = std::pow(10.0, db/10); }
00055       void set_alpha(double alpha) { d_iir.set_taps(alpha); }
00056 
00057       int ramp() const { return squelch_base_ff_impl::ramp(); }
00058       void set_ramp(int ramp) { squelch_base_ff_impl::set_ramp(ramp); }
00059       bool gate() const { return squelch_base_ff_impl::gate(); }
00060       void set_gate(bool gate) { squelch_base_ff_impl::set_gate(gate); }
00061       bool unmuted() const { return squelch_base_ff_impl::unmuted(); }
00062 
00063       int general_work(int noutput_items,
00064                        gr_vector_int &ninput_items,
00065                        gr_vector_const_void_star &input_items,
00066                        gr_vector_void_star &output_items)
00067       { 
00068         return squelch_base_ff_impl::general_work(noutput_items,
00069                                                   ninput_items,
00070                                                   input_items,
00071                                                   output_items);
00072       }
00073     };
00074 
00075   } /* namespace analog */
00076 } /* namespace gr */
00077 
00078 #endif /* INCLUDED_ANALOG_PWR_SQUELCH_FF_IMPL_H */