From e1c77a24ebd590a44b0fdf46c27be724e44d4237 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 10 Jun 2024 20:16:59 -0400 Subject: [PATCH] Improves the channelizer by lowering the number of Taps and tightening the channel bandwidth (#960) * Dropping Taps and tightening channels * Update xlat_channelizer.cc --- trunk-recorder/gr_blocks/xlat_channelizer.cc | 39 ++++++++++---------- trunk-recorder/gr_blocks/xlat_channelizer.h | 1 + trunk-recorder/recorders/analog_recorder.cc | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/trunk-recorder/gr_blocks/xlat_channelizer.cc b/trunk-recorder/gr_blocks/xlat_channelizer.cc index 3ccf5001..4c3ed768 100644 --- a/trunk-recorder/gr_blocks/xlat_channelizer.cc +++ b/trunk-recorder/gr_blocks/xlat_channelizer.cc @@ -56,26 +56,27 @@ xlat_channelizer::xlat_channelizer(double input_rate, int samples_per_symbol, do const float pi = M_PI; + int initial_decim = floor(input_rate / 96000); + double initial_rate = double(input_rate) / double(initial_decim); + int decim = floor(initial_rate / channel_rate); + double resampled_rate = double(initial_rate) / double(decim); + int decimation = floor(input_rate / channel_rate); - double resampled_rate = float(input_rate) / float(decimation); - /* - std::vector if_coeffs; - #if GNURADIO_VERSION < 0x030900 - - if_coeffs = gr::filter::firdes::low_pass(1.0, input_rate, resampled_rate / 2, resampled_rate / 2, gr::filter::firdes::WIN_HAMMING); - #else - if_coeffs = gr::filter::firdes::low_pass(1.0, input_rate, resampled_rate / 2, resampled_rate / 2, gr::fft::window::WIN_HAMMING); - #endif - freq_xlat = gr::filter::freq_xlating_fir_filter::make(decimation, if_coeffs, 0, input_rate); // inital_lpf_taps, 0, input_rate); - */ + // double resampled_rate = float(input_rate) / float(decimation); + + + // channel_lpf_taps = gr::filter::firdes::low_pass_2(1.0, pre_channel_rate, 5000, 2000, 60); + std::vector channel_lpf_taps = gr::filter::firdes::low_pass_2(1.0, initial_rate, d_bandwidth / 2, d_bandwidth / 4, 60); std::vector if_coeffs; - if_coeffs = gr::filter::firdes::complex_band_pass(1, input_rate, -d_bandwidth / 2, d_bandwidth / 2, d_bandwidth ); + if_coeffs = gr::filter::firdes::complex_band_pass_2(1, input_rate, -24000, 24000, 12000, 10 ); - freq_xlat = make_freq_xlating_fft_filter(decimation, if_coeffs, 0, input_rate); // inital_lpf_taps, 0, input_rate); + channel_lpf = gr::filter::fft_filter_ccf::make(decim, channel_lpf_taps); - BOOST_LOG_TRIVIAL(info) << "\t Xlating Channelizer single-stage decimator - Decim: " << decimation << " Resampled Rate: " << resampled_rate << " Lowpass Taps: " << if_coeffs.size(); + freq_xlat = make_freq_xlating_fft_filter(initial_decim, if_coeffs, 0, input_rate); // inital_lpf_taps, 0, input_rate); + // BOOST_LOG_TRIVIAL(info) << "\t Xlating Channelizer single-stage decimator - Decim: " << decimation << " Resampled Rate: " << resampled_rate << " Lowpass Taps: " << if_coeffs.size(); + BOOST_LOG_TRIVIAL(info) << "\t Xlating Channelizer single-stage decimator - if_coeffs: " << if_coeffs.size() << " Decim: " << decim << " Resampled Rate: " << resampled_rate << " Lowpass Taps: " << channel_lpf_taps.size(); // ARB Resampler double arb_rate = channel_rate / resampled_rate; @@ -125,21 +126,21 @@ xlat_channelizer::xlat_channelizer(double input_rate, int samples_per_symbol, do fll_band_edge = gr::digital::fll_band_edge_cc::make(d_samples_per_symbol, def_excess_bw, 2 * d_samples_per_symbol + 1, (2.0 * pi) / d_samples_per_symbol / 250); // OP25 has this set to 350 instead of 250 connect(self(), 0, freq_xlat, 0); - + connect(freq_xlat, 0, channel_lpf, 0); if (d_use_squelch) { BOOST_LOG_TRIVIAL(info) << "Conventional - with Squelch"; if (arb_rate == 1.0) { - connect(freq_xlat, 0, squelch, 0); + connect(channel_lpf, 0, squelch, 0); } else { - connect(freq_xlat, 0, arb_resampler, 0); + connect(channel_lpf, 0, arb_resampler, 0); connect(arb_resampler, 0, squelch, 0); } connect(squelch, 0, rms_agc, 0); } else { if (arb_rate == 1.0) { - connect(freq_xlat, 0, rms_agc, 0); + connect(channel_lpf, 0, rms_agc, 0); } else { - connect(freq_xlat, 0, arb_resampler, 0); + connect(channel_lpf, 0, arb_resampler, 0); connect(arb_resampler, 0, rms_agc, 0); } } diff --git a/trunk-recorder/gr_blocks/xlat_channelizer.h b/trunk-recorder/gr_blocks/xlat_channelizer.h index 77a457f3..22bd314b 100644 --- a/trunk-recorder/gr_blocks/xlat_channelizer.h +++ b/trunk-recorder/gr_blocks/xlat_channelizer.h @@ -96,6 +96,7 @@ class xlat_channelizer : public gr::hier_block2 { gr::filter::fft_filter_ccc::sptr bandpass_filter; gr::filter::fft_filter_ccf::sptr lowpass_filter; + gr::filter::fft_filter_ccf::sptr channel_lpf; gr::filter::fft_filter_ccf::sptr cutoff_filter; gr::filter::pfb_arb_resampler_ccf::sptr arb_resampler; diff --git a/trunk-recorder/recorders/analog_recorder.cc b/trunk-recorder/recorders/analog_recorder.cc index 375347e2..f1ac6395 100644 --- a/trunk-recorder/recorders/analog_recorder.cc +++ b/trunk-recorder/recorders/analog_recorder.cc @@ -114,7 +114,7 @@ analog_recorder::analog_recorder(Source *src, Recorder_Type type, float tone_fre } int samp_per_sym = 2; - double bandwidth = 16000; + double bandwidth = 12000; system_channel_rate = 16000; // 4800 * samp_per_sym; wav_sample_rate = 16000; // Must be an integer decimation of system_channel_rate