GNU Radio 3.6.5 C++ API

ctcss_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_CTCSS_SQUELCH_FF_IMPL_H
00024 #define INCLUDED_ANALOG_CTCSS_SQUELCH_FF_IMPL_H
00025 
00026 #include <analog/ctcss_squelch_ff.h>
00027 #include "squelch_base_ff_impl.h"
00028 #include <fft/goertzel.h>
00029 
00030 namespace gr {
00031   namespace analog {
00032 
00033     class ctcss_squelch_ff_impl : public ctcss_squelch_ff, squelch_base_ff_impl
00034     {
00035     private:
00036       float d_freq;
00037       float d_level;
00038       int   d_len;
00039       bool  d_mute;
00040 
00041       fft::goertzel d_goertzel_l;
00042       fft::goertzel d_goertzel_c;
00043       fft::goertzel d_goertzel_r;
00044 
00045       int find_tone(float freq);
00046 
00047     protected:
00048       virtual void update_state(const float &in);
00049       virtual bool mute() const { return d_mute; }
00050 
00051     public:
00052       ctcss_squelch_ff_impl(int rate, float freq, float level,
00053                             int len, int ramp, bool gate);
00054       ~ctcss_squelch_ff_impl();
00055 
00056       std::vector<float> squelch_range() const;
00057       float level() const { return d_level; }
00058       void set_level(float level) { d_level = level; }
00059       int len() const { return d_len; }
00060 
00061       int ramp() const { return squelch_base_ff_impl::ramp(); }
00062       void set_ramp(int ramp) { squelch_base_ff_impl::set_ramp(ramp); }
00063       bool gate() const { return squelch_base_ff_impl::gate(); }
00064       void set_gate(bool gate) { squelch_base_ff_impl::set_gate(gate); }
00065       bool unmuted() const { return squelch_base_ff_impl::unmuted(); }
00066 
00067       int general_work(int noutput_items,
00068                        gr_vector_int &ninput_items,
00069                        gr_vector_const_void_star &input_items,
00070                        gr_vector_void_star &output_items)
00071       { 
00072         return squelch_base_ff_impl::general_work(noutput_items,
00073                                                   ninput_items,
00074                                                   input_items,
00075                                                   output_items);
00076       }
00077     };
00078 
00079   } /* namespace analog */
00080 } /* namespace gr */
00081 
00082 #endif /* INCLUDED_ANALOG_CTCSS_SQUELCH_FF_IMPL_H */