diff options
Diffstat (limited to 'gr-analog/include')
36 files changed, 2558 insertions, 0 deletions
diff --git a/gr-analog/include/analog/CMakeLists.txt b/gr-analog/include/analog/CMakeLists.txt new file mode 100644 index 000000000..4de94a88b --- /dev/null +++ b/gr-analog/include/analog/CMakeLists.txt @@ -0,0 +1,111 @@ +# Copyright 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. + +######################################################################## +# generate helper scripts to expand templated files +######################################################################## +include(GrPython) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py " +#!${PYTHON_EXECUTABLE} + +import sys, os, re +sys.path.append('${GR_CORE_PYTHONPATH}') +os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}' +os.chdir('${CMAKE_CURRENT_BINARY_DIR}') + +if __name__ == '__main__': + import build_utils + root, inp = sys.argv[1:3] + for sig in sys.argv[3:]: + name = re.sub ('X+', sig, root) + d = build_utils.standard_dict2(name, sig, 'analog') + build_utils.expand_template(d, inp) + +") + +macro(expand_h root) + #make a list of all the generated files + unset(expanded_files_h) + foreach(sig ${ARGN}) + string(REGEX REPLACE "X+" ${sig} name ${root}) + list(APPEND expanded_files_h ${CMAKE_CURRENT_BINARY_DIR}/${name}.h) + endforeach(sig) + + #create a command to generate the files + add_custom_command( + OUTPUT ${expanded_files_h} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.h.t + COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} + ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py + ${root} ${root}.h.t ${ARGN} + ) + + #install rules for the generated h files + list(APPEND generated_includes ${expanded_files_h}) +endmacro(expand_h) + +######################################################################## +# Invoke macro to generate various sources +####################################################################### +expand_h(noise_source_X s i f c) +expand_h(sig_source_X s i f c) + +add_custom_target(analog_generated_includes DEPENDS + ${generated_includes} +) + +######################################################################## +# Install header files +######################################################################## +install(FILES + ${analog_generated_includes} + api.h + cpm.h + agc.h + agc2.h + squelch_base_ff.h + agc_cc.h + agc_ff.h + agc2_cc.h + agc2_ff.h + cpfsk_bc.h + ctcss_squelch_ff.h + dpll_bb.h + feedforward_agc_cc.h + fmdet_cf.h + frequency_modulator_fc.h + phase_modulator_fc.h + pll_carriertracking_cc.h + pll_freqdet_cf.h + pll_refout_cc.h + probe_avg_mag_sqrd_c.h + probe_avg_mag_sqrd_cf.h + probe_avg_mag_sqrd_f.h + pwr_squelch_cc.h + pwr_squelch_ff.h + quadrature_demod_cf.h + rail_ff.h + rotator.h + sig_source_waveform.h + simple_squelch_cc.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/analog + COMPONENT "analog_devel" +) + diff --git a/gr-analog/include/analog/agc.h b/gr-analog/include/analog/agc.h new file mode 100644 index 000000000..92d777fa1 --- /dev/null +++ b/gr-analog/include/analog/agc.h @@ -0,0 +1,136 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,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. + */ + +#ifndef INCLUDED_ANALOG_AGC_H +#define INCLUDED_ANALOG_AGC_H + +#include <analog/api.h> +#include <gr_complex.h> +#include <math.h> + +namespace gr { + namespace analog { + namespace kernel { + + /*! + * \brief high performance Automatic Gain Control class for complex signals. + * + * For Power the absolute value of the complex number is used. + */ + class ANALOG_API agc_cc + { + public: + agc_cc(float rate = 1e-4, float reference = 1.0, + float gain = 1.0, float max_gain = 0.0) + : _rate(rate), _reference(reference), + _gain(gain), _max_gain(max_gain) {}; + + virtual ~agc_cc() {}; + + float rate() const { return _rate; } + float reference() const { return _reference; } + float gain() const { return _gain; } + float max_gain() const { return _max_gain; } + + void set_rate(float rate) { _rate = rate; } + void set_reference(float reference) { _reference = reference; } + void set_gain(float gain) { _gain = gain; } + void set_max_gain(float max_gain) { _max_gain = max_gain; } + + gr_complex scale(gr_complex input) + { + gr_complex output = input * _gain; + + _gain += _rate * (_reference - sqrt(output.real()*output.real() + + output.imag()*output.imag())); + if(_max_gain > 0.0 && _gain > _max_gain) { + _gain = _max_gain; + } + return output; + } + + void scaleN(gr_complex output[], const gr_complex input[], unsigned n) + { + for(unsigned i = 0; i < n; i++) { + output[i] = scale (input[i]); + } + } + + protected: + float _rate; // adjustment rate + float _reference; // reference value + float _gain; // current gain + float _max_gain; // max allowable gain + }; + + /*! + * \brief high performance Automatic Gain Control class for float signals. + * + * Power is approximated by absolute value + */ + class ANALOG_API agc_ff + { + public: + agc_ff(float rate = 1e-4, float reference = 1.0, + float gain = 1.0, float max_gain = 0.0) + : _rate(rate), _reference(reference), _gain(gain), + _max_gain(max_gain) {}; + + ~agc_ff() {}; + + float rate () const { return _rate; } + float reference () const { return _reference; } + float gain () const { return _gain; } + float max_gain () const { return _max_gain; } + + void set_rate (float rate) { _rate = rate; } + void set_reference (float reference) { _reference = reference; } + void set_gain (float gain) { _gain = gain; } + void set_max_gain (float max_gain) { _max_gain = max_gain; } + + float scale (float input) + { + float output = input * _gain; + _gain += (_reference - fabsf (output)) * _rate; + if(_max_gain > 0.0 && _gain > _max_gain) + _gain = _max_gain; + return output; + } + + void scaleN(float output[], const float input[], unsigned n) + { + for(unsigned i = 0; i < n; i++) + output[i] = scale (input[i]); + } + + protected: + float _rate; // adjustment rate + float _reference; // reference value + float _gain; // current gain + float _max_gain; // maximum gain + }; + + } /* namespace kernel */ + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_AGC_H */ diff --git a/gr-analog/include/analog/agc2.h b/gr-analog/include/analog/agc2.h new file mode 100644 index 000000000..75a203e9f --- /dev/null +++ b/gr-analog/include/analog/agc2.h @@ -0,0 +1,160 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,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. + */ + +#ifndef INCLUDED_ANALOG_AGC2_H +#define INCLUDED_ANALOG_AGC2_H + +#include <analog/api.h> +#include <gr_complex.h> +#include <math.h> + +namespace gr { + namespace analog { + namespace kernel { + + /*! + * \brief high performance Automatic Gain Control class + * + * For Power the absolute value of the complex number is used. + */ + class ANALOG_API agc2_cc + { + public: + agc2_cc(float attack_rate = 1e-1, float decay_rate = 1e-2, + float reference = 1.0, + float gain = 1.0, float max_gain = 0.0) + : _attack_rate(attack_rate), _decay_rate(decay_rate), + _reference(reference), + _gain(gain), _max_gain(max_gain) {}; + + float decay_rate() const { return _decay_rate; } + float attack_rate() const { return _attack_rate; } + float reference() const { return _reference; } + float gain() const { return _gain; } + float max_gain() const { return _max_gain; } + + void set_decay_rate(float rate) { _decay_rate = rate; } + void set_attack_rate(float rate) { _attack_rate = rate; } + void set_reference(float reference) { _reference = reference; } + void set_gain(float gain) { _gain = gain; } + void set_max_gain(float max_gain) { _max_gain = max_gain; } + + gr_complex scale(gr_complex input) + { + gr_complex output = input * _gain; + + float tmp = -_reference + sqrt(output.real()*output.real() + + output.imag()*output.imag()); + float rate = _decay_rate; + if((tmp) > _gain) { + rate = _attack_rate; + } + _gain -= tmp*rate; + + // Not sure about this; will blow up if _gain < 0 (happens + // when rates are too high), but is this the solution? + if(_gain < 0.0) + _gain = 10e-5; + + if(_max_gain > 0.0 && _gain > _max_gain) { + _gain = _max_gain; + } + return output; + } + + void scaleN(gr_complex output[], const gr_complex input[], unsigned n) + { + for(unsigned i = 0; i < n; i++) + output[i] = scale (input[i]); + } + + protected: + float _attack_rate; // attack rate for fast changing signals + float _decay_rate; // decay rate for slow changing signals + float _reference; // reference value + float _gain; // current gain + float _max_gain; // max allowable gain + }; + + + class ANALOG_API agc2_ff + { + public: + agc2_ff(float attack_rate = 1e-1, float decay_rate = 1e-2, + float reference = 1.0, + float gain = 1.0, float max_gain = 0.0) + : _attack_rate(attack_rate), _decay_rate(decay_rate), + _reference(reference), + _gain(gain), _max_gain(max_gain) {}; + + float attack_rate() const { return _attack_rate; } + float decay_rate() const { return _decay_rate; } + float reference() const { return _reference; } + float gain() const { return _gain; } + float max_gain() const { return _max_gain; } + + void set_attack_rate(float rate) { _attack_rate = rate; } + void set_decay_rate(float rate) { _decay_rate = rate; } + void set_reference(float reference) { _reference = reference; } + void set_gain(float gain) { _gain = gain; } + void set_max_gain(float max_gain) { _max_gain = max_gain; } + + float scale(float input) + { + float output = input * _gain; + + float tmp = (fabsf(output)) - _reference; + float rate = _decay_rate; + if(fabsf(tmp) > _gain) { + rate = _attack_rate; + } + _gain -= tmp*rate; + + // Not sure about this + if(_gain < 0.0) + _gain = 10e-5; + + if(_max_gain > 0.0 && _gain > _max_gain) { + _gain = _max_gain; + } + return output; + } + + void scaleN(float output[], const float input[], unsigned n) + { + for(unsigned i = 0; i < n; i++) + output[i] = scale (input[i]); + } + + protected: + float _attack_rate; // attack_rate for fast changing signals + float _decay_rate; // decay rate for slow changing signals + float _reference; // reference value + float _gain; // current gain + float _max_gain; // maximum gain + }; + + } /* namespace kernel */ + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_AGC2_H */ diff --git a/gr-analog/include/analog/agc2_cc.h b/gr-analog/include/analog/agc2_cc.h new file mode 100644 index 000000000..c922ccd4d --- /dev/null +++ b/gr-analog/include/analog/agc2_cc.h @@ -0,0 +1,65 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,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. + */ + +#ifndef INCLUDED_ANALOG_AGC2_CC_H +#define INCLUDED_ANALOG_AGC2_CC_H + +#include <analog/api.h> +#include <analog/agc2.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief high performance Automatic Gain Control class + * \ingroup level_blk + * + * For Power the absolute value of the complex number is used. + */ + class ANALOG_API agc2_cc : virtual public gr_sync_block + { + public: + // gr::analog::agc2_cc::sptr + typedef boost::shared_ptr<agc2_cc> sptr; + + static sptr make(float attack_rate = 1e-1, float decay_rate = 1e-2, + float reference = 1.0, + float gain = 1.0, float max_gain = 0.0); + + virtual float attack_rate() const = 0; + virtual float decay_rate() const = 0; + virtual float reference() const = 0; + virtual float gain() const = 0; + virtual float max_gain() const = 0; + + virtual void set_attack_rate(float rate) = 0; + virtual void set_decay_rate(float rate) = 0; + virtual void set_reference(float reference) = 0; + virtual void set_gain(float gain) = 0; + virtual void set_max_gain(float max_gain) = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_AGC2_CC_H */ diff --git a/gr-analog/include/analog/agc2_ff.h b/gr-analog/include/analog/agc2_ff.h new file mode 100644 index 000000000..27dd6d92e --- /dev/null +++ b/gr-analog/include/analog/agc2_ff.h @@ -0,0 +1,65 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,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. + */ + +#ifndef INCLUDED_ANALOG_AGC2_FF_H +#define INCLUDED_ANALOG_AGC2_FF_H + +#include <analog/api.h> +#include <analog/agc2.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief high performance Automatic Gain Control class + * + * \ingroup level_blk + * Power is approximated by absolute value + */ + class ANALOG_API agc2_ff : virtual public gr_sync_block + { + public: + // gr::analog::agc2_ff::sptr + typedef boost::shared_ptr<agc2_ff> sptr; + + static sptr make(float attack_rate = 1e-1, float decay_rate = 1e-2, + float reference = 1.0, + float gain = 1.0, float max_gain = 0.0); + + virtual float attack_rate() const = 0; + virtual float decay_rate() const = 0; + virtual float reference() const = 0; + virtual float gain() const = 0; + virtual float max_gain() const = 0; + + virtual void set_attack_rate(float rate) = 0; + virtual void set_decay_rate(float rate) = 0; + virtual void set_reference(float reference) = 0; + virtual void set_gain(float gain) = 0; + virtual void set_max_gain(float max_gain) = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_AGC2_FF_H */ diff --git a/gr-analog/include/analog/agc_cc.h b/gr-analog/include/analog/agc_cc.h new file mode 100644 index 000000000..b2b1a9b43 --- /dev/null +++ b/gr-analog/include/analog/agc_cc.h @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,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. + */ + +#ifndef INCLUDED_ANALOG_AGC_CC_H +#define INCLUDED_ANALOG_AGC_CC_H + +#include <analog/api.h> +#include <analog/agc.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief high performance Automatic Gain Control class + * \ingroup level_blk + * + * For Power the absolute value of the complex number is used. + */ + class ANALOG_API agc_cc : virtual public gr_sync_block + { + public: + // gr::analog::agc_cc::sptr + typedef boost::shared_ptr<agc_cc> sptr; + + static sptr make(float rate = 1e-4, float reference = 1.0, + float gain = 1.0, float max_gain = 0.0); + + virtual float rate() const = 0; + virtual float reference() const = 0; + virtual float gain() const = 0; + virtual float max_gain() const = 0; + + virtual void set_rate(float rate) = 0; + virtual void set_reference(float reference) = 0; + virtual void set_gain(float gain) = 0; + virtual void set_max_gain(float max_gain) = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_AGC_CC_H */ diff --git a/gr-analog/include/analog/agc_ff.h b/gr-analog/include/analog/agc_ff.h new file mode 100644 index 000000000..30d1ae1fd --- /dev/null +++ b/gr-analog/include/analog/agc_ff.h @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,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. + */ + +#ifndef INCLUDED_ANALOG_AGC_FF_H +#define INCLUDED_ANALOG_AGC_FF_H + +#include <analog/api.h> +#include <analog/agc.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief high performance Automatic Gain Control class + * \ingroup level_blk + * + * Power is approximated by absolute value + */ + class ANALOG_API agc_ff : virtual public gr_sync_block + { + public: + // gr::analog::agc_ff::sptr + typedef boost::shared_ptr<agc_ff> sptr; + + static sptr make(float rate = 1e-4, float reference = 1.0, + float gain = 1.0, float max_gain = 0.0); + + virtual float rate() const = 0; + virtual float reference() const = 0; + virtual float gain() const = 0; + virtual float max_gain() const = 0; + + virtual void set_rate(float rate) = 0; + virtual void set_reference(float reference) = 0; + virtual void set_gain(float gain) = 0; + virtual void set_max_gain(float max_gain) = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_AGC_FF_H */ diff --git a/gr-analog/include/analog/api.h b/gr-analog/include/analog/api.h new file mode 100644 index 000000000..b7dee4693 --- /dev/null +++ b/gr-analog/include/analog/api.h @@ -0,0 +1,33 @@ +/* + * Copyright 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. + */ + +#ifndef INCLUDED_ANALOG_API_H +#define INCLUDED_ANALOG_API_H + +#include <gruel/attributes.h> + +#ifdef gnuradio_analog_EXPORTS +# define ANALOG_API __GR_ATTR_EXPORT +#else +# define ANALOG_API __GR_ATTR_IMPORT +#endif + +#endif /* INCLUDED_ANALOG_API_H */ diff --git a/gr-analog/include/analog/cpfsk_bc.h b/gr-analog/include/analog/cpfsk_bc.h new file mode 100644 index 000000000..904730e2b --- /dev/null +++ b/gr-analog/include/analog/cpfsk_bc.h @@ -0,0 +1,59 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2012 Free Software Foundation, Inc. + * + * 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_ANALOG_CPFSK_BC_H +#define INCLUDED_ANALOG_CPFSK_BC_H + +#include <analog/api.h> +#include <gr_sync_interpolator.h> + +namespace gr { + namespace analog { + + /*! + * \brief Perform continuous phase 2-level frequency shift keying modulation + * on an input stream of unpacked bits. + * \ingroup modulation_blk + */ + class ANALOG_API cpfsk_bc : virtual public gr_sync_interpolator + { + public: + // gr::analog::cpfsk_bc::sptr + typedef boost::shared_ptr<cpfsk_bc> sptr; + + /*! + * \brief Make a CPFSK block. + * + * \param k modulation index + * \param ampl output amplitude + * \param samples_per_sym number of output samples per input bit + */ + static sptr make(float k, float ampl, int samples_per_sym); + + virtual void set_amplitude(float amplitude) = 0; + virtual float amplitude() = 0; + virtual float freq() = 0; + virtual float phase() = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_CPFSK_BC_H */ diff --git a/gr-analog/include/analog/cpm.h b/gr-analog/include/analog/cpm.h new file mode 100644 index 000000000..d22e02321 --- /dev/null +++ b/gr-analog/include/analog/cpm.h @@ -0,0 +1,86 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,2012 Free Software Foundation, Inc. + * + * 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_ANALOG_CPM_H +#define INCLUDED_ANALOG_CPM_H + +#include <analog/api.h> +#include <vector> + +namespace gr { + namespace analog { + + class ANALOG_API cpm + { + public: + enum cpm_type { + LRC, + LSRC, + LREC, + TFM, + GAUSSIAN, + GENERIC = 999 + }; + + /*! \brief Return the taps for an interpolating FIR filter (gr_interp_fir_filter_fff). + * + * These taps represent the phase response \f$g(k)\f$ for use in a CPM modulator, + * see also gr_cpmmod_bc. + * + * \param type The CPM type (Rectangular, Raised Cosine, Spectral Raised Cosine, + * Tamed FM or Gaussian). + * \param samples_per_sym Samples per symbol. + * \param L The length of the phase response in symbols. + * \param beta For Spectral Raised Cosine, this is the rolloff factor. For Gaussian + * phase responses, this the 3dB-time-bandwidth product. For all other + * cases, it is ignored. + * + * Output: returns a vector of length \a K = \p samples_per_sym x \p L. + * This can be used directly in an interpolating FIR filter such as + * gr_interp_fir_filter_fff with interpolation factor \p samples_per_sym. + * + * All phase responses are normalised s.t. \f$ \sum_{k=0}^{K-1} g(k) = 1\f$; this will cause + * a maximum phase change of \f$ h \cdot \pi\f$ between two symbols, where \a h is the + * modulation index. + * + * The following phase responses can be generated: + * - LREC: Rectangular phase response. + * - LRC: Raised cosine phase response, looks like 1 - cos(x). + * - LSRC: Spectral raised cosine. This requires a rolloff factor beta. + * The phase response is the Fourier transform of raised cosine + * function. + * - TFM: Tamed frequency modulation. This scheme minimizes phase change for + * rapidly varying input symbols. + * - GAUSSIAN: A Gaussian phase response. For a modulation index h = 1/2, this + * results in GMSK. + * + * A short description of all these phase responses can be found in [1]. + * + * [1]: Anderson, Aulin and Sundberg; Digital Phase Modulation + */ + static std::vector<float> + phase_response(cpm_type type, unsigned samples_per_sym, unsigned L, double beta=0.3); + }; + } // namespace analog +} // namespace gr + +#endif /* INCLUDED_ANALOG_CPM_H */ + diff --git a/gr-analog/include/analog/ctcss_squelch_ff.h b/gr-analog/include/analog/ctcss_squelch_ff.h new file mode 100644 index 000000000..f88029917 --- /dev/null +++ b/gr-analog/include/analog/ctcss_squelch_ff.h @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,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. + */ + +#ifndef INCLUDED_ANALOG_CTCSS_SQUELCH_FF_H +#define INCLUDED_ANALOG_CTCSS_SQUELCH_FF_H + +#include <analog/api.h> +#include <analog/squelch_base_ff.h> +#include <gr_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief gate or zero output if ctcss tone not present + * \ingroup level_blk + */ + class ANALOG_API ctcss_squelch_ff : + public squelch_base_ff, virtual public gr_block + { + protected: + virtual void update_state(const float &in) = 0; + virtual bool mute() const = 0; + + public: + // gr::analog::ctcss_squelch_ff::sptr + typedef boost::shared_ptr<ctcss_squelch_ff> sptr; + + /*! + * \brief Make CTCSS tone squelch block. + */ + static sptr make(int rate, float freq, float level, + int len, int ramp, bool gate); + + virtual std::vector<float> squelch_range() const = 0; + virtual float level() const = 0; + virtual void set_level(float level) = 0; + virtual int len() const = 0; + + virtual int ramp() const = 0; + virtual void set_ramp(int ramp) = 0; + virtual bool gate() const = 0; + virtual void set_gate(bool gate) = 0; + virtual bool unmuted() const = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_CTCSS_SQUELCH_FF_H */ diff --git a/gr-analog/include/analog/dpll_bb.h b/gr-analog/include/analog/dpll_bb.h new file mode 100644 index 000000000..78efb8fde --- /dev/null +++ b/gr-analog/include/analog/dpll_bb.h @@ -0,0 +1,59 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,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. + */ + +#ifndef INCLUDED_ANALOG_DPLL_BB_H +#define INCLUDED_ANALOG_DPLL_BB_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief Detect the peak of a signal + * \ingroup level_blk + * + * If a peak is detected, this block outputs a 1, + * or it outputs 0's. + */ + class ANALOG_API dpll_bb : virtual public gr_sync_block + { + public: + // gr::analog::dpll_bb::sptr + typedef boost::shared_ptr<dpll_bb> sptr; + + static sptr make(float period, float gain); + + virtual void set_gain(float gain) = 0; + virtual void set_decision_threshold(float thresh) = 0; + + virtual float gain() const = 0; + virtual float freq() const = 0; + virtual float phase() const = 0; + virtual float decision_threshold() const = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_DPLL_BB_H */ diff --git a/gr-analog/include/analog/feedforward_agc_cc.h b/gr-analog/include/analog/feedforward_agc_cc.h new file mode 100644 index 000000000..9e259a4eb --- /dev/null +++ b/gr-analog/include/analog/feedforward_agc_cc.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,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. + */ + +#ifndef INCLUDED_ANALOG_FEEDFORWARD_AGC_CC_H +#define INCLUDED_ANALOG_FEEDFORWARD_AGC_CC_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief Non-causal AGC which computes required gain based on max absolute value over nsamples + * \ingroup level_blk + */ + class ANALOG_API feedforward_agc_cc : virtual public gr_sync_block + { + public: + // gr::analog::feedforward_agc_cc::sptr + typedef boost::shared_ptr<feedforward_agc_cc> sptr; + + static sptr make(int nsamples, float reference); + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_FEEDFORWARD_AGC_CC_H */ diff --git a/gr-analog/include/analog/fmdet_cf.h b/gr-analog/include/analog/fmdet_cf.h new file mode 100644 index 000000000..6878775e6 --- /dev/null +++ b/gr-analog/include/analog/fmdet_cf.h @@ -0,0 +1,70 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,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. + */ + +#ifndef INCLUDED_ANALOG_FMDET_CF_H +#define INCLUDED_ANALOG_FMDET_CF_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \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 ANALOG_API fmdet_cf : virtual public gr_sync_block + { + public: + // gr::analog::fmdet_cf::sptr + typedef boost::shared_ptr<fmdet_cf> sptr; + + /*! + * \brief Make FM detector block. + * + * \param samplerate sample rate of signal (is not used; to be removed) + * \param freq_low lowest frequency of signal (Hz) + * \param freq_high highest frequency of signal (Hz) + * \param scl scale factor + */ + static sptr make(float samplerate, float freq_low, + float freq_high, float scl); + + virtual void set_scale(float scl) = 0; + virtual void set_freq_range(float freq_low, float freq_high) = 0; + + virtual float freq() const = 0; + virtual float freq_high() const = 0; + virtual float freq_low() const = 0; + virtual float scale() const = 0; + virtual float bias() const = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_FMDET_CF_H */ diff --git a/gr-analog/include/analog/frequency_modulator_fc.h b/gr-analog/include/analog/frequency_modulator_fc.h new file mode 100644 index 000000000..8706d513a --- /dev/null +++ b/gr-analog/include/analog/frequency_modulator_fc.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifndef INCLUDED_ANALOG_FREQUENCY_MODULATOR_FC_H +#define INCLUDED_ANALOG_FREQUENCY_MODULATOR_FC_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief Frequency modulator block + * \ingroup modulation_blk + * + * float input; complex baseband output + */ + class ANALOG_API frequency_modulator_fc : virtual public gr_sync_block + { + public: + // gr::analog::frequency_modulator_fc::sptr + typedef boost::shared_ptr<frequency_modulator_fc> sptr; + + static sptr make(double sensitivity); + + virtual void set_sensitivity(float sens) = 0; + virtual float sensitivity() const = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_FREQUENCY_MODULATOR_FC_H */ diff --git a/gr-analog/include/analog/lfsr.h b/gr-analog/include/analog/lfsr.h new file mode 100644 index 000000000..5cf2ec70d --- /dev/null +++ b/gr-analog/include/analog/lfsr.h @@ -0,0 +1,162 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2010,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. + */ + +#ifndef INCLUDED_ANALOG_LFSR_H +#define INCLUDED_ANALOG_LFSR_H + +#include <analog/api.h> +#include <stdexcept> +#include <stdint.h> + +namespace gr { + namespace analog { + + /*! + * \brief Fibonacci Linear Feedback Shift Register using specified + * polynomial mask + * \ingroup misc + * + * Generates a maximal length pseudo-random sequence of length + * 2^degree-1 + * + * Constructor: analog::lfsr(int mask, int seed, int reg_len); + * + * \param mask - polynomial coefficients representing the + * locations of feedback taps from a shift register + * which are xor'ed together to form the new high + * order bit. + * + * Some common masks might be: + * x^4 + x^3 + x^0 = 0x19 + * x^5 + x^3 + x^0 = 0x29 + * x^6 + x^5 + x^0 = 0x61 + * + * \param seed - the initialization vector placed into the + * register durring initialization. Low order bit + * corresponds to x^0 coefficient -- the first to be + * shifted as output. + * + * \param reg_len - specifies the length of the feedback shift + * register to be used. Durring each iteration, the + * register is rightshifted one and the new bit is + * placed in bit reg_len. reg_len should generally be + * at least order(mask) + 1 + * + * + * see http://en.wikipedia.org/wiki/Linear_feedback_shift_register + * for more explanation. + * + * next_bit() - Standard LFSR operation + * + * Perform one cycle of the LFSR. The output bit is taken from + * the shift register LSB. The shift register MSB is assigned from + * the modulo 2 sum of the masked shift register. + * + * next_bit_scramble(unsigned char input) - Scramble an input stream + * + * Perform one cycle of the LFSR. The output bit is taken from + * the shift register LSB. The shift register MSB is assigned from + * the modulo 2 sum of the masked shift register and the input LSB. + * + * next_bit_descramble(unsigned char input) - Descramble an input stream + * + * Perform one cycle of the LFSR. The output bit is taken from + * the modulo 2 sum of the masked shift register and the input LSB. + * The shift register MSB is assigned from the LSB of the input. + * + * See http://en.wikipedia.org/wiki/Scrambler for operation of these + * last two functions (see multiplicative scrambler.) + */ + class lfsr + { + private: + uint32_t d_shift_register; + uint32_t d_mask; + uint32_t d_seed; + uint32_t d_shift_register_length; // less than 32 + + static uint32_t + popCount(uint32_t x) + { + uint32_t r = x - ((x >> 1) & 033333333333) + - ((x >> 2) & 011111111111); + return ((r + (r >> 3)) & 030707070707) % 63; + } + + public: + lfsr(uint32_t mask, uint32_t seed, uint32_t reg_len) + : d_shift_register(seed), + d_mask(mask), + d_seed(seed), + d_shift_register_length(reg_len) + { + if(reg_len > 31) + throw std::invalid_argument("reg_len must be <= 31"); + } + + unsigned char next_bit() + { + unsigned char output = d_shift_register & 1; + unsigned char newbit = popCount( d_shift_register & d_mask )%2; + d_shift_register = ((d_shift_register>>1) | (newbit<<d_shift_register_length)); + return output; + } + + unsigned char next_bit_scramble(unsigned char input) + { + unsigned char output = d_shift_register & 1; + unsigned char newbit = (popCount( d_shift_register & d_mask )%2)^(input & 1); + d_shift_register = ((d_shift_register>>1) | (newbit<<d_shift_register_length)); + return output; + } + + unsigned char next_bit_descramble(unsigned char input) + { + unsigned char output = (popCount( d_shift_register & d_mask )%2)^(input & 1); + unsigned char newbit = input & 1; + d_shift_register = ((d_shift_register>>1) | (newbit<<d_shift_register_length)); + return output; + } + + /*! + * Reset shift register to initial seed value + */ + void reset() { d_shift_register = d_seed; } + + /*! + * Rotate the register through x number of bits + * where we are just throwing away the results to get queued up correctly + */ + void pre_shift(int num) + { + for(int i=0; i<num; i++) { + next_bit(); + } + } + + int mask() const { return d_mask; } + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_LFSR_H */ diff --git a/gr-analog/include/analog/noise_source_X.h.t b/gr-analog/include/analog/noise_source_X.h.t new file mode 100644 index 000000000..9d1be6fed --- /dev/null +++ b/gr-analog/include/analog/noise_source_X.h.t @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <analog/api.h> +#include <analog/noise_type.h> +#include <gr_sync_block.h> +#include <gr_random.h> + +namespace gr { + namespace analog { + + /*! + * \brief Random number source + * \ingroup source_blk + * + * \details + * Generate random values from different distributions. + * Currently, only Gaussian and uniform are enabled. + */ + class ANALOG_API @BASE_NAME@ : virtual public gr_sync_block + { + public: + // gr::analog::@BASE_NAME@::sptr + typedef boost::shared_ptr<@BASE_NAME@> sptr; + + /*! \brief Make a noise source + * \param type the random distribution to use (see analog/noise_type.h) + * \param ampl a scaling factor for the output + * \param seed seed for random generators. Note that for uniform and + * Gaussian distributions, this should be a negative number. + */ + static sptr make(noise_type_t type, float ampl, long seed); + + virtual void set_type(noise_type_t type) = 0; + virtual void set_amplitude(float ampl) = 0; + + virtual noise_type_t type() const = 0; + virtual float amplitude() const = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-analog/include/analog/noise_type.h b/gr-analog/include/analog/noise_type.h new file mode 100644 index 000000000..c3a2146b7 --- /dev/null +++ b/gr-analog/include/analog/noise_type.h @@ -0,0 +1,36 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifndef INCLUDED_ANALOG_NOISE_TYPE_H +#define INCLUDED_ANALOG_NOISE_TYPE_H + +namespace gr { + namespace analog { + + typedef enum { + GR_UNIFORM = 200, GR_GAUSSIAN, GR_LAPLACIAN, GR_IMPULSE + } noise_type_t; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_NOISE_TYPE_H */ diff --git a/gr-analog/include/analog/phase_modulator_fc.h b/gr-analog/include/analog/phase_modulator_fc.h new file mode 100644 index 000000000..409de7804 --- /dev/null +++ b/gr-analog/include/analog/phase_modulator_fc.h @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,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. + */ + +#ifndef INCLUDED_ANALOG_PHASE_MODULATOR_FC_H +#define INCLUDED_ANALOG_PHASE_MODULATOR_FC_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief Phase modulator block + * \ingroup modulation_blk + * + * output = complex(cos(in*sensitivity), sin(in*sensitivity)) + * + * Input stream 0: floats + * Ouput stream 0: complex + */ + class ANALOG_API phase_modulator_fc : virtual public gr_sync_block + { + public: + // gr::analog::phase_modulator_fc::sptr + typedef boost::shared_ptr<phase_modulator_fc> sptr; + + /* \brief Make a phase modulator block. + * + * \param sensitivity Phase change sensitivity of input amplitude. + */ + static sptr make(double sensitivity); + + virtual double sensitivity() const = 0; + virtual double phase() const = 0; + + virtual void set_sensitivity(double s) = 0; + virtual void set_phase(double p) = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_PHASE_MODULATOR_FC_H */ diff --git a/gr-analog/include/analog/pll_carriertracking_cc.h b/gr-analog/include/analog/pll_carriertracking_cc.h new file mode 100644 index 000000000..3596429d4 --- /dev/null +++ b/gr-analog/include/analog/pll_carriertracking_cc.h @@ -0,0 +1,88 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2006,2011,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. + */ + +#ifndef INCLUDED_ANALOG_PLL_CARRIERTRACKING_CC_H +#define INCLUDED_ANALOG_PLL_CARRIERTRACKING_CC_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief Implements a PLL which locks to the input frequency and outputs the + * input signal mixed with that carrier. + * \ingroup sync_blk + * + * Input stream 0: complex + * Output stream 0: complex + * + * This PLL locks onto a [possibly noisy] reference carrier on the + * input and outputs that signal, downconverted to DC + * + * All settings max_freq and min_freq are in terms of radians per + * sample, NOT HERTZ. The loop bandwidth determins the lock range + * and should be set around pi/200 -- 2pi/100. \sa + * pll_freqdet_cf, pll_carriertracking_cc + */ + class ANALOG_API pll_carriertracking_cc : virtual public gr_sync_block + { + public: + // gr::analog::pll_carriertracking_cc::sptr + typedef boost::shared_ptr<pll_carriertracking_cc> sptr; + + /* \brief Make a carrier tracking PLL block. + * + * \param loop_bw: control loop's bandwidth parameter. + * \param max_freq: maximum (normalized) frequency PLL will lock to. + * \param min_freq: minimum (normalized) frequency PLL will lock to. + */ + static sptr make(float loop_bw, float max_freq, float min_freq); + + virtual bool lock_detector(void) = 0; + virtual bool squelch_enable(bool) = 0; + virtual float set_lock_threshold(float) = 0; + + virtual void set_loop_bandwidth(float bw) = 0; + virtual void set_damping_factor(float df) = 0; + virtual void set_alpha(float alpha) = 0; + virtual void set_beta(float beta) = 0; + virtual void set_frequency(float freq) = 0; + virtual void set_phase(float phase) = 0; + virtual void set_min_freq(float freq) = 0; + virtual void set_max_freq(float freq) = 0; + + virtual float get_loop_bandwidth() const = 0; + virtual float get_damping_factor() const = 0; + virtual float get_alpha() const = 0; + virtual float get_beta() const = 0; + virtual float get_frequency() const = 0; + virtual float get_phase() const = 0; + virtual float get_min_freq() const = 0; + virtual float get_max_freq() const = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_PLL_CARRIERTRACKING_CC_H */ diff --git a/gr-analog/include/analog/pll_freqdet_cf.h b/gr-analog/include/analog/pll_freqdet_cf.h new file mode 100644 index 000000000..613e85263 --- /dev/null +++ b/gr-analog/include/analog/pll_freqdet_cf.h @@ -0,0 +1,83 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifndef INCLUDED_ANALOG_PLL_FREQDET_CF_H +#define INCLUDED_ANALOG_PLL_FREQDET_CF_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief Implements a PLL which locks to the input frequency and outputs + * an estimate of that frequency. Useful for FM Demod. + * \ingroup sync_blk + * + * Input stream 0: complex + * Output stream 0: float + * + * This PLL locks onto a [possibly noisy] reference carrier on + * the input and outputs an estimate of that frequency in radians per sample. + * All settings max_freq and min_freq are in terms of radians per sample, + * NOT HERTZ. The loop bandwidth determins the lock range and should be set + * around pi/200 -- 2pi/100. + * \sa pll_refout_cc, pll_carriertracking_cc + */ + class ANALOG_API pll_freqdet_cf : virtual public gr_sync_block + { + public: + // gr::analog::pll_freqdet_cf::sptr + typedef boost::shared_ptr<pll_freqdet_cf> sptr; + + /* \brief Make PLL block that outputs the tracked signal's frequency. + * + * \param loop_bw: control loop's bandwidth parameter. + * \param max_freq: maximum (normalized) frequency PLL will lock to. + * \param min_freq: minimum (normalized) frequency PLL will lock to. + */ + static sptr make(float loop_bw, float max_freq, float min_freq); + + virtual void set_loop_bandwidth(float bw) = 0; + virtual void set_damping_factor(float df) = 0; + virtual void set_alpha(float alpha) = 0; + virtual void set_beta(float beta) = 0; + virtual void set_frequency(float freq) = 0; + virtual void set_phase(float phase) = 0; + virtual void set_min_freq(float freq) = 0; + virtual void set_max_freq(float freq) = 0; + + virtual float get_loop_bandwidth() const = 0; + virtual float get_damping_factor() const = 0; + virtual float get_alpha() const = 0; + virtual float get_beta() const = 0; + virtual float get_frequency() const = 0; + virtual float get_phase() const = 0; + virtual float get_min_freq() const = 0; + virtual float get_max_freq() const = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_PLL_FREQDET_CF_H */ diff --git a/gr-analog/include/analog/pll_refout_cc.h b/gr-analog/include/analog/pll_refout_cc.h new file mode 100644 index 000000000..a18d177e6 --- /dev/null +++ b/gr-analog/include/analog/pll_refout_cc.h @@ -0,0 +1,66 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2011,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. + */ + +#ifndef INCLUDED_ANALOG_PLL_REFOUT_CC_H +#define INCLUDED_ANALOG_PLL_REFOUT_CC_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief Implements a PLL which locks to the input frequency and outputs a carrier + * \ingroup sync_blk + * + * Input stream 0: complex + * Output stream 0: complex + * + * This PLL locks onto a [possibly noisy] reference carrier on the + * input and outputs a clean version which is phase and frequency + * aligned to it. + * + * All settings max_freq and min_freq are in terms of radians per + * sample, NOT HERTZ. The loop bandwidth determins the lock range + * and should be set around pi/200 -- 2pi/100. \sa + * pll_freqdet_cf, pll_carriertracking_cc + */ + class ANALOG_API pll_refout_cc : virtual public gr_sync_block + { + public: + // gr::analog::pll_refout_cc::sptr + typedef boost::shared_ptr<pll_refout_cc> sptr; + + /* \brief Make PLL block that outputs the tracked carrier signal. + * + * \param loop_bw: control loop's bandwidth parameter. + * \param max_freq: maximum (normalized) frequency PLL will lock to. + * \param min_freq: minimum (normalized) frequency PLL will lock to. + */ + static sptr make(float loop_bw, float max_freq, float min_freq); + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_PLL_REFOUT_CC_H */ diff --git a/gr-analog/include/analog/probe_avg_mag_sqrd_c.h b/gr-analog/include/analog/probe_avg_mag_sqrd_c.h new file mode 100644 index 000000000..9e62732a3 --- /dev/null +++ b/gr-analog/include/analog/probe_avg_mag_sqrd_c.h @@ -0,0 +1,67 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,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. + */ +#ifndef INCLUDED_ANALOG_PROBE_AVG_MAG_SQRD_C_H +#define INCLUDED_ANALOG_PROBE_AVG_MAG_SQRD_C_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief compute avg magnitude squared. + * \ingroup sink_blk + * + * Input stream 0: complex + * + * Compute a running average of the magnitude squared of the the + * input. The level and indication as to whether the level exceeds + * threshold can be retrieved with the level and unmuted + * accessors. + */ + class ANALOG_API probe_avg_mag_sqrd_c : virtual public gr_sync_block + { + public: + // gr::analog::probe_avg_mag_sqrd_c::sptr + typedef boost::shared_ptr<probe_avg_mag_sqrd_c> sptr; + + /*! + * \brief Make a complex sink that computes avg magnitude squared. + * + * \param threshold_db Threshold for muting. + * \param alpha Gain parameter for the running average filter. + */ + static sptr make(double threshold_db, double alpha = 0.0001); + + virtual bool unmuted() const = 0; + virtual double level() const = 0; + virtual double threshold() const = 0; + + virtual void set_alpha(double alpha) = 0; + virtual void set_threshold(double decibels) = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_PROBE_AVG_MAG_SQRD_C_H */ diff --git a/gr-analog/include/analog/probe_avg_mag_sqrd_cf.h b/gr-analog/include/analog/probe_avg_mag_sqrd_cf.h new file mode 100644 index 000000000..b18916ae9 --- /dev/null +++ b/gr-analog/include/analog/probe_avg_mag_sqrd_cf.h @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2006,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. + */ + +#ifndef INCLUDED_ANALOG_PROBE_AVG_MAG_SQRD_CF_H +#define INCLUDED_ANALOG_PROBE_AVG_MAG_SQRD_CF_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief compute avg magnitude squared. + * \ingroup sink_blk + * + * Input stream 0: complex + * Output stream 0: float + * + * Compute a running average of the magnitude squared of the the + * input. The level and indication as to whether the level exceeds + * threshold can be retrieved with the level and unmuted + * accessors. + */ + class ANALOG_API probe_avg_mag_sqrd_cf : virtual public gr_sync_block + { + public: + // gr::analog::probe_avg_mag_sqrd_cf::sptr + typedef boost::shared_ptr<probe_avg_mag_sqrd_cf> sptr; + + /*! + * \brief Make a block that computes avg magnitude squared. + * + * \param threshold_db Threshold for muting. + * \param alpha Gain parameter for the running average filter. + */ + static sptr make(double threshold_db, double alpha = 0.0001); + + virtual bool unmuted() const = 0; + virtual double level() const = 0; + virtual double threshold() const = 0; + + virtual void set_alpha(double alpha) = 0; + virtual void set_threshold(double decibels) = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_PROBE_AVG_MAG_SQRD_CF_H */ diff --git a/gr-analog/include/analog/probe_avg_mag_sqrd_f.h b/gr-analog/include/analog/probe_avg_mag_sqrd_f.h new file mode 100644 index 000000000..fe9d27793 --- /dev/null +++ b/gr-analog/include/analog/probe_avg_mag_sqrd_f.h @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifndef INCLUDED_ANALOG_PROBE_AVG_MAG_SQRD_F_H +#define INCLUDED_ANALOG_PROBE_AVG_MAG_SQRD_F_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief compute avg magnitude squared. + * \ingroup sink_blk + * + * input stream 0: float + * + * Compute a running average of the magnitude squared of the the + * input. The level and indication as to whether the level exceeds + * threshold can be retrieved with the level and unmuted + * accessors. + */ + class ANALOG_API probe_avg_mag_sqrd_f : virtual public gr_sync_block + { + public: + // gr::analog::probe_avg_mag_sqrd_f::sptr + typedef boost::shared_ptr<probe_avg_mag_sqrd_f> sptr; + + /*! + * \brief Make a float sink that computes avg magnitude squared. + * + * \param threshold_db Threshold for muting. + * \param alpha Gain parameter for the running average filter. + */ + static sptr make(double threshold_db, double alpha = 0.0001); + + virtual bool unmuted() const = 0; + virtual double level() const = 0; + + virtual double threshold() const = 0; + + virtual void set_alpha (double alpha) = 0; + virtual void set_threshold (double decibels) = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_PROBE_AVG_MAG_SQRD_F_H */ diff --git a/gr-analog/include/analog/pwr_squelch_cc.h b/gr-analog/include/analog/pwr_squelch_cc.h new file mode 100644 index 000000000..79364a86b --- /dev/null +++ b/gr-analog/include/analog/pwr_squelch_cc.h @@ -0,0 +1,75 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,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. + */ + +#ifndef INCLUDED_ANALOG_PWR_SQUELCH_CC_H +#define INCLUDED_ANALOG_PWR_SQUELCH_CC_H + +#include <analog/api.h> +#include <analog/squelch_base_cc.h> +#include <cmath> + +namespace gr { + namespace analog { + + /*! + * \brief gate or zero output when input power below threshold + * \ingroup level_blk + */ + class ANALOG_API pwr_squelch_cc : + public squelch_base_cc, virtual public gr_block + { + protected: + virtual void update_state(const gr_complex &in) = 0; + virtual bool mute() const = 0; + + public: + // gr::analog::pwr_squelch_cc::sptr + typedef boost::shared_ptr<pwr_squelch_cc> sptr; + + /*! + * \brief Make power-based squelch block. + * + * \param db threshold (in dB) for power squelch + * \param alpha Gain of averaging filter + * \param ramp + * \param gate + */ + static sptr make(double db, double alpha=0.0001, + int ramp=0, bool gate=false); + + virtual std::vector<float> squelch_range() const = 0; + + virtual double threshold() const = 0; + virtual void set_threshold(double db) = 0; + virtual void set_alpha(double alpha) = 0; + + virtual int ramp() const = 0; + virtual void set_ramp(int ramp) = 0; + virtual bool gate() const = 0; + virtual void set_gate(bool gate) = 0; + virtual bool unmuted() const = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_PWR_SQUELCH_CC_H */ diff --git a/gr-analog/include/analog/pwr_squelch_ff.h b/gr-analog/include/analog/pwr_squelch_ff.h new file mode 100644 index 000000000..6fdebec74 --- /dev/null +++ b/gr-analog/include/analog/pwr_squelch_ff.h @@ -0,0 +1,75 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,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. + */ + +#ifndef INCLUDED_ANALOG_PWR_SQUELCH_FF_H +#define INCLUDED_ANALOG_PWR_SQUELCH_FF_H + +#include <analog/api.h> +#include <analog/squelch_base_ff.h> +#include <cmath> + +namespace gr { + namespace analog { + + /*! + * \brief gate or zero output when input power below threshold + * \ingroup level_blk + */ + class ANALOG_API pwr_squelch_ff : + public squelch_base_ff, virtual public gr_block + { + protected: + virtual void update_state(const float &in) = 0; + virtual bool mute() const = 0; + + public: + // gr::analog::pwr_squelch_ff::sptr + typedef boost::shared_ptr<pwr_squelch_ff> sptr; + + /*! + * \brief Make power-based squelch block. + * + * \param db threshold (in dB) for power squelch + * \param alpha Gain of averaging filter + * \param ramp + * \param gate + */ + static sptr make(double db, double alpha=0.0001, + int ramp=0, bool gate=false); + + virtual std::vector<float> squelch_range() const = 0; + + virtual double threshold() const = 0; + virtual void set_threshold(double db) = 0; + virtual void set_alpha(double alpha) = 0; + + virtual int ramp() const = 0; + virtual void set_ramp(int ramp) = 0; + virtual bool gate() const = 0; + virtual void set_gate(bool gate) = 0; + virtual bool unmuted() const = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_PWR_SQUELCH_FF_H */ diff --git a/gr-analog/include/analog/quadrature_demod_cf.h b/gr-analog/include/analog/quadrature_demod_cf.h new file mode 100644 index 000000000..916d8b2ec --- /dev/null +++ b/gr-analog/include/analog/quadrature_demod_cf.h @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifndef INCLUDED_ANALOG_QUADRATURE_DEMOD_CF_H +#define INCLUDED_ANALOG_QUADRATURE_DEMOD_CF_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief quadrature demodulator: complex in, float out + * \ingroup demodulation_blk + * + * This can be used to demod FM, FSK, GMSK, etc. + * The input is complex baseband. + */ + class ANALOG_API quadrature_demod_cf : virtual public gr_sync_block + { + public: + // gr::analog::quadrature_demod_cf::sptr + typedef boost::shared_ptr<quadrature_demod_cf> sptr; + + static sptr make(float gain); + + virtual void set_gain(float gain) = 0; + virtual float gain() const = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_QUADRATURE_DEMOD_CF_H */ diff --git a/gr-analog/include/analog/rail_ff.h b/gr-analog/include/analog/rail_ff.h new file mode 100644 index 000000000..e51b2fc93 --- /dev/null +++ b/gr-analog/include/analog/rail_ff.h @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifndef INCLUDED_ANALOG_RAIL_FF_H +#define INCLUDED_ANALOG_RAIL_FF_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief clips input values to min, max + * \ingroup misc + */ + class ANALOG_API rail_ff : virtual public gr_sync_block + { + public: + // gr::analog::rail_ff::sptr + typedef boost::shared_ptr<rail_ff> sptr; + + static sptr make(float lo, float hi); + + virtual float lo() const = 0; + virtual float hi() const = 0; + + virtual void set_lo(float lo) = 0; + virtual void set_hi(float hi) = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_RAIL_FF_H */ diff --git a/gr-analog/include/analog/rotator.h b/gr-analog/include/analog/rotator.h new file mode 100644 index 000000000..ee3849eae --- /dev/null +++ b/gr-analog/include/analog/rotator.h @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2003,2008,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. + */ + +#ifndef _ANALOG_ROTATOR_H_ +#define _ANALOG_ROTATOR_H_ + +#include <analog/api.h> +#include <gr_complex.h> + +namespace gr { + namespace analog { + + class rotator + { + private: + gr_complex d_phase; + gr_complex d_phase_incr; + unsigned int d_counter; + + public: + rotator() : d_phase (1), d_phase_incr (1), d_counter(0) + { } + + void set_phase(gr_complex phase) { d_phase = phase / abs(phase); } + void set_phase_incr(gr_complex incr) { d_phase_incr = incr / abs(incr); } + + gr_complex rotate (gr_complex in) + { + d_counter++; + + gr_complex z = in * d_phase; // rotate in by phase + d_phase *= d_phase_incr; // incr our phase (complex mult == add phases) + + if((d_counter % 512) == 0) + d_phase /= abs(d_phase); // Normalize to ensure multiplication is rotation + + return z; + } + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* _ANALOG_ROTATOR_H_ */ diff --git a/gr-analog/include/analog/sig_source_X.h.t b/gr-analog/include/analog/sig_source_X.h.t new file mode 100644 index 000000000..2915c2abe --- /dev/null +++ b/gr-analog/include/analog/sig_source_X.h.t @@ -0,0 +1,75 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +/* @WARNING@ */ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <analog/api.h> +#include <analog/sig_source_waveform.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief signal generator with @TYPE@ output. + * \ingroup source_blk + */ + class ANALOG_API @BASE_NAME@ : virtual public gr_sync_block + { + public: + // gr::analog::@BASE_NAME@::sptr + typedef boost::shared_ptr<@BASE_NAME@> sptr; + + /*! + * \brief Make a signal source block. + * + * \param sampling_freq Sampling rate of signal. + * \param waveform wavetform type. + * \param wave_freq Frequency of waveform (relative to sampling_freq). + * \param ampl Signal amplitude. + * \param offset offset of signal. + */ + static sptr make(double sampling_freq, + gr::analog::gr_waveform_t waveform, + double wave_freq, + double ampl, @TYPE@ offset = 0); + + virtual double sampling_freq() const = 0; + virtual gr::analog::gr_waveform_t waveform() const = 0; + virtual double frequency() const = 0; + virtual double amplitude() const = 0; + virtual @TYPE@ offset() const = 0; + + virtual void set_sampling_freq(double sampling_freq) = 0; + virtual void set_waveform(gr::analog::gr_waveform_t waveform) = 0; + virtual void set_frequency(double frequency) = 0; + virtual void set_amplitude(double ampl) = 0; + virtual void set_offset(@TYPE@ offset) = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-analog/include/analog/sig_source_waveform.h b/gr-analog/include/analog/sig_source_waveform.h new file mode 100644 index 000000000..3a9edb8f3 --- /dev/null +++ b/gr-analog/include/analog/sig_source_waveform.h @@ -0,0 +1,41 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifndef INCLUDED_ANALOG_SIG_SOURCE_WAVEFORM_H +#define INCLUDED_ANALOG_SIG_SOURCE_WAVEFORM_H + +namespace gr { + namespace analog { + + typedef enum { + GR_CONST_WAVE = 100, + GR_SIN_WAVE, + GR_COS_WAVE, + GR_SQR_WAVE, + GR_TRI_WAVE, + GR_SAW_WAVE + } gr_waveform_t; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_SIG_SOURCE_WAVEFORM_H */ diff --git a/gr-analog/include/analog/simple_squelch_cc.h b/gr-analog/include/analog/simple_squelch_cc.h new file mode 100644 index 000000000..1e12646e4 --- /dev/null +++ b/gr-analog/include/analog/simple_squelch_cc.h @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifndef INCLUDED_ANALOG_SIMPLE_SQUELCH_CC_H +#define INCLUDED_ANALOG_SIMPLE_SQUELCH_CC_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief simple squelch block based on average signal power and threshold in dB. + * \ingroup level_blk + */ + class ANALOG_API simple_squelch_cc : virtual public gr_sync_block + { + public: + // gr::analog::simple_squelch_cc::sptr + typedef boost::shared_ptr<simple_squelch_cc> sptr; + + /*! + * \brief Make a simple squelch block. + * + * \param threshold_db Threshold for muting. + * \param alpha Gain parameter for the running average filter. + */ + static sptr make(double threshold_db, double alpha); + + virtual bool unmuted() const = 0; + + virtual void set_alpha(double alpha) = 0; + virtual void set_threshold(double decibels) = 0; + + virtual double threshold() const = 0; + virtual std::vector<float> squelch_range() const = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_SIMPLE_SQUELCH_CC_H */ diff --git a/gr-analog/include/analog/sincos.h b/gr-analog/include/analog/sincos.h new file mode 100644 index 000000000..38b9d96da --- /dev/null +++ b/gr-analog/include/analog/sincos.h @@ -0,0 +1,38 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2004,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. + */ + +#ifndef INCLUDED_ANALOG_SINCOS_H +#define INCLUDED_ANALOG_SINCOS_H + +#include <analog/api.h> + +namespace gr { + namespace analog { + + // compute sine and cosine at the same time + ANALOG_API void sincos(double x, double *sin, double *cos); + ANALOG_API void sincosf(float x, float *sin, float *cos); + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_SINCOS_H */ diff --git a/gr-analog/include/analog/squelch_base_cc.h b/gr-analog/include/analog/squelch_base_cc.h new file mode 100644 index 000000000..11476e7e8 --- /dev/null +++ b/gr-analog/include/analog/squelch_base_cc.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,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. + */ + +#ifndef INCLUDED_ANALOG_SQUELCH_BASE_CC_H +#define INCLUDED_ANALOG_SQUELCH_BASE_CC_H + +#include <analog/api.h> +#include <gr_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief basic squelch block; to be subclassed for other squelches. + * \ingroup level_blk + */ + class ANALOG_API squelch_base_cc : virtual public gr_block + { + protected: + virtual void update_state(const gr_complex &sample) = 0; + virtual bool mute() const = 0; + + public: + squelch_base_cc() {}; + virtual int ramp() const = 0; + virtual void set_ramp(int ramp) = 0; + virtual bool gate() const = 0; + virtual void set_gate(bool gate) = 0; + virtual bool unmuted() const = 0; + + virtual std::vector<float> squelch_range() const = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_SQUELCH_BASE_CC_H */ diff --git a/gr-analog/include/analog/squelch_base_ff.h b/gr-analog/include/analog/squelch_base_ff.h new file mode 100644 index 000000000..2ce1f1a65 --- /dev/null +++ b/gr-analog/include/analog/squelch_base_ff.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,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. + */ + +#ifndef INCLUDED_ANALOG_SQUELCH_BASE_FF_H +#define INCLUDED_ANALOG_SQUELCH_BASE_FF_H + +#include <analog/api.h> +#include <gr_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief basic squelch block; to be subclassed for other squelches. + * \ingroup level_blk + */ + class ANALOG_API squelch_base_ff : virtual public gr_block + { + protected: + virtual void update_state(const float &sample) = 0; + virtual bool mute() const = 0; + + public: + squelch_base_ff() {}; + virtual int ramp() const = 0; + virtual void set_ramp(int ramp) = 0; + virtual bool gate() const = 0; + virtual void set_gate(bool gate) = 0; + virtual bool unmuted() const = 0; + + virtual std::vector<float> squelch_range() const = 0; + }; + + } /* namespace analog */ +} /* namespace gr */ + +#endif /* INCLUDED_ANALOG_SQUELCH_BASE_FF_H */ |