mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-10-01 00:10:50 +00:00
Notch filters FFT improved
FFT migrated from Armadillo to GNU Radio
This commit is contained in:
parent
f6397c9c39
commit
c114d38975
@ -38,7 +38,6 @@
|
|||||||
#include <volk/volk.h>
|
#include <volk/volk.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
#include <armadillo>
|
|
||||||
|
|
||||||
using google::LogMessage;
|
using google::LogMessage;
|
||||||
|
|
||||||
@ -72,6 +71,7 @@ Notch::Notch(float pfa, float p_c_factor, int length_, int n_segments_est, int n
|
|||||||
angle_ = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment()));
|
angle_ = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment()));
|
||||||
power_spect = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment()));
|
power_spect = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment()));
|
||||||
last_out = gr_complex(0,0);
|
last_out = gr_complex(0,0);
|
||||||
|
d_fft = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(length_, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -99,17 +99,14 @@ int Notch::general_work(int noutput_items, gr_vector_int &ninput_items __attribu
|
|||||||
lv_32fc_t dot_prod_;
|
lv_32fc_t dot_prod_;
|
||||||
const gr_complex* in = reinterpret_cast<const gr_complex *>(input_items[0]);
|
const gr_complex* in = reinterpret_cast<const gr_complex *>(input_items[0]);
|
||||||
gr_complex* out = reinterpret_cast<gr_complex *>(output_items[0]);
|
gr_complex* out = reinterpret_cast<gr_complex *>(output_items[0]);
|
||||||
|
|
||||||
in++;
|
in++;
|
||||||
arma::cx_fvec signal_segment;
|
|
||||||
arma::cx_fvec signal_segment_fft;
|
|
||||||
while((index_out + length_) < noutput_items)
|
while((index_out + length_) < noutput_items)
|
||||||
{
|
{
|
||||||
if((n_segments < n_segments_est) && (filter_state_ == false))
|
if((n_segments < n_segments_est) && (filter_state_ == false))
|
||||||
{
|
{
|
||||||
signal_segment = arma::cx_fvec(in, length_);
|
memcpy(d_fft->get_inbuf(), in, sizeof(gr_complex) * length_);
|
||||||
signal_segment_fft = arma::fft(signal_segment);
|
d_fft->execute();
|
||||||
volk_32fc_s32f_power_spectrum_32f(power_spect, signal_segment_fft.memptr(), 1.0, length_);
|
volk_32fc_s32f_power_spectrum_32f(power_spect, d_fft->get_outbuf(), 1.0, length_);
|
||||||
volk_32f_s32f_calc_spectral_noise_floor_32f(&sig2dB, power_spect, 15.0, length_);
|
volk_32f_s32f_calc_spectral_noise_floor_32f(&sig2dB, power_spect, 15.0, length_);
|
||||||
sig2lin = std::pow(10.0, (sig2dB / 10.0)) / (static_cast<float>(n_deg_fred) );
|
sig2lin = std::pow(10.0, (sig2dB / 10.0)) / (static_cast<float>(n_deg_fred) );
|
||||||
noise_pow_est = (static_cast<float>(n_segments) * noise_pow_est + sig2lin) / (static_cast<float>(n_segments + 1));
|
noise_pow_est = (static_cast<float>(n_segments) * noise_pow_est + sig2lin) / (static_cast<float>(n_segments + 1));
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <gnuradio/block.h>
|
#include <gnuradio/block.h>
|
||||||
|
#include <gnuradio/fft/fft.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class Notch;
|
class Notch;
|
||||||
|
|
||||||
@ -64,6 +66,7 @@ private:
|
|||||||
gr_complex* c_samples;
|
gr_complex* c_samples;
|
||||||
float* angle_;
|
float* angle_;
|
||||||
float* power_spect;
|
float* power_spect;
|
||||||
|
std::unique_ptr<gr::fft::fft_complex> d_fft;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
#include <boost/math/distributions/chi_squared.hpp>
|
#include <boost/math/distributions/chi_squared.hpp>
|
||||||
#include <armadillo>
|
|
||||||
|
|
||||||
using google::LogMessage;
|
using google::LogMessage;
|
||||||
|
|
||||||
@ -47,7 +46,6 @@ notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_,
|
|||||||
return notch_lite_sptr(new NotchLite(p_c_factor, pfa, length_, n_segments_est, n_segments_reset, n_segments_coeff));
|
return notch_lite_sptr(new NotchLite(p_c_factor, pfa, length_, n_segments_est, n_segments_reset, n_segments_coeff));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NotchLite::NotchLite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff) : gr::block("NotchLite",
|
NotchLite::NotchLite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff) : gr::block("NotchLite",
|
||||||
gr::io_signature::make (1, 1, sizeof(gr_complex)),
|
gr::io_signature::make (1, 1, sizeof(gr_complex)),
|
||||||
gr::io_signature::make (1, 1, sizeof(gr_complex)))
|
gr::io_signature::make (1, 1, sizeof(gr_complex)))
|
||||||
@ -76,10 +74,9 @@ NotchLite::NotchLite(float p_c_factor, float pfa, int length_, int n_segments_es
|
|||||||
angle1 = 0.0;
|
angle1 = 0.0;
|
||||||
angle2 = 0.0;
|
angle2 = 0.0;
|
||||||
power_spect = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment()));
|
power_spect = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment()));
|
||||||
|
d_fft = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(length_, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NotchLite::~NotchLite()
|
NotchLite::~NotchLite()
|
||||||
{
|
{
|
||||||
volk_free(power_spect);
|
volk_free(power_spect);
|
||||||
@ -102,17 +99,14 @@ int NotchLite::general_work(int noutput_items, gr_vector_int &ninput_items __att
|
|||||||
lv_32fc_t dot_prod_;
|
lv_32fc_t dot_prod_;
|
||||||
const gr_complex* in = reinterpret_cast<const gr_complex *>(input_items[0]);
|
const gr_complex* in = reinterpret_cast<const gr_complex *>(input_items[0]);
|
||||||
gr_complex* out = reinterpret_cast<gr_complex *>(output_items[0]);
|
gr_complex* out = reinterpret_cast<gr_complex *>(output_items[0]);
|
||||||
|
|
||||||
in++;
|
in++;
|
||||||
arma::cx_fvec signal_segment;
|
|
||||||
arma::cx_fvec signal_segment_fft;
|
|
||||||
while((index_out + length_) < noutput_items)
|
while((index_out + length_) < noutput_items)
|
||||||
{
|
{
|
||||||
if((n_segments < n_segments_est) && (filter_state_ == false))
|
if((n_segments < n_segments_est) && (filter_state_ == false))
|
||||||
{
|
{
|
||||||
signal_segment = arma::cx_fvec(in, length_);
|
memcpy(d_fft->get_inbuf(), in, sizeof(gr_complex) * length_);
|
||||||
signal_segment_fft = arma::fft(signal_segment);
|
d_fft->execute();
|
||||||
volk_32fc_s32f_power_spectrum_32f(power_spect, signal_segment_fft.memptr(), 1.0, length_);
|
volk_32fc_s32f_power_spectrum_32f(power_spect, d_fft->get_outbuf(), 1.0, length_);
|
||||||
volk_32f_s32f_calc_spectral_noise_floor_32f(&sig2dB, power_spect, 15.0, length_);
|
volk_32f_s32f_calc_spectral_noise_floor_32f(&sig2dB, power_spect, 15.0, length_);
|
||||||
sig2lin = std::pow(10.0, (sig2dB / 10.0)) / static_cast<float>(n_deg_fred);
|
sig2lin = std::pow(10.0, (sig2dB / 10.0)) / static_cast<float>(n_deg_fred);
|
||||||
noise_pow_est = (static_cast<float>(n_segments) * noise_pow_est + sig2lin) / static_cast<float>(n_segments + 1);
|
noise_pow_est = (static_cast<float>(n_segments) * noise_pow_est + sig2lin) / static_cast<float>(n_segments + 1);
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <gnuradio/block.h>
|
#include <gnuradio/block.h>
|
||||||
|
#include <gnuradio/fft/fft.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class NotchLite;
|
class NotchLite;
|
||||||
|
|
||||||
@ -67,6 +69,7 @@ private:
|
|||||||
float angle1;
|
float angle1;
|
||||||
float angle2;
|
float angle2;
|
||||||
float* power_spect;
|
float* power_spect;
|
||||||
|
std::unique_ptr<gr::fft::fft_complex> d_fft;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include <gnuradio/fft/fft.h>
|
#include <gnuradio/fft/fft.h>
|
||||||
#include <armadillo>
|
#include <armadillo>
|
||||||
|
|
||||||
DEFINE_int32(fft_speed_iterations_test, 1000, "Number of averaged iterations in FFT length timing test");
|
DEFINE_int32(fft_speed_iterations_test, 100, "Number of averaged iterations in FFT length timing test");
|
||||||
|
|
||||||
TEST(FFTSpeedTest, ArmadilloVSGNURadioExecutionTime)
|
TEST(FFTSpeedTest, ArmadilloVSGNURadioExecutionTime)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user