commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r8186 - in gnuradio/trunk/gnuradio-core/src: lib/gener


From: jcorgan
Subject: [Commit-gnuradio] r8186 - in gnuradio/trunk/gnuradio-core/src: lib/general python/gnuradio/gr
Date: Fri, 11 Apr 2008 15:31:26 -0600 (MDT)

Author: jcorgan
Date: 2008-04-11 15:31:25 -0600 (Fri, 11 Apr 2008)
New Revision: 8186

Added:
   gnuradio/trunk/gnuradio-core/src/lib/general/gr_repeat.cc
   gnuradio/trunk/gnuradio-core/src/lib/general/gr_repeat.h
   gnuradio/trunk/gnuradio-core/src/lib/general/gr_repeat.i
   gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_repeat.py
Modified:
   gnuradio/trunk/gnuradio-core/src/lib/general/Makefile.am
   gnuradio/trunk/gnuradio-core/src/lib/general/general.i
Log:
Adds gr.repeat(), an interpolating block to repeat a sample N times on the 
output.

Modified: gnuradio/trunk/gnuradio-core/src/lib/general/Makefile.am
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/general/Makefile.am    2008-04-11 
19:47:54 UTC (rev 8185)
+++ gnuradio/trunk/gnuradio-core/src/lib/general/Makefile.am    2008-04-11 
21:31:25 UTC (rev 8186)
@@ -127,6 +127,7 @@
        gr_random.cc                    \
        gr_regenerate_bb.cc             \
        gr_remez.cc                     \
+       gr_repeat.cc                    \
        gr_reverse.cc                   \
        gr_rms_cf.cc                    \
        gr_rms_ff.cc                    \
@@ -272,6 +273,7 @@
        gr_random.h                     \
        gr_regenerate_bb.h              \
        gr_remez.h                      \
+       gr_repeat.h                     \
        gr_reverse.h                    \
        gr_rms_cf.h                     \
        gr_rms_ff.h                     \
@@ -419,6 +421,7 @@
        gr_remez.i                      \
        gr_rms_cf.i                     \
        gr_rms_ff.i                     \
+       gr_repeat.i                     \
        gr_short_to_float.i             \
        gr_simple_correlator.i          \
        gr_simple_framer.i              \

Modified: gnuradio/trunk/gnuradio-core/src/lib/general/general.i
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/general/general.i      2008-04-11 
19:47:54 UTC (rev 8185)
+++ gnuradio/trunk/gnuradio-core/src/lib/general/general.i      2008-04-11 
21:31:25 UTC (rev 8186)
@@ -129,6 +129,7 @@
 #include <gr_glfsr_source_b.h>
 #include <gr_glfsr_source_f.h>
 #include <gr_peak_detector2_fb.h>
+#include <gr_repeat.h>
 %}
 
 %include "gr_nop.i"
@@ -238,3 +239,4 @@
 %include "gr_glfsr_source_b.i"
 %include "gr_glfsr_source_f.i"
 %include "gr_peak_detector2_fb.i"
+%include "gr_repeat.i"

Added: gnuradio/trunk/gnuradio-core/src/lib/general/gr_repeat.cc
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/general/gr_repeat.cc                   
        (rev 0)
+++ gnuradio/trunk/gnuradio-core/src/lib/general/gr_repeat.cc   2008-04-11 
21:31:25 UTC (rev 8186)
@@ -0,0 +1,68 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_repeat.h>
+#include <gr_io_signature.h>
+
+gr_repeat_sptr 
+gr_make_repeat(size_t itemsize, int interp)
+{
+  return gr_repeat_sptr(new gr_repeat(itemsize, interp));
+}
+
+gr_repeat::gr_repeat(size_t itemsize, int interp)  
+  : gr_sync_interpolator("extend",
+                        gr_make_io_signature(1, 1, itemsize),
+                        gr_make_io_signature(1, 1, itemsize),
+                        interp),
+    d_interp(interp),
+    d_itemsize(itemsize)
+{
+}
+
+gr_repeat::~gr_repeat()
+{
+}
+
+int 
+gr_repeat::work(int noutput_items,
+                 gr_vector_const_void_star &input_items,
+                 gr_vector_void_star &output_items)
+{
+  const char *in = (const char *) input_items[0];
+  char *out = (char *)output_items[0];
+
+  for (int i = 0; i < noutput_items/d_interp; i++) {
+    for (int j = 0; j < d_interp; j++) {
+      memcpy(out, in, d_itemsize);
+      out += d_itemsize;
+    }
+
+    i += d_itemsize;
+  }
+
+  return noutput_items;
+}

Added: gnuradio/trunk/gnuradio-core/src/lib/general/gr_repeat.h
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/general/gr_repeat.h                    
        (rev 0)
+++ gnuradio/trunk/gnuradio-core/src/lib/general/gr_repeat.h    2008-04-11 
21:31:25 UTC (rev 8186)
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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_REPEAT_H
+#define INCLUDED_GR_REPEAT_H
+
+#include <gr_sync_interpolator.h>
+
+class gr_repeat;
+
+typedef boost::shared_ptr<gr_repeat> gr_repeat_sptr;
+
+gr_repeat_sptr gr_make_repeat(size_t itemsize, int decim);
+
+/*!
+ * \brief Repeat a sample 'interp' times in output stream
+ * \ingroup converter
+ */
+
+class gr_repeat : public gr_sync_interpolator
+{
+private:
+  friend gr_repeat_sptr gr_make_repeat(size_t itemsize, int interp);
+                                                    
+  gr_repeat(size_t itemsize, int interp);
+
+  int d_interp;
+  int d_itemsize;
+
+ public:
+  ~gr_repeat();
+
+  int work(int noutput_items,
+          gr_vector_const_void_star &input_items,
+          gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_GR_REPEAT_H */

Added: gnuradio/trunk/gnuradio-core/src/lib/general/gr_repeat.i
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/general/gr_repeat.i                    
        (rev 0)
+++ gnuradio/trunk/gnuradio-core/src/lib/general/gr_repeat.i    2008-04-11 
21:31:25 UTC (rev 8186)
@@ -0,0 +1,11 @@
+/* -*- c++ -*- */
+
+GR_SWIG_BLOCK_MAGIC(gr,repeat);
+
+gr_repeat_sptr gr_make_repeat(size_t itemsize, int interp);
+
+class gr_repeat : public gr_sync_interpolator
+{
+private:
+  gr_repeat();
+};

Added: gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_repeat.py
===================================================================
--- gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_repeat.py            
                (rev 0)
+++ gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_repeat.py    
2008-04-11 21:31:25 UTC (rev 8186)
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 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.
+# 
+
+from gnuradio import gr, gr_unittest
+import math
+
+class test_repeat (gr_unittest.TestCase):
+
+    def setUp (self):
+        self.tb = gr.top_block ()
+
+    def tearDown (self):
+        self.tb = None
+
+    def test_001_float(self):
+       src_data = [1.0, 2.0, 3.0]
+       dst_data = [1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0]
+       src = gr.vector_source_f(src_data)
+       rpt = gr.repeat(gr.sizeof_float, 3)
+       dst = gr.vector_sink_f()
+       self.tb.connect(src, rpt, dst)
+       self.tb.run()
+       self.assertFloatTuplesAlmostEqual(dst_data, dst.data(), 6)      
+
+if __name__ == '__main__':
+    gr_unittest.main ()


Property changes on: 
gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_repeat.py
___________________________________________________________________
Name: svn:executable
   + *





reply via email to

[Prev in Thread] Current Thread [Next in Thread]