diff options
Diffstat (limited to 'gr-blocks/include/blocks')
-rw-r--r-- | gr-blocks/include/blocks/CMakeLists.txt | 11 | ||||
-rw-r--r-- | gr-blocks/include/blocks/delay.h | 57 | ||||
-rw-r--r-- | gr-blocks/include/blocks/log2_const.h | 53 | ||||
-rw-r--r-- | gr-blocks/include/blocks/packed_to_unpacked_XX.h.t | 73 | ||||
-rw-r--r-- | gr-blocks/include/blocks/peak_detector2_fb.h | 91 | ||||
-rw-r--r-- | gr-blocks/include/blocks/regenerate_bb.h | 80 | ||||
-rw-r--r-- | gr-blocks/include/blocks/rms_cf.h | 54 | ||||
-rw-r--r-- | gr-blocks/include/blocks/rms_ff.h | 53 | ||||
-rw-r--r-- | gr-blocks/include/blocks/stretch_ff.h | 59 | ||||
-rw-r--r-- | gr-blocks/include/blocks/threshold_ff.h | 66 | ||||
-rw-r--r-- | gr-blocks/include/blocks/throttle.h | 62 | ||||
-rw-r--r-- | gr-blocks/include/blocks/unpacked_to_packed_XX.h.t | 72 |
12 files changed, 731 insertions, 0 deletions
diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt index 37790b7cf..8d5fe9b13 100644 --- a/gr-blocks/include/blocks/CMakeLists.txt +++ b/gr-blocks/include/blocks/CMakeLists.txt @@ -78,6 +78,8 @@ expand_h(not_XX bb ss ii) expand_h(or_XX bb ss ii) expand_h(sub_XX ss ii ff cc) expand_h(xor_XX bb ss ii) +expand_h(packed_to_unpacked_XX bb ss ii) +expand_h(unpacked_to_packed_XX bb ss ii) add_custom_target(blocks_generated_includes DEPENDS ${generated_includes} @@ -90,6 +92,7 @@ install(FILES ${generated_includes} api.h count_bits.h + log2_const.h add_ff.h char_to_float.h char_to_short.h @@ -102,6 +105,7 @@ install(FILES complex_to_arg.h conjugate_cc.h deinterleave.h + delay.h file_source.h file_meta_sink.h file_meta_source.h @@ -122,7 +126,11 @@ install(FILES multiply_const_ff.h nlog10_ff.h patterned_interleaver.h + peak_detector2_fb.h + regenerate_bb.h repeat.h + rms_cf.h + rms_ff.h short_to_char.h short_to_float.h stream_mux.h @@ -130,6 +138,9 @@ install(FILES stream_to_vector.h streams_to_stream.h streams_to_vector.h + stretch_ff.h + threshold_ff.h + throttle.h uchar_to_float.h vector_to_stream.h vector_to_streams.h diff --git a/gr-blocks/include/blocks/delay.h b/gr-blocks/include/blocks/delay.h new file mode 100644 index 000000000..2a59fa0fc --- /dev/null +++ b/gr-blocks/include/blocks/delay.h @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2012-2013 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_BLOCKS_DELAY_H +#define INCLUDED_BLOCKS_DELAY_H + +#include <blocks/api.h> +#include <gr_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief delay the input by a certain number of samples + * \ingroup misc_blk + */ + class BLOCKS_API delay : virtual public gr_block + { + public: + // gr::blocks::delay::sptr + typedef boost::shared_ptr<delay> sptr; + + /*! + * \brief Make a delay block. + * \param itemsize size of the data items. + * \param delay number of samples to delay stream. + */ + static sptr make(size_t itemsize, int delay); + + virtual int dly() const = 0; + virtual void set_dly(int d) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_DELAY_H */ + diff --git a/gr-blocks/include/blocks/log2_const.h b/gr-blocks/include/blocks/log2_const.h new file mode 100644 index 000000000..67d63810f --- /dev/null +++ b/gr-blocks/include/blocks/log2_const.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2013 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. + */ + + +/* + * a bit of template hackery... + */ +#ifndef INCLUDED_BLOCKS_LOG2_CONST_H +#define INCLUDED_BLOCKS_LOG2_CONST_H + +#include <blocks/api.h> +#include <assert.h> + +namespace gr { + namespace blocks { + + template<unsigned int k> static inline int log2_const() { assert(0); return 0; } + + template<> inline int log2_const<1>() { return 0; } + template<> inline int log2_const<2>() { return 1; } + template<> inline int log2_const<4>() { return 2; } + template<> inline int log2_const<8>() { return 3; } + template<> inline int log2_const<16>() { return 4; } + template<> inline int log2_const<32>() { return 5; } + template<> inline int log2_const<64>() { return 6; } + template<> inline int log2_const<128>() { return 7; } + template<> inline int log2_const<256>() { return 8; } + template<> inline int log2_const<512>() { return 9; } + template<> inline int log2_const<1024>(){ return 10; } + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_LOG2_CONST_H */ diff --git a/gr-blocks/include/blocks/packed_to_unpacked_XX.h.t b/gr-blocks/include/blocks/packed_to_unpacked_XX.h.t new file mode 100644 index 000000000..9ab8b8bdf --- /dev/null +++ b/gr-blocks/include/blocks/packed_to_unpacked_XX.h.t @@ -0,0 +1,73 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2013 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 <blocks/api.h> +#include <gr_block.h> +#include <gr_endianness.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Convert a stream of packed bytes or shorts to stream of unpacked bytes or shorts. + * \ingroup converter_blk + * + * input: stream of @I_TYPE@; output: stream of @O_TYPE@ + * + * This is the inverse of gr::blocks::unpacked_to_packed_XX. + * + * The bits in the bytes or shorts input stream are grouped into + * chunks of \p bits_per_chunk bits and each resulting chunk is + * written right- justified to the output stream of bytes or + * shorts. All b or 16 bits of the each input bytes or short are + * processed. The right thing is done if bits_per_chunk is not a + * power of two. + * + * The combination of gr_packed_to_unpacked_XX_ followed by + * gr_chunks_to_symbols_Xf or gr_chunks_to_symbols_Xc handles the + * general case of mapping from a stream of bytes or shorts into + * arbitrary float or complex symbols. + * + * \sa gr::blocks::packed_to_unpacked_bb, gr::blocks::unpacked_to_packed_bb, + * \sa gr::blocks::packed_to_unpacked_ss, gr::blocks::unpacked_to_packed_ss, + * \sa gr::blocks::chunks_to_symbols_bf, gr::blocks::chunks_to_symbols_bc. + * \sa gr::blocks::chunks_to_symbols_sf, gr::blocks::chunks_to_symbols_sc. + */ + class BLOCKS_API @NAME@ : virtual public gr_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(unsigned int bits_per_chunk, + gr_endianness_t endianness); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/peak_detector2_fb.h b/gr-blocks/include/blocks/peak_detector2_fb.h new file mode 100644 index 000000000..71afc3287 --- /dev/null +++ b/gr-blocks/include/blocks/peak_detector2_fb.h @@ -0,0 +1,91 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_PEAK_DETECTOR2_FB_H +#define INCLUDED_GR_PEAK_DETECTOR2_FB_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \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. A separate debug output may be connected, to view the + * internal EWMA described below. + * + * \param threshold_factor_rise The threshold factor determins + * when a peak is present. An EWMA average of the signal is + * calculated and when the value of the signal goes over + * threshold_factor_rise*average, we call the peak. + * \param look_ahead The look-ahead value is used when the + * threshold is found to locate the peak within this range. + * \param alpha The gain value of a single-pole moving average filter. + */ + class BLOCKS_API peak_detector2_fb : virtual public gr_sync_block + { + public: + // gr::blocks::peak_detector2_fb::sptr + typedef boost::shared_ptr<peak_detector2_fb> sptr; + + static sptr make(float threshold_factor_rise=7, + int look_ahead=1000, float alpha=0.001); + + /*! \brief Set the threshold factor value for the rise time + * \param thr new threshold factor + */ + virtual void set_threshold_factor_rise(float thr) = 0; + + /*! \brief Set the look-ahead factor + * \param look new look-ahead factor + */ + virtual void set_look_ahead(int look) = 0; + + /*! \brief Set the running average alpha + * \param alpha new alpha for running average + */ + virtual void set_alpha(int alpha) = 0; + + /*! \brief Get the threshold factor value for the rise time + * \return threshold factor + */ + virtual float threshold_factor_rise() = 0; + + /*! \brief Get the look-ahead factor value + * \return look-ahead factor + */ + virtual int look_ahead() = 0; + + /*! \brief Get the alpha value of the running average + * \return alpha + */ + virtual float alpha() = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_PEAK_DETECTOR2_FB_H */ diff --git a/gr-blocks/include/blocks/regenerate_bb.h b/gr-blocks/include/blocks/regenerate_bb.h new file mode 100644 index 000000000..3063e70a7 --- /dev/null +++ b/gr-blocks/include/blocks/regenerate_bb.h @@ -0,0 +1,80 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_REGENERATE_BB_H +#define INCLUDED_GR_REGENERATE_BB_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Detect the peak of a signal and repeat every period samples + * \ingroup level_blk + * + * If a peak is detected, this block outputs a 1 repeated every + * period samples until reset by detection of another 1 on the + * input or stopped after max_regen regenerations have occurred. + * + * Note that if max_regen=(-1)/ULONG_MAX then the regeneration + * will run forever. + */ + class BLOCKS_API regenerate_bb : virtual public gr_sync_block + { + public: + // gr::blocks::regenerate_bb::sptr + typedef boost::shared_ptr<regenerate_bb> sptr; + + /*! + * \brief Make a regenerate block + * \param period The number of samples between regenerations + * \param max_regen The maximum number of regenerations to + * perform; if set to ULONG_MAX, it will regenerate + * continuously. + */ + static sptr make(int period, unsigned int max_regen=500); + + /*! \brief Reset the maximum regeneration count; this will reset + the current regen. + */ + virtual void set_max_regen(unsigned int regen) = 0; + + /*! \brief Reset the period of regenerations; this will reset + the current regen. + */ + virtual void set_period(int period) = 0; + + /*! \brief return the maximum regeneration count. + */ + virtual unsigned int max_regen() const = 0; + + /*! \brief return the regeneration period. + */ + virtual int period() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_REGENERATE_BB_H */ diff --git a/gr-blocks/include/blocks/rms_cf.h b/gr-blocks/include/blocks/rms_cf.h new file mode 100644 index 000000000..e73be6923 --- /dev/null +++ b/gr-blocks/include/blocks/rms_cf.h @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2013 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_BLOCKS_RMS_CF_H +#define INCLUDED_BLOCKS_RMS_CF_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief RMS average power + * \ingroup math_blk + */ + class BLOCKS_API rms_cf : virtual public gr_sync_block + { + public: + // gr::blocks::rms_cf::sptr + typedef boost::shared_ptr<rms_cf> sptr; + + /*! + * \brief Make an RMS calc. block. + * \param alpha gain for running average filter. + */ + static sptr make(double alpha = 0.0001); + + virtual void set_alpha(double alpha) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_RMS_CF_H */ diff --git a/gr-blocks/include/blocks/rms_ff.h b/gr-blocks/include/blocks/rms_ff.h new file mode 100644 index 000000000..19fb0016d --- /dev/null +++ b/gr-blocks/include/blocks/rms_ff.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2013 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_BLOCKS_RMS_FF_H +#define INCLUDED_BLOCKS_RMS_FF_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief RMS average power + * \ingroup math_blk + */ + class BLOCKS_API rms_ff : virtual public gr_sync_block + { + public: + // gr::blocks::rms_ff::sptr + typedef boost::shared_ptr<rms_ff> sptr; + + /*! + * \brief Make an RMS calc. block. + * \param alpha gain for running average filter. + */ + static sptr make(double alpha = 0.0001); + + virtual void set_alpha(double alpha) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_RMS_FF_H */ diff --git a/gr-blocks/include/blocks/stretch_ff.h b/gr-blocks/include/blocks/stretch_ff.h new file mode 100644 index 000000000..5f98452a4 --- /dev/null +++ b/gr-blocks/include/blocks/stretch_ff.h @@ -0,0 +1,59 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_STRETCH_FF_H +#define INCLUDED_GR_STRETCH_FF_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief adjust y-range of an input vector by mapping to range + * (max-of-input, stipulated-min). Primarily for spectral + * signature matching by normalizing spectrum dynamic ranges. + * \ingroup misc_blk + */ + class BLOCKS_API stretch_ff : virtual public gr_sync_block + { + public: + // gr::blocks::stretch_ff::sptr + typedef boost::shared_ptr<stretch_ff> sptr; + + /*! + * \brief Make a stretch block. + * \param lo Set low value for range. + * \param vlen vector length of input stream. + */ + static sptr make(float lo, size_t vlen=1); + + virtual float lo() const = 0; + virtual void set_lo(float lo) = 0; + virtual size_t vlen() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_STRETCH_FF_H */ diff --git a/gr-blocks/include/blocks/threshold_ff.h b/gr-blocks/include/blocks/threshold_ff.h new file mode 100644 index 000000000..900e5c5bd --- /dev/null +++ b/gr-blocks/include/blocks/threshold_ff.h @@ -0,0 +1,66 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_THRESHOLD_FF_H +#define INCLUDED_GR_THRESHOLD_FF_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Output a 1 or zero based on a threshold value. + * \ingroup misc_blk + * + * Test the incoming signal against a threshold. If the signal + * excedes the \p hi value, it will output a 1 until the signal + * falls below the \p lo value. + */ + class BLOCKS_API threshold_ff : virtual public gr_sync_block + { + public: + // gr::blocks::threshold_ff::sptr + typedef boost::shared_ptr<threshold_ff> sptr; + + /* \brief Create a threadshold block. + * \param lo Threshold input signal needs to drop below to + * change state to 0. + * \param hi Threshold input signal needs to rise above to + * change state to 1. + * \param initial_state Initial state of the block (0 or 1). + */ + static sptr make(float lo, float hi, float initial_state=0); + + virtual float lo () const = 0; + virtual void set_lo (float lo) = 0; + virtual float hi () const = 0; + virtual void set_hi (float hi) = 0; + virtual float last_state () const = 0; + virtual void set_last_state (float last_state) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_THRESHOLD_FF_H */ diff --git a/gr-blocks/include/blocks/throttle.h b/gr-blocks/include/blocks/throttle.h new file mode 100644 index 000000000..20d8037e1 --- /dev/null +++ b/gr-blocks/include/blocks/throttle.h @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005-2011,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_THROTTLE_H +#define INCLUDED_GR_THROTTLE_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief throttle flow of samples such that the average rate does + * not exceed samples_per_sec. + * \ingroup misc_blk + * + * input: one stream of itemsize; output: one stream of itemsize + * + * N.B. this should only be used in GUI apps where there is no + * other rate limiting block. It is not intended nor effective at + * precisely controlling the rate of samples. That should be + * controlled by a source or sink tied to sample clock. E.g., a + * USRP or audio card. + */ + class BLOCKS_API throttle : virtual public gr_sync_block + { + public: + typedef boost::shared_ptr<throttle> sptr; + + static sptr make(size_t itemsize, double samples_per_sec); + + //! Sets the sample rate in samples per second. + virtual void set_sample_rate(double rate) = 0; + + //! Get the sample rate in samples per second. + virtual double sample_rate() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_THROTTLE_H */ diff --git a/gr-blocks/include/blocks/unpacked_to_packed_XX.h.t b/gr-blocks/include/blocks/unpacked_to_packed_XX.h.t new file mode 100644 index 000000000..749f0e00f --- /dev/null +++ b/gr-blocks/include/blocks/unpacked_to_packed_XX.h.t @@ -0,0 +1,72 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2013 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 <blocks/api.h> +#include <gr_block.h> +#include <gr_endianness.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Convert a stream of unpacked bytes or shorts into a stream of packed bytes or shorts. + * \ingroup converter_blk + * + * input: stream of @I_TYPE@; output: stream of @O_TYPE@ + * + * This is the inverse of gr::blocks::packed_to_unpacked_XX. + * + * The low \p bits_per_chunk bits are extracted from each input + * byte or short. These bits are then packed densely into the + * output bytes or shorts, such that all 8 or 16 bits of the + * output bytes or shorts are filled with valid input bits. The + * right thing is done if bits_per_chunk is not a power of two. + * + * The combination of gr_packed_to_unpacked_XX followed by + * gr_chunks_to_symbols_Xf or gr_chunks_to_symbols_Xc handles the + * general case of mapping from a stream of bytes or shorts into + * arbitrary float or complex symbols. + * + * \sa gr::blocks::packed_to_unpacked_bb, gr::blocks::unpacked_to_packed_bb, + * \sa gr::blocks::packed_to_unpacked_ss, gr::blocks::unpacked_to_packed_ss, + * \sa gr::blocks::chunks_to_symbols_bf, gr::blocks::chunks_to_symbols_bc. + * \sa gr::blocks::chunks_to_symbols_sf, gr::blocks::chunks_to_symbols_sc. + */ + class BLOCKS_API @NAME@ : virtual public gr_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(unsigned int bits_per_chunk, + gr_endianness_t endianness); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ |