summaryrefslogtreecommitdiff
path: root/gr-blocks/include/blocks
diff options
context:
space:
mode:
authorTom Rondeau2013-02-24 18:55:04 -0500
committerTom Rondeau2013-02-24 18:55:04 -0500
commita54dc5bab6cc38513e9732be9f5c2670145b160f (patch)
tree50c711e17105a00f16486e51fd41d1e3b7786d8d /gr-blocks/include/blocks
parentffcaa3436cc8e608cb51bad78ca669b90bd110f2 (diff)
downloadgnuradio-a54dc5bab6cc38513e9732be9f5c2670145b160f.tar.gz
gnuradio-a54dc5bab6cc38513e9732be9f5c2670145b160f.tar.bz2
gnuradio-a54dc5bab6cc38513e9732be9f5c2670145b160f.zip
blocks: adding threshold, strech, and throttle to gr-blocks.
Diffstat (limited to 'gr-blocks/include/blocks')
-rw-r--r--gr-blocks/include/blocks/CMakeLists.txt3
-rw-r--r--gr-blocks/include/blocks/stretch_ff.h59
-rw-r--r--gr-blocks/include/blocks/threshold_ff.h66
-rw-r--r--gr-blocks/include/blocks/throttle.h62
4 files changed, 190 insertions, 0 deletions
diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt
index cd2fea672..8d5fe9b13 100644
--- a/gr-blocks/include/blocks/CMakeLists.txt
+++ b/gr-blocks/include/blocks/CMakeLists.txt
@@ -138,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/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 */