gr_or_XX.i.t \
gr_not_XX.cc.t \
gr_not_XX.h.t \
- gr_not_XX.i.t
+ gr_not_XX.i.t \
+ gr_moving_average_XX.cc.t \
+ gr_moving_average_XX.h.t \
+ gr_moving_average_XX.i.t
include Makefile.gen
gr_max_ff.h \
gr_max_ii.h \
gr_max_ss.h \
+ gr_moving_average_cc.h \
+ gr_moving_average_ff.h \
+ gr_moving_average_ii.h \
+ gr_moving_average_ss.h \
gr_multiply_cc.h \
gr_multiply_const_cc.h \
gr_multiply_const_ff.h \
gr_max_ff.i \
gr_max_ii.i \
gr_max_ss.i \
+ gr_moving_average_cc.i \
+ gr_moving_average_ff.i \
+ gr_moving_average_ii.i \
+ gr_moving_average_ss.i \
gr_multiply_cc.i \
gr_multiply_const_cc.i \
gr_multiply_const_ff.i \
gr_max_ff.cc \
gr_max_ii.cc \
gr_max_ss.cc \
+ gr_moving_average_cc.cc \
+ gr_moving_average_ff.cc \
+ gr_moving_average_ii.cc \
+ gr_moving_average_ss.cc \
gr_multiply_cc.cc \
gr_multiply_const_cc.cc \
gr_multiply_const_ff.cc \
'gr_add_const_vXX',
'gr_multiply_const_vXX',
'gr_integrate_XX',
+ 'gr_moving_average_XX',
]
# other blocks
#include <gr_max_ff.h>
#include <gr_max_ii.h>
#include <gr_max_ss.h>
+#include <gr_moving_average_cc.h>
+#include <gr_moving_average_ff.h>
+#include <gr_moving_average_ii.h>
+#include <gr_moving_average_ss.h>
#include <gr_multiply_cc.h>
#include <gr_multiply_const_cc.h>
#include <gr_multiply_const_ff.h>
%include <gr_max_ff.i>
%include <gr_max_ii.i>
%include <gr_max_ss.i>
+%include <gr_moving_average_cc.i>
+%include <gr_moving_average_ff.i>
+%include <gr_moving_average_ii.i>
+%include <gr_moving_average_ss.i>
%include <gr_multiply_cc.i>
%include <gr_multiply_const_cc.i>
%include <gr_multiply_const_ff.i>
--- /dev/null
+/* -*- 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <@NAME@.h>
+#include <gr_io_signature.h>
+
+@SPTR_NAME@
+gr_make_@BASE_NAME@ (int length, @O_TYPE@ scale, int max_iter)
+{
+ return @SPTR_NAME@ (new @NAME@ (length, scale, max_iter));
+}
+
+@NAME@::@NAME@ (int length, @O_TYPE@ scale, int max_iter)
+ : gr_sync_block ("@BASE_NAME@",
+ gr_make_io_signature (1, 1, sizeof (@I_TYPE@)),
+ gr_make_io_signature (1, 1, sizeof (@O_TYPE@))),
+ d_length(length),
+ d_scale(scale),
+ d_max_iter(max_iter)
+{
+ set_history(length);
+}
+
+@NAME@::~@NAME@ ()
+{
+}
+
+int
+@NAME@::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0];
+ @O_TYPE@ *out = (@O_TYPE@ *) output_items[0];
+
+ @I_TYPE@ sum = 0;
+ int num_iter = (noutput_items>d_max_iter) ? d_max_iter : noutput_items;
+ for (int i = 0; i < d_length-1 ; i++) {
+ sum += in[i];
+ }
+
+ for (int i = 0; i < num_iter; i++) {
+ sum += in[i+d_length-1];
+ out[i] = sum * d_scale;
+ sum -= in[i];
+ }
+
+ return num_iter;
+}
--- /dev/null
+/* -*- 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <gr_sync_block.h>
+
+class @NAME@;
+
+typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
+
+@SPTR_NAME@ gr_make_@BASE_NAME@ (int length, @O_TYPE@ scale, int max_iter = 4096);
+
+/*!
+ * \brief output is the moving sum of the last N samples, scaled by the scale factor
+ * \ingroup filter. max_iter limits how long we go without flushing the accumulator
+ * This is necessary to avoid numerical instability for float and complex.
+ *
+ */
+class @NAME@ : public gr_sync_block
+{
+private:
+ friend @SPTR_NAME@ gr_make_@BASE_NAME@(int length, @O_TYPE@ scale, int max_iter);
+
+ @NAME@ (int length, @O_TYPE@ scale, int max_iter = 4096);
+
+ int d_length;
+ @O_TYPE@ d_scale;
+ int d_max_iter;
+
+public:
+ ~@NAME@ ();
+
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* @GUARD_NAME@ */
--- /dev/null
+/* -*- 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.
+ */
+
+// @WARNING@
+
+GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@);
+
+@SPTR_NAME@ gr_make_@BASE_NAME@ (int length, @O_TYPE@ scale, int max_iter=4096);
+
+class @NAME@ : public gr_sync_block
+{
+private:
+ @NAME@ ();
+};