From 2e0412ff9b5fca3890bdd3c4d70a9bc9850e9611 Mon Sep 17 00:00:00 2001
From: leee <leee@users.noreply.github.com>
Date: Sun, 25 Apr 2021 01:46:53 -0400
Subject: [PATCH] Add low pass filter to analog recorder audio flow

---
 trunk-recorder/recorders/analog_recorder.cc | 12 +++++++++---
 trunk-recorder/recorders/analog_recorder.h  |  2 ++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/trunk-recorder/recorders/analog_recorder.cc b/trunk-recorder/recorders/analog_recorder.cc
index bdd8278a2..7af7b8108 100644
--- a/trunk-recorder/recorders/analog_recorder.cc
+++ b/trunk-recorder/recorders/analog_recorder.cc
@@ -135,7 +135,7 @@ analog_recorder::analog_recorder(Source *src)
   squelch_two = gr::analog::pwr_squelch_ff::make(-200, 0.01, 0, true);
 
   // k = quad_rate/(2*math.pi*max_dev) = 48k / (6.283185*5000) = 1.527
-  
+
   int d_max_dev = 5000;
   /* demodulator gain */
   quad_gain = system_channel_rate / (2.0 * M_PI * d_max_dev);
@@ -164,9 +164,14 @@ analog_recorder::analog_recorder(Source *src)
   decoder_sink = gr::blocks::decoder_wrapper_impl::make(wave_sample_rate, src->get_num(), std::bind(&analog_recorder::decoder_callback_handler, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
   BOOST_LOG_TRIVIAL(info) << "Decoder sink created!" << std::endl;
 
-  // Try and get rid of the FSK wobble
+  // Analog audio band pass from 300 to 3000 Hz
+  // can't use gnuradio.filter.firdes.band_pass since we have different transition widths
+  // 300 Hz high pass (275-325 Hz): removes CTCSS/DCS and Type II 150 bps Low Speed Data (LSD), or "FSK wobble"
   high_f_taps = gr::filter::firdes::high_pass(1, wave_sample_rate, 300, 50, gr::filter::firdes::WIN_HANN); // Configurable
   high_f = gr::filter::fir_filter_fff::make(1, high_f_taps);
+  // 3000 Hz low pass (3000-3500 Hz)
+  low_f_taps = gr::filter::firdes::low_pass(1, wave_sample_rate, 3250, 500, gr::filter::firdes::WIN_HANN);
+  low_f = gr::filter::fir_filter_fff::make(1, low_f_taps);
 
   // using squelch
   connect(self(), 0, valve, 0);
@@ -183,7 +188,8 @@ analog_recorder::analog_recorder(Source *src)
   connect(deemph, 0, decim_audio, 0);
   connect(decim_audio, 0, high_f, 0);
   connect(decim_audio, 0, decoder_sink, 0);
-  connect(high_f, 0, squelch_two, 0);
+  connect(high_f, 0, low_f, 0);
+  connect(low_f, 0, squelch_two, 0);
   connect(squelch_two, 0, levels, 0);
   connect(levels, 0, wav_sink, 0);
 }
diff --git a/trunk-recorder/recorders/analog_recorder.h b/trunk-recorder/recorders/analog_recorder.h
index 7047c7a7b..0c38bed3b 100644
--- a/trunk-recorder/recorders/analog_recorder.h
+++ b/trunk-recorder/recorders/analog_recorder.h
@@ -107,6 +107,7 @@ class analog_recorder : public gr::hier_block2, public Recorder {
   std::vector<float> audio_resampler_taps;
   std::vector<float> sym_taps;
   std::vector<float> high_f_taps;
+  std::vector<float> low_f_taps;
   std::vector<float> arb_taps;
   /* De-emph IIR filter taps */
   std::vector<double> d_fftaps; /*! Feed forward taps. */
@@ -128,6 +129,7 @@ class analog_recorder : public gr::hier_block2, public Recorder {
   gr::filter::pfb_arb_resampler_ccf::sptr arb_resampler;
   gr::filter::fir_filter_fff::sptr decim_audio;
   gr::filter::fir_filter_fff::sptr high_f;
+  gr::filter::fir_filter_fff::sptr low_f;
   gr::analog::pwr_squelch_cc::sptr squelch;
   gr::analog::pwr_squelch_ff::sptr squelch_two;
   gr::analog::quadrature_demod_cf::sptr demod;