From e3b6560b0423efbaecb743e7edf6cbb28a1ee3c7 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 7 Jun 2016 13:45:25 -0700 Subject: [PATCH] soapy: support automatic bandwidth param When the special 0.0 bandwidth setting is used, set the filter bandwidth to rate * 0.75. Passing automatic 0.0 bandwidth for some devices was problematic. --- lib/soapy/soapy_sink_c.cc | 5 ++++- lib/soapy/soapy_source_c.cc | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/soapy/soapy_sink_c.cc b/lib/soapy/soapy_sink_c.cc index dd4130e..c1f6fc1 100644 --- a/lib/soapy/soapy_sink_c.cc +++ b/lib/soapy/soapy_sink_c.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2015 Josh Blum + * Copyright 2015-2016 Josh Blum * Copyright 2013 Dimitri Stolnikov * * GNU Radio is free software; you can redistribute it and/or modify @@ -272,6 +272,9 @@ void soapy_sink_c::set_iq_balance( const std::complex &balance, size_t c double soapy_sink_c::set_bandwidth( double bandwidth, size_t chan) { + if ( bandwidth == 0.0 ) /* bandwidth of 0 means automatic filter selection */ + set_bandwidth(get_sample_rate() * 0.75, chan); /* select narrower filters to prevent aliasing */ + _device->setBandwidth(SOAPY_SDR_TX, chan, bandwidth); return this->get_bandwidth(chan); } diff --git a/lib/soapy/soapy_source_c.cc b/lib/soapy/soapy_source_c.cc index ea84467..e64f34a 100644 --- a/lib/soapy/soapy_source_c.cc +++ b/lib/soapy/soapy_source_c.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2015 Josh Blum + * Copyright 2015-2016 Josh Blum * Copyright 2013 Dimitri Stolnikov * * GNU Radio is free software; you can redistribute it and/or modify @@ -292,6 +292,9 @@ void soapy_source_c::set_iq_balance( const std::complex &balance, size_t double soapy_source_c::set_bandwidth( double bandwidth, size_t chan ) { + if ( bandwidth == 0.0 ) /* bandwidth of 0 means automatic filter selection */ + set_bandwidth(get_sample_rate() * 0.75, chan); /* select narrower filters to prevent aliasing */ + _device->setBandwidth(SOAPY_SDR_RX, chan, bandwidth); return this->get_bandwidth(chan); }