commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r3631 - gnuradio/branches/developers/eb/digital-wip/gn


From: eb
Subject: [Commit-gnuradio] r3631 - gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general
Date: Mon, 25 Sep 2006 01:07:52 -0600 (MDT)

Author: eb
Date: 2006-09-25 01:07:51 -0600 (Mon, 25 Sep 2006)
New Revision: 3631

Added:
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.cc
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.h
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.i
Modified:
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/Makefile.am
   
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/general.i
Log:
New feedforward AGC (untested)


Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/Makefile.am
       2006-09-24 23:43:03 UTC (rev 3630)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/Makefile.am
       2006-09-25 07:07:51 UTC (rev 3631)
@@ -122,6 +122,7 @@
        gr_diff_phasor_cc.cc            \
        gr_fake_channel_coder_pp.cc     \
        gr_fast_atan2f.cc               \
+       gr_feedforward_agc_cc.cc        \
        gr_feval.cc                     \
        gr_fft_vcc.cc                   \
        gr_fft_vfc.cc                   \
@@ -243,6 +244,7 @@
        gr_endianness.h                 \
        gr_expj.h                       \
        gr_fake_channel_coder_pp.h      \
+       gr_feedforward_agc_cc.h         \
        gr_feval.h                      \
        gr_fft_vcc.h                    \
        gr_fft_vfc.h                    \
@@ -379,6 +381,7 @@
        gr_deinterleave.i               \
        gr_endianness.i                 \
        gr_fake_channel_coder_pp.i      \
+       gr_feedforward_agc_cc.i         \
        gr_feval.i                      \
        gr_fft_vcc.i                    \
        gr_fft_vfc.i                    \

Modified: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/general.i
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/general.i
 2006-09-24 23:43:03 UTC (rev 3630)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/general.i
 2006-09-25 07:07:51 UTC (rev 3631)
@@ -111,6 +111,7 @@
 #include <gr_pwr_squelch_cc.h>
 #include <gr_pwr_squelch_ff.h>
 #include <gr_ctcss_squelch_ff.h>
+#include <gr_feedforward_agc_cc.h>
 %}
 
 %include "gr_sync_block.i"
@@ -203,5 +204,6 @@
 %include "gr_pwr_squelch_cc.i"
 %include "gr_pwr_squelch_ff.i"
 %include "gr_ctcss_squelch_ff.i"
+%include "gr_feedforward_agc_cc.i"
 
 %include "general_generated.i"

Added: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.cc
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.cc
                          (rev 0)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.cc
  2006-09-25 07:07:51 UTC (rev 3631)
@@ -0,0 +1,84 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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 2, 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_feedforward_agc_cc.h>
+#include <gr_io_signature.h>
+#include <stdexcept>
+
+gr_feedforward_agc_cc_sptr
+gr_make_feedforward_agc_cc(int nsamples, float reference)
+{
+  return gr_feedforward_agc_cc_sptr(new gr_feedforward_agc_cc (nsamples, 
reference));
+}
+
+gr_feedforward_agc_cc::gr_feedforward_agc_cc (int nsamples, float reference)
+  : gr_sync_block ("gr_feedforward_agc_cc",
+                  gr_make_io_signature (1, 1, sizeof (gr_complex)),
+                  gr_make_io_signature (1, 1, sizeof (gr_complex))),
+    d_nsamples(nsamples), d_reference(reference),
+    d_sum_squares(0)
+{
+  if (nsamples < 1)
+    throw std::invalid_argument("gr_feedforward_agc_cc: nsamples must be >= 
1");
+  
+  d_1_over_nsamples = 1.0 / nsamples;
+  set_history(nsamples);
+}
+
+gr_feedforward_agc_cc::~gr_feedforward_agc_cc()
+{
+}
+
+inline static float
+mag_squared(gr_complex x)
+{
+  return x.real() * x.real() + x.imag() * x.imag();
+}
+
+int
+gr_feedforward_agc_cc::work(int noutput_items,
+                           gr_vector_const_void_star &input_items,
+                           gr_vector_void_star &output_items)
+{
+  const gr_complex *in = (const gr_complex *) input_items[0];
+  gr_complex *out = (gr_complex *) output_items[0];
+  int  nsamples = d_nsamples;
+  float gain;
+  
+  for (int i = 0; i < noutput_items; i++){
+    if (d_sum_squares < 1e-24) // call it zero
+      gain = d_reference / sqrt(1e-24 * d_1_over_nsamples);
+    else
+      gain = d_reference / sqrt(d_sum_squares * d_1_over_nsamples);
+
+    out[i] = gain * in[i];
+
+    // now end-adjust our sum of squares
+    d_sum_squares -= mag_squared(in[i]);         // subtract off current value
+    d_sum_squares += mag_squared(in[i+nsamples]); // add in new one
+  }
+  return noutput_items;
+}

Added: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.h
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.h
                           (rev 0)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.h
   2006-09-25 07:07:51 UTC (rev 3631)
@@ -0,0 +1,57 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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 2, 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_FEEDFORWARD_AGC_CC_H
+#define INCLUDED_GR_FEEDFORWARD_AGC_CC_H
+
+#include <gr_sync_block.h>
+
+class gr_feedforward_agc_cc;
+typedef boost::shared_ptr<gr_feedforward_agc_cc> gr_feedforward_agc_cc_sptr;
+
+gr_feedforward_agc_cc_sptr
+gr_make_feedforward_agc_cc(int nsamples, float reference = 1.0);
+
+/*!
+ * \brief Non-causal AGC which computes required gain based on RMS over 
nsamples
+ */
+class gr_feedforward_agc_cc : public gr_sync_block
+{
+  friend gr_feedforward_agc_cc_sptr 
+  gr_make_feedforward_agc_cc(int nsamples, float reference);
+  
+  int          d_nsamples;
+  float                d_reference;
+  float                d_sum_squares;
+  float                d_1_over_nsamples;
+
+  gr_feedforward_agc_cc(int nsamples, float reference);
+
+ public:
+  ~gr_feedforward_agc_cc();
+
+  int work(int noutput_items,
+          gr_vector_const_void_star &input_items,
+          gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_GR_FEEDFORWARD_AGC_CC_H */

Added: 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.i
===================================================================
--- 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.i
                           (rev 0)
+++ 
gnuradio/branches/developers/eb/digital-wip/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.i
   2006-09-25 07:07:51 UTC (rev 3631)
@@ -0,0 +1,34 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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 2, 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,feedforward_agc_cc);
+
+gr_feedforward_agc_cc_sptr
+gr_make_feedforward_agc_cc(int nsamples, float reference = 1.0);
+
+class gr_feedforward_agc_cc : public gr_sync_block
+{
+  gr_feedforward_agc_cc(int nsamples, float reference);
+  
+ public:
+  ~gr_feedforward_agc_cc();
+};





reply via email to

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