1 /* -*- c++ -*- */ 2 /* 3 * Gqrx SDR: Software defined radio receiver powered by GNU Radio and Qt 4 * https://gqrx.dk/ 5 * 6 * Copyright 2011-2016 Alexandru Csete OZ9AEC. 7 * 8 * Gqrx is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 3, or (at your option) 11 * any later version. 12 * 13 * Gqrx is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with Gqrx; see the file COPYING. If not, write to 20 * the Free Software Foundation, Inc., 51 Franklin Street, 21 * Boston, MA 02110-1301, USA. 22 */ 23 #ifndef NBRX_H 24 #define NBRX_H 25 26 #include <gnuradio/analog/simple_squelch_cc.h> 27 #include <gnuradio/basic_block.h> 28 #include <gnuradio/blocks/complex_to_float.h> 29 #include <gnuradio/blocks/complex_to_real.h> 30 #include "receivers/receiver_base.h" 31 #include "dsp/rx_noise_blanker_cc.h" 32 #include "dsp/rx_filter.h" 33 #include "dsp/rx_meter.h" 34 #include "dsp/rx_agc_xx.h" 35 #include "dsp/rx_demod_fm.h" 36 #include "dsp/rx_demod_am.h" 37 //#include "dsp/resampler_ff.h" 38 #include "dsp/resampler_xx.h" 39 40 class nbrx; 41 42 #if GNURADIO_VERSION < 0x030900 43 typedef boost::shared_ptr<nbrx> nbrx_sptr; 44 #else 45 typedef std::shared_ptr<nbrx> nbrx_sptr; 46 #endif 47 48 /*! \brief Public constructor of nbrx_sptr. */ 49 nbrx_sptr make_nbrx(float quad_rate, float audio_rate); 50 51 /*! \brief Narrow band analog receiver 52 * \ingroup RX 53 * 54 * This block provides receiver for AM, narrow band FM and SSB modes. 55 */ 56 class nbrx : public receiver_base_cf 57 { 58 public: 59 /*! \brief Available demodulators. */ 60 enum nbrx_demod { 61 NBRX_DEMOD_NONE = 0, /*!< No demod. Raw I/Q to audio. */ 62 NBRX_DEMOD_AM = 1, /*!< Amplitude modulation. */ 63 NBRX_DEMOD_FM = 2, /*!< Frequency modulation. */ 64 NBRX_DEMOD_SSB = 3, /*!< Single Side Band. */ 65 NBRX_DEMOD_AMSYNC = 4, /*!< Amplitude modulation (synchronous demod). */ 66 NBRX_DEMOD_NUM = 5 /*!< Included for convenience. */ 67 }; 68 69 public: 70 nbrx(float quad_rate, float audio_rate); ~nbrx()71 virtual ~nbrx() { }; 72 73 bool start(); 74 bool stop(); 75 76 void set_quad_rate(float quad_rate); 77 void set_audio_rate(float audio_rate); 78 79 void set_filter(double low, double high, double tw); 80 void set_cw_offset(double offset); 81 82 float get_signal_level(); 83 84 /* Noise blanker */ has_nb()85 bool has_nb() { return true; } 86 void set_nb_on(int nbid, bool on); 87 void set_nb_threshold(int nbid, float threshold); 88 89 /* Squelch parameter */ has_sql()90 bool has_sql() { return true; } 91 void set_sql_level(double level_db); 92 void set_sql_alpha(double alpha); 93 94 /* AGC */ has_agc()95 bool has_agc() { return true; } 96 void set_agc_on(bool agc_on); 97 void set_agc_hang(bool use_hang); 98 void set_agc_threshold(int threshold); 99 void set_agc_slope(int slope); 100 void set_agc_decay(int decay_ms); 101 void set_agc_manual_gain(int gain); 102 103 void set_demod(int demod); 104 105 /* FM parameters */ has_fm()106 bool has_fm() { return true; } 107 void set_fm_maxdev(float maxdev_hz); 108 void set_fm_deemph(double tau); 109 110 /* AM parameters */ has_am()111 bool has_am() { return true; } 112 void set_am_dcr(bool enabled); 113 114 /* AM-Sync parameters */ has_amsync()115 bool has_amsync() { return true; } 116 void set_amsync_dcr(bool enabled); 117 void set_amsync_pll_bw(float pll_bw); 118 119 private: 120 bool d_running; /*!< Whether receiver is running or not. */ 121 float d_quad_rate; /*!< Input sample rate. */ 122 int d_audio_rate; /*!< Audio output rate. */ 123 124 nbrx_demod d_demod; /*!< Current demodulator. */ 125 126 resampler_cc_sptr iq_resamp; /*!< Baseband resampler. */ 127 rx_filter_sptr filter; /*!< Non-translating bandpass filter.*/ 128 129 rx_nb_cc_sptr nb; /*!< Noise blanker. */ 130 rx_meter_c_sptr meter; /*!< Signal strength. */ 131 rx_agc_cc_sptr agc; /*!< Receiver AGC. */ 132 gr::analog::simple_squelch_cc::sptr sql; /*!< Squelch. */ 133 gr::blocks::complex_to_float::sptr demod_raw; /*!< Raw I/Q passthrough. */ 134 gr::blocks::complex_to_real::sptr demod_ssb; /*!< SSB demodulator. */ 135 rx_demod_fm_sptr demod_fm; /*!< FM demodulator. */ 136 rx_demod_am_sptr demod_am; /*!< AM demodulator. */ 137 rx_demod_amsync_sptr demod_amsync; /*!< AM-Sync demodulator. */ 138 resampler_ff_sptr audio_rr0; /*!< Audio resampler. */ 139 resampler_ff_sptr audio_rr1; /*!< Audio resampler. */ 140 141 gr::basic_block_sptr demod; // dummy pointer used for simplifying reconf 142 }; 143 144 #endif // NBRX_H 145