commit-gnuradio
[Top][All Lists]
Advanced

[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: Sat, 01 Jul 2006 10:33:55 +0000

CVSROOT:        /sources/gnuradio
Module name:    gnuradio-core
Changes by:     Johnathan Corgan <jcorgan>      06/07/01 10:33:55

Modified files:
        src/lib/general: Makefile.am general.i 
Added files:
        src/lib/general: gr_ctcss_squelch_ff.cc gr_ctcss_squelch_ff.h 
                         gr_ctcss_squelch_ff.i 

Log message:
        Added work in progress gr_ctcss_squelch_ff signal processing block.
        
        NOTE: Minimal testing, but is working with generated signals.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/general/Makefile.am?cvsroot=gnuradio&r1=1.108&r2=1.109
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/general/general.i?cvsroot=gnuradio&r1=1.74&r2=1.75
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.cc?cvsroot=gnuradio&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.h?cvsroot=gnuradio&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.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.108
retrieving revision 1.109
diff -u -b -r1.108 -r1.109
--- Makefile.am 1 Jul 2006 01:38:28 -0000       1.108
+++ Makefile.am 1 Jul 2006 10:33:54 -0000       1.109
@@ -126,6 +126,7 @@
        gr_costas_loop_cc.cc            \
        gr_count_bits.cc                \
        gr_crc32.cc                     \
+       gr_ctcss_squelch_ff.cc          \
        gr_dd_mpsk_sync_cc.cc           \
        gr_deinterleave.cc              \
        gr_diff_decoder_bb.cc           \
@@ -243,6 +244,7 @@
        gr_costas_loop_cc.h             \
        gr_count_bits.h                 \
        gr_crc32.h                      \
+       gr_ctcss_squelch_ff.h           \
        gr_dd_mpsk_sync_cc.h            \
        gr_diff_decoder_bb.h            \
        gr_diff_encoder_bb.h            \
@@ -375,6 +377,7 @@
        gr_correlate_access_code_bb.i   \
        gr_costas_loop_cc.i             \
        gr_crc32.i                      \
+       gr_ctcss_squelch_ff.i           \
        gr_dd_mpsk_sync_cc.i            \
        gr_diff_decoder_bb.i            \
        gr_diff_encoder_bb.i            \

Index: general.i
===================================================================
RCS file: /sources/gnuradio/gnuradio-core/src/lib/general/general.i,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -b -r1.74 -r1.75
--- general.i   18 Jun 2006 19:20:00 -0000      1.74
+++ general.i   1 Jul 2006 10:33:54 -0000       1.75
@@ -108,7 +108,7 @@
 #include <gr_feval.h>
 #include <gr_pwr_squelch_cc.h>
 #include <gr_pwr_squelch_ff.h>
-
+#include <gr_ctcss_squelch_ff.h>
 %}
 
 %include "gr_sync_block.i"
@@ -198,5 +198,6 @@
 %include "gr_feval.i"
 %include "gr_pwr_squelch_cc.i"
 %include "gr_pwr_squelch_ff.i"
+%include "gr_ctcss_squelch_ff.i"
 
 %include "general_generated.i"

Index: gr_ctcss_squelch_ff.cc
===================================================================
RCS file: gr_ctcss_squelch_ff.cc
diff -N gr_ctcss_squelch_ff.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gr_ctcss_squelch_ff.cc      1 Jul 2006 10:33:54 -0000       1.1
@@ -0,0 +1,111 @@
+/* -*- 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 <gr_ctcss_squelch_ff.h>
+
+static float ctcss_tones[] = {
+   67.0,  71.9,  74.4,  77.0,  79.7,  82.5,  85.4,  88.5,  91.5,  94.8, 
+   97.4, 100.0, 103.5, 107.2, 110.9, 114.8, 118.8, 123.0, 127.3, 131.8,
+  136.5, 141.3, 146.2, 151.4, 156.7, 162.2, 167.9, 173.8, 179.9, 186.2, 
+  192.8, 203.5, 210.7, 218.1, 225.7, 233.6, 241.8, 250.3
+};
+
+static int max_tone_index = 37;
+
+gr_ctcss_squelch_ff_sptr
+gr_make_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, 
bool gate)
+{
+  return gr_ctcss_squelch_ff_sptr(new gr_ctcss_squelch_ff(rate, freq, level, 
len, ramp, gate));
+}
+
+int gr_ctcss_squelch_ff::find_tone(float freq)
+{
+  for (int i = 0; i <= max_tone_index; i++)
+    if (ctcss_tones[i] == freq) // FIXME: make almost equal
+      return i;
+
+  return -1;
+}
+
+gr_ctcss_squelch_ff::gr_ctcss_squelch_ff(int rate, float freq, float level, 
int len, int ramp, bool gate) : 
+    gr_squelch_base_ff("ctcss_squelch_ff", ramp, gate)
+{
+  d_freq = freq;
+  d_level = level;
+
+  // Default is 125 ms detection time
+  if (len == 0)
+    d_len = (int)(rate/8);
+  else
+    d_len = len;
+
+  int i = find_tone(freq);
+
+  // Non-standard tones or edge tones get 2% guard band, otherwise
+  // guards are set at adjacent ctcss tone frequencies
+  float f_l, f_r;
+  if (i == -1 || i == 0)
+    f_l = freq*0.98;
+  else
+    f_l = ctcss_tones[i-1];
+    
+  if (i == -1 || i == max_tone_index)
+    f_r = freq*1.02;
+  else
+    f_r = ctcss_tones[i+1];
+
+  d_goertzel_l = gri_goertzel(rate, d_len, f_l);
+  d_goertzel_c = gri_goertzel(rate, d_len, freq);
+  d_goertzel_r = gri_goertzel(rate, d_len, f_r);
+
+  d_mute = true;
+}
+
+std::vector<float> gr_ctcss_squelch_ff::squelch_range() const
+{
+  std::vector<float> r(3);
+  r[0] = 0.0;
+  r[1] = 1.0;
+  r[2] = (r[1]-r[0])/100; // step size
+
+  return r;
+}
+
+void gr_ctcss_squelch_ff::update_state(const float &in)
+{
+  d_goertzel_l.input(in);
+  d_goertzel_c.input(in);
+  d_goertzel_r.input(in);
+
+  float d_out_l, d_out_c, d_out_r;
+  if (d_goertzel_c.ready()) {
+      d_out_l = abs(d_goertzel_l.output());
+      d_out_c = abs(d_goertzel_c.output());
+      d_out_r = abs(d_goertzel_r.output());
+  
+      d_mute = (d_out_c < d_level || d_out_c < d_out_l || d_out_c < d_out_r);
+  }
+}

Index: gr_ctcss_squelch_ff.h
===================================================================
RCS file: gr_ctcss_squelch_ff.h
diff -N gr_ctcss_squelch_ff.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gr_ctcss_squelch_ff.h       1 Jul 2006 10:33:54 -0000       1.1
@@ -0,0 +1,67 @@
+/* -*- 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_CTCSS_SQUELCH_FF_H
+#define INCLUDED_GR_CTCSS_SQUELCH_FF_H
+
+#include <gr_squelch_base_ff.h>
+#include <gri_goertzel.h>
+
+class gr_ctcss_squelch_ff;
+typedef boost::shared_ptr<gr_ctcss_squelch_ff> gr_ctcss_squelch_ff_sptr;
+
+gr_ctcss_squelch_ff_sptr 
+gr_make_ctcss_squelch_ff(int rate, float freq, float level=0.04, int len=0, 
int ramp=0, bool gate=false);
+
+/*!
+ * \brief gate or zero output if ctcss tone not present
+ * \ingroup block
+ */
+class gr_ctcss_squelch_ff : public gr_squelch_base_ff
+{
+private:
+  float d_freq;
+  float d_level;
+  int   d_len;
+  bool  d_mute;
+     
+  gri_goertzel d_goertzel_l;
+  gri_goertzel d_goertzel_c;
+  gri_goertzel d_goertzel_r;
+
+  friend gr_ctcss_squelch_ff_sptr gr_make_ctcss_squelch_ff(int rate, float 
freq, float level, int len, int ramp, bool gate);
+  gr_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, 
bool gate);
+
+  int find_tone(float freq);
+
+protected:
+  virtual void update_state(const float &in);
+  virtual bool mute() const { return d_mute; }
+  
+public:
+  std::vector<float> squelch_range() const;
+  float level() const { return d_level; }
+  void set_level(float level) { d_level = level; }
+  int len() const { return d_len; }
+};
+
+#endif /* INCLUDED_GR_CTCSS_SQUELCH_FF_H */

Index: gr_ctcss_squelch_ff.i
===================================================================
RCS file: gr_ctcss_squelch_ff.i
diff -N gr_ctcss_squelch_ff.i
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ gr_ctcss_squelch_ff.i       1 Jul 2006 10:33:54 -0000       1.1
@@ -0,0 +1,39 @@
+/* -*- 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,ctcss_squelch_ff);
+
+%include gr_squelch_base_ff.i
+
+gr_ctcss_squelch_ff_sptr 
+gr_make_ctcss_squelch_ff(int rate, float freq, float level=0.04, int len=0, 
int ramp=0, bool gate=false);
+
+class gr_ctcss_squelch_ff : public gr_squelch_base_ff
+{
+  gr_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, 
bool gate);
+
+public:
+  std::vector<float> squelch_range() const;
+  float level() const { return d_level; }
+  void set_level(float level) { d_level = level; }
+  int len() const { return d_len; }
+};




reply via email to

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