[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] gnuradio-core/src/lib/general Makefile.am gener...
From: |
Johnathan Corgan |
Subject: |
[Commit-gnuradio] gnuradio-core/src/lib/general Makefile.am gener... |
Date: |
Sun, 18 Jun 2006 06:52:46 +0000 |
CVSROOT: /sources/gnuradio
Module name: gnuradio-core
Changes by: Johnathan Corgan <jcorgan> 06/06/18 06:52:46
Modified files:
src/lib/general: Makefile.am general.i generate_common.py
Added files:
src/lib/general: gr_pwr_squelch_cc.cc gr_pwr_squelch_cc.h
gr_pwr_squelch_cc.i
Log message:
Added gr_pwr_squelch_cc block.
No formal qa code yet, but informal testing shows basic functionality is
correct.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/general/Makefile.am?cvsroot=gnuradio&r1=1.104&r2=1.105
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/general/general.i?cvsroot=gnuradio&r1=1.72&r2=1.73
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/general/generate_common.py?cvsroot=gnuradio&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.cc?cvsroot=gnuradio&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.h?cvsroot=gnuradio&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.i?cvsroot=gnuradio&rev=1.1
Patches:
Index: Makefile.am
===================================================================
RCS file: /sources/gnuradio/gnuradio-core/src/lib/general/Makefile.am,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -b -r1.104 -r1.105
--- Makefile.am 8 Jun 2006 22:03:54 -0000 1.104
+++ Makefile.am 18 Jun 2006 06:52:46 -0000 1.105
@@ -170,6 +170,7 @@
gr_probe_avg_mag_sqrd_c.cc \
gr_probe_avg_mag_sqrd_f.cc \
gr_probe_signal_f.cc \
+ gr_pwr_squelch_cc.cc \
gr_quadrature_demod_cf.cc \
gr_random.cc \
gr_remez.cc \
@@ -289,6 +290,7 @@
gr_probe_avg_mag_sqrd_c.h \
gr_probe_avg_mag_sqrd_f.h \
gr_probe_signal_f.h \
+ gr_pwr_squelch_cc.h \
gr_quadrature_demod_cf.h \
gr_random.h \
gr_remez.h \
@@ -408,6 +410,7 @@
gr_probe_avg_mag_sqrd_c.i \
gr_probe_avg_mag_sqrd_f.i \
gr_probe_signal_f.i \
+ gr_pwr_squelch_cc.i \
gr_quadrature_demod_cf.i \
gr_remez.i \
gr_rms_cf.i \
Index: general.i
===================================================================
RCS file: /sources/gnuradio/gnuradio-core/src/lib/general/general.i,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -b -r1.72 -r1.73
--- general.i 8 Jun 2006 22:03:54 -0000 1.72
+++ general.i 18 Jun 2006 06:52:46 -0000 1.73
@@ -106,6 +106,7 @@
#include <gr_framer_sink_1.h>
#include <gr_map_bb.h>
#include <gr_feval.h>
+#include <gr_pwr_squelch_cc.h>
%}
@@ -194,5 +195,6 @@
%include "gr_framer_sink_1.i"
%include "gr_map_bb.i"
%include "gr_feval.i"
+%include "gr_pwr_squelch_cc.i"
%include "general_generated.i"
Index: generate_common.py
===================================================================
RCS file: /sources/gnuradio/gnuradio-core/src/lib/general/generate_common.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- generate_common.py 16 Jun 2006 05:44:37 -0000 1.12
+++ generate_common.py 18 Jun 2006 06:52:46 -0000 1.13
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2004 Free Software Foundation, Inc.
+# Copyright 2004,2006 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
Index: gr_pwr_squelch_cc.cc
===================================================================
RCS file: gr_pwr_squelch_cc.cc
diff -N gr_pwr_squelch_cc.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gr_pwr_squelch_cc.cc 18 Jun 2006 06:52:46 -0000 1.1
@@ -0,0 +1,156 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <cmath>
+#include <cstdio>
+#include <gr_pwr_squelch_cc.h>
+#include <gr_io_signature.h>
+
+gr_pwr_squelch_cc_sptr
+gr_make_pwr_squelch_cc(double threshold, double alpha, int ramp, bool gate)
+{
+ return gr_pwr_squelch_cc_sptr(new gr_pwr_squelch_cc(threshold, alpha, ramp,
gate));
+}
+
+gr_pwr_squelch_cc::gr_pwr_squelch_cc(double threshold, double alpha, int ramp,
bool gate) :
+ gr_block("pwr_squelch_cc",
+ gr_make_io_signature (1, 1, sizeof(gr_complex)),
+ gr_make_io_signature (1, 1, sizeof(gr_complex))),
+ d_iir(alpha)
+{
+ set_threshold(threshold);
+ set_ramp(ramp);
+ set_gate(gate);
+ d_state = ST_MUTED;
+ d_envelope = d_ramp ? 0.0 : 1.0;
+ d_ramped = 0;
+}
+
+gr_pwr_squelch_cc::~gr_pwr_squelch_cc()
+{
+}
+
+double gr_pwr_squelch_cc::threshold() const
+{
+ return 10*log10(d_threshold);
+}
+
+void gr_pwr_squelch_cc::set_threshold(double db)
+{
+ d_threshold = std::pow(10.0, db/10);
+}
+
+void gr_pwr_squelch_cc::set_alpha(double alpha)
+{
+ d_iir.set_taps(alpha);
+}
+
+void gr_pwr_squelch_cc::set_gate(bool gate)
+{
+ d_gate = gate;
+}
+
+void gr_pwr_squelch_cc::set_ramp(int ramp)
+{
+ d_ramp = ramp;
+}
+
+bool gr_pwr_squelch_cc::unmuted() const
+{
+ return (d_state == ST_UNMUTED || d_state == ST_ATTACK);
+}
+
+std::vector<float> gr_pwr_squelch_cc::squelch_range() const
+{
+ std::vector<float> r(3);
+ r[0] = -50.0; // min FIXME
+ r[1] = +50.0; // max FIXME
+ r[2] = (r[1] - r[0]) / 100; // step size
+
+ return r;
+}
+
+int gr_pwr_squelch_cc::general_work(int noutput_items,
+ gr_vector_int &ninput_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 j = 0;
+
+ for (int i = 0; i < noutput_items; i++) {
+ // Calculate average power
+ double mag_sqrd = in[i].real()*in[i].real() + in[i].imag()*in[i].imag();
+ double f = d_iir.filter(mag_sqrd);
+
+ // Update squelch state based on power vs. threshold
+ switch(d_state) {
+ case ST_MUTED:
+ if (f >= d_threshold) {
+ putchar('A');
+ d_state = d_ramp ? ST_ATTACK : ST_UNMUTED; // If not ramping, go
straight to unmuted
+ }
+ break;
+
+ case ST_UNMUTED:
+ if (f < d_threshold) {
+ putchar('D');
+ d_state = d_ramp ? ST_DECAY : ST_MUTED; // If not ramping, go
straight to muted
+ }
+ break;
+
+ case ST_ATTACK:
+ d_envelope = 0.5-std::cos(M_PI*(++d_ramped)/d_ramp)/2.0; // FIXME:
precalculate window for speed
+ if (d_ramped >= d_ramp) { // use >= in case d_ramp
is set to lower value elsewhere
+ putchar('a');
+ d_state = ST_UNMUTED;
+ d_envelope = 1.0;
+ }
+ break;
+
+ case ST_DECAY:
+ d_envelope = 0.5-std::cos(M_PI*(d_ramp-(--d_ramped))/d_ramp)/2.0; //
FIXME: precalculate window for speed
+ if (d_ramped == 0) {
+ d_state = ST_MUTED;
+ putchar('d');
+ }
+ break;
+ };
+
+ // If unmuted, copy input times envelope to output
+ // Otherwise, if not gating, copy zero to output
+ if (d_state != ST_MUTED)
+ out[j++] = in[i]*gr_complex(d_envelope, 0.0);
+ else
+ if (!d_gate)
+ out[j++] = 0.0;
+ }
+
+ consume_each(noutput_items); // Use all the inputs
+ return j; // But only report outputs copied
+}
Index: gr_pwr_squelch_cc.h
===================================================================
RCS file: gr_pwr_squelch_cc.h
diff -N gr_pwr_squelch_cc.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gr_pwr_squelch_cc.h 18 Jun 2006 06:52:46 -0000 1.1
@@ -0,0 +1,78 @@
+/* -*- 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef INCLUDED_GR_PWR_SQUELCH_CC_H
+#define INCLUDED_GR_PWR_SQUELCH_CC_H
+
+#include <gr_block.h>
+#include <gr_single_pole_iir.h>
+
+class gr_pwr_squelch_cc;
+typedef boost::shared_ptr<gr_pwr_squelch_cc> gr_pwr_squelch_cc_sptr;
+
+gr_pwr_squelch_cc_sptr gr_make_pwr_squelch_cc(double db, double alpha =
0.0001, int ramp=0, bool gate=false);
+
+/*!
+ * \brief gate or zero output when input power below threshold
+ * \ingroup block
+ */
+class gr_pwr_squelch_cc : public gr_block
+{
+ enum state_t { ST_MUTED, ST_ATTACK, ST_UNMUTED, ST_DECAY };
+
+ double d_threshold;
+ int d_ramp;
+ bool d_gate;
+
+ gr_single_pole_iir<double,double,double> d_iir;
+ state_t d_state;
+ int d_ramped;
+ double d_envelope;
+
+ friend gr_pwr_squelch_cc_sptr gr_make_pwr_squelch_cc(double db, double
alpha, int ramp, bool gate);
+ gr_pwr_squelch_cc(double db, double alpha, int ramp, bool gate);
+
+ public:
+ ~gr_pwr_squelch_cc();
+
+ double threshold() const;
+ void set_threshold(double db);
+
+ void set_alpha(double alpha);
+
+ int ramp() const { return d_ramp; }
+ void set_ramp(int ramp);
+
+ bool gate() const { return d_gate; }
+ void set_gate(bool gate);
+
+ bool unmuted() const;
+
+ std::vector<float> squelch_range() const;
+
+ int general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_GR_PWR_SQUELCH_CC_H */
Index: gr_pwr_squelch_cc.i
===================================================================
RCS file: gr_pwr_squelch_cc.i
diff -N gr_pwr_squelch_cc.i
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gr_pwr_squelch_cc.i 18 Jun 2006 06:52:46 -0000 1.1
@@ -0,0 +1,47 @@
+/* -*- 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,pwr_squelch_cc);
+
+gr_pwr_squelch_cc_sptr gr_make_pwr_squelch_cc(double db, double alpha=0.0001,
int ramp=0, bool gate=false);
+
+class gr_pwr_squelch_cc : public gr_block
+{
+ private:
+ gr_pwr_squelch_cc(double db, double alpha, int ramp, bool gate);
+
+ public:
+ double threshold() const;
+ void set_threshold(double db);
+
+ void set_alpha(double alpha);
+
+ int ramp() const { return d_ramp; }
+ void set_ramp(int ramp);
+
+ bool gate() const { return d_gate; }
+ void set_gate(bool gate);
+
+ bool unmuted() const;
+
+ std::vector<float> squelch_range() const;
+};
- [Commit-gnuradio] gnuradio-core/src/lib/general Makefile.am gener...,
Johnathan Corgan <=