baseband.hh
#ifndef __SDR_BASEBAND_HH__
#define __SDR_BASEBAND_HH__
#include "node.hh"
#include "config.hh"
#include "utils.hh"
#include "traits.hh"
#include "operators.hh"
#include "freqshift.hh"
namespace sdr {
template <class Scalar>
class IQBaseBand: public Sink< std::complex<Scalar> >, public Source, public FreqShiftBase<Scalar>
{
public:
typedef std::complex<Scalar> CScalar;
typedef int32_t SScalar;
typedef std::complex<SScalar> CSScalar;
public:
IQBaseBand(double Fc, double width, size_t order, size_t sub_sample, double oFs=0.0)
: Sink<CScalar>(), Source(), FreqShiftBase<Scalar>(Fc, 0),
_Fc(Fc), _Ff(Fc), _Fs(0), _width(width), _order(std::max(size_t(1), order)),
_sub_sample(sub_sample), _oFs(oFs), _ring_offset(0), _sample_count(0),
_last(0), _kernel(_order)
{
// Allocate and reset ring buffer:
_ring = Buffer<CSScalar>(_order);
for (size_t i=0; i<_order; i++) { _ring[i] = 0; }
}
IQBaseBand(double Fc, double Ff, double width, size_t order, size_t sub_sample, double oFs=0.0)
: Sink<CScalar>(), Source(), FreqShiftBase<Scalar>(Fc, 0),
_Fc(Fc), _Ff(Ff), _Fs(0), _width(width), _order(std::max(size_t(1), order)),
_sub_sample(sub_sample), _oFs(oFs), _ring_offset(0), _sample_count(0),
_last(0), _kernel(_order)
{
// Allocate and reset ring buffer:
_ring = Buffer<CSScalar>(_order);
for (size_t i=0; i<_order; i++) { _ring[i] = 0; }
}
virtual ~IQBaseBand() {
// Free buffers
_buffer.unref();
_kernel.unref();
_ring.unref();
}
inline size_t order() const { return _order; }
void setOrder(size_t o) {
// ensure filter order >= 1
o = (o<1) ? 1 : o;
// Reallocate ring buffer and kernel
if (! _kernel.isEmpty()) { _kernel.unref(); }
if (! _ring.isEmpty()) { _ring.unref(); }
_kernel = Buffer<CSScalar>(o);
_ring = Buffer<CSScalar>(o);
// Update filter kernel
_order = o; _update_filter_kernel();
}
inline double centerFrequency() const { return _Fc; }
void setCenterFrequency(double Fc) {
_Fc = Fc; this->setFrequencyShift(_Fc);
}
inline double filterFrequency() const { return _Ff; }
void setFilterFrequency(double Ff) {
_Ff = Ff; _update_filter_kernel();
}
inline double filterWidth() const { return _width; }
void setFilterWidth(double width) {
_width = width; _update_filter_kernel();
}
size_t subSample() const { return _sub_sample; }
void setSubsample(size_t sub_sample) {
_sub_sample = std::max(size_t(1), sub_sample); _reconfigure();
}
void setOutputSampleRate(double Fs) {
_oFs = Fs; _reconfigure();
}
virtual void config(const Config &src_cfg)
{
// Requires type, sample rate & buffer size
if (!src_cfg.hasType() || !src_cfg.hasSampleRate() || !src_cfg.hasBufferSize()) { return; }
// Check buffer type
if (Config::typeId<CScalar>() != src_cfg.type()) {
ConfigError err;
err << "Can not configure IQBaseBand: Invalid type " << src_cfg.type()
<< ", expected " << Config::typeId<CScalar>();
throw err;
}
// Store sample rate
_Fs = src_cfg.sampleRate();
// Store source buffer size
_sourceBs = src_cfg.bufferSize();
_reconfigure();
}
virtual void process(const Buffer< std::complex<Scalar> > &buffer, bool allow_overwrite)
{
if (allow_overwrite) {
// Perform in-place if @c allow_overwrite
_process(buffer, buffer);
} else if (_buffer.isUnused()) {
// Otherwise store results into output buffer.
_process(buffer, _buffer);
} else {
#ifdef SDR_DEBUG
LogMessage msg(LOG_WARNING);
msg << "IQBaseBand: Drop buffer: Output buffer still in use.";
Logger::get().log(msg);
#endif
}
}
protected:
void _reconfigure()
{
// If _oFs > 0 -> set _sub_sample to match the sample rate (approx).
if (_oFs > 0) {
_sub_sample = _Fs/_oFs;
if (_sub_sample < 1) { _sub_sample=1; }
}
// Update filter kernel
_update_filter_kernel();
// Update freq shift operator:
this->setSampleRate(_Fs);
// Calc output buffer size
size_t buffer_size = _sourceBs/_sub_sample;
if (_sourceBs%_sub_sample) { buffer_size += 1; }
// Allocate output buffer
_buffer = Buffer<CScalar>(buffer_size);
// Reset internal state
_last = 0;
_sample_count = 0;
_ring_offset = 0;
LogMessage msg(LOG_DEBUG);
msg << "Configured IQBaseBand node:" << std::endl
<< " type " << Traits< std::complex<Scalar> >::scalarId << std::endl
<< " sample-rate " << _Fs << "Hz" << std::endl
<< " center freq " << _Fc << "Hz" << std::endl
<< " width " << _width << "Hz" << std::endl
<< " kernel " << _kernel << std::endl
<< " in buffer size " << _sourceBs << std::endl
<< " sub-sample by " << _sub_sample << std::endl
<< " out buffer size " << buffer_size;
Logger::get().log(msg);
// Propergate config
this->setConfig(Config(Traits< std::complex<Scalar> >::scalarId,
_Fs/_sub_sample, buffer_size, 1));
}
inline void _process(const Buffer<CScalar> &in, const Buffer<CScalar> &out) {
size_t i=0, j=0;
for (; i<in.size(); i++, _sample_count++) {
// Store sample in ring buffer
_ring[_ring_offset] = in[i];
// Apply filter on ring-buffer and shift freq
_last += this->applyFrequencyShift(_filter_ring());
// _ring_offset modulo _order
_ring_offset++;
if (_order == _ring_offset) { _ring_offset = 0; }
// If _sample_count samples have been averaged:
if (_sub_sample == _sample_count) {
// Store average in output buffer
CSScalar value = _last/CSScalar(_sub_sample);
out[j] = value;
// reset average, sample count and increment output buffer index j
_last = 0; _sample_count=0; j++;
} else if (_sub_sample == 1) {
out[j] = _last; _last = 0; _sample_count = 0; j++;
}
}
this->send(out.head(j), true);
}
inline CSScalar _filter_ring() const
{
CSScalar res = 0;
size_t idx = _ring_offset+1;
if (_order == idx) { idx = 0; }
for (size_t i=0; i<_order; i++, idx++) {
if (_order == idx) { idx = 0; }
res += _kernel[i]*_ring[idx];
}
return (res>>14);
}
void _update_filter_kernel() {
// First, create a filter kernel of a low-pass filter with _width/2 cut-off
Buffer< std::complex<double> > alpha(_order);
double w = (M_PI*_width)/(_Fs);
double M = double(_order)/2.;
double norm = 0;
//std::complex<double> phi(0.0, (2*M_PI*_Ff)/_Fs); phi = std::exp(phi);
for (size_t i=0; i<_order; i++) {
if (_order == 2*i) { alpha[i] = 4*(w/M_PI); }
else { alpha[i] = std::sin(w*(i-M))/(w*(i-M)); }
// Shift freq by +_Ff:
//alpha[i] = phi*alpha[i]; phi = phi*phi;
alpha[i] *= std::exp(std::complex<double>(0.0, (-2*M_PI*_Ff*i)/_Fs));
// apply window function
alpha[i] *= (0.42 - 0.5*cos((2*M_PI*i)/_order) + 0.08*cos((4*M_PI*i)/_order));
// Calc norm
norm += std::abs(alpha[i]);
}
// Normalize filter coeffs and store in _kernel:
for (size_t i=0; i<_order; i++) {
_kernel[i] = (double(1<<14) * alpha[i]) / norm;
}
}
protected:
int32_t _Fc;
int32_t _Ff;
int32_t _Fs;
int32_t _width;
size_t _order;
size_t _sub_sample;
double _oFs;
size_t _ring_offset;
size_t _sample_count;
CSScalar _last;
size_t _sourceBs;
Buffer<CSScalar> _kernel;
Buffer<CSScalar> _ring;
Buffer<CScalar> _buffer;
};
template <class Scalar>
class BaseBand: public Sink<Scalar>, public Source, public FreqShiftBase<Scalar>
{
public:
typedef typename FreqShiftBase<Scalar>::CScalar CScalar;
typedef typename FreqShiftBase<Scalar>::SScalar SScalar;
typedef typename FreqShiftBase<Scalar>::CSScalar CSScalar;
public:
BaseBand(double Fc, double width, size_t order, size_t sub_sample)
: Sink<Scalar>(), Source(), FreqShiftBase<Scalar>(Fc, 0),
_Ff(Fc), _width(width), _order(std::max(size_t(1), order)),
_sub_sample(sub_sample), _ring_offset(0), _sample_count(0),
_last(0), _kernel(_order)
{
// Allocate and reset ring buffer:
_ring = Buffer<SScalar>(_order);
for (size_t i=0; i<_order; i++) { _ring[i] = 0; }
}
BaseBand(double Fc, double Ff, double width, size_t order, size_t sub_sample)
: Sink<Scalar>(), Source(), FreqShiftBase<Scalar>(Fc, 0),
_Ff(Ff), _width(width), _order(std::max(size_t(1), order)),
_sub_sample(sub_sample), _ring_offset(0), _sample_count(0),
_last(0), _kernel(_order)
{
// Allocate and reset ring buffer:
_ring = Buffer<SScalar>(_order);
for (size_t i=0; i<_order; i++) { _ring[i] = 0; }
}
virtual ~BaseBand() {
// Free buffers
_buffer.unref();
_kernel.unref();
_ring.unref();
}
virtual void config(const Config &src_cfg) {
// Requires type, sample rate & buffer size
if (!src_cfg.hasType() || !src_cfg.hasSampleRate() || !src_cfg.hasBufferSize()) { return; }
// Check buffer type
if (Config::typeId<Scalar>() != src_cfg.type()) {
ConfigError err;
err << "Can not configure BaseBand: Invalid type " << src_cfg.type()
<< ", expected " << Config::typeId<Scalar>();
throw err;
}
// Store sample rate
this->setSampleRate(src_cfg.sampleRate());
// Calc output buffer size
size_t buffer_size = src_cfg.bufferSize()/_sub_sample;
if (src_cfg.bufferSize()%_sub_sample) { buffer_size += 1; }
// Allocate output buffer
_buffer = Buffer<CScalar>(buffer_size);
_last = 0;
_sample_count = 0;
_ring_offset = 0;
LogMessage msg(LOG_DEBUG);
msg << "Configured BaseBand node:" << std::endl
<< " type " << Traits< std::complex<Scalar> >::scalarId << std::endl
<< " sample-rate " << FreqShiftBase<Scalar>::sampleRate() << "Hz" << std::endl
<< " center freq " << FreqShiftBase<Scalar>::frequencyShift() << "Hz" << std::endl
<< " width " << _width << "Hz" << std::endl
<< " kernel " << _kernel << std::endl
<< " in buffer size " << src_cfg.bufferSize() << std::endl
<< " sub-sample by " << _sub_sample << std::endl
<< " out buffer size " << buffer_size;
Logger::get().log(msg);
// Propergate config
this->setConfig(Config(Traits< std::complex<Scalar> >::scalarId,
FreqShiftBase<Scalar>::sampleRate()/_sub_sample, buffer_size, 1));
}
virtual void setSampleRate(double Fs) {
FreqShiftBase<Scalar>::setSampleRate(Fs);
_update_filter_kernel();
}
virtual void process(const Buffer<Scalar> &buffer, bool allow_overwrite)
{
if (_buffer.isUnused()) {
_process(buffer, _buffer);
} else {
#ifdef SDR_DEBUG
LogMessage msg(LOG_WARNING);
msg << "BaseBand: Drop buffer: Output buffer still in use.";
Logger::get().log(msg);
#endif
}
}
protected:
inline void _process(const Buffer<Scalar> &in, const Buffer<CScalar> &out) {
size_t i=0, j=0;
for (; i<in.size(); i++) {
// Store sample in ring buffer
_ring[_ring_offset] = in[i];
_last += this->applyFrequencyShift(_filter_ring());
_sample_count++;
// _ring_offset modulo _order
_ring_offset++;
if (_order == _ring_offset) { _ring_offset = 0; }
// If _sample_count samples have been averaged:
if (_sub_sample == _sample_count) {
// Store average in output buffer
out[j] = _last/CSScalar(_sub_sample);;
// reset average, sample count and increment output buffer index j
_last = 0; _sample_count=0; j++;
}
}
this->send(out.head(j), true);
}
inline CSScalar _filter_ring()
{
CSScalar res = 0;
size_t idx = _ring_offset+1;
if (_order == idx) { idx = 0; }
for (size_t i=0; i<_order; i++, idx++) {
if (_order == idx) { idx = 0; }
res += _kernel[i]*_ring[idx];
}
return (res>>Traits<Scalar>::shift);
}
void _update_filter_kernel() {
// First, create a filter kernel of a low-pass filter with
// _width/2 cut-off
Buffer< std::complex<double> > alpha(_order);
double w = (2*M_PI*_width)/(2*FreqShiftBase<Scalar>::sampleRate());
double M = double(_order)/2;
double norm = 0;
for (size_t i=0; i<_order; i++) {
if (_order == (2*i)) { alpha[i] = 1; }
else { alpha[i] = std::sin(w*(i-M))/(w*(i-M)); }
}
// Shift filter by _Fc, apply window function and calc norm of filter
std::complex<double> phi(0.0, (2*M_PI*_Ff)/FreqShiftBase<Scalar>::sampleRate()); phi = std::exp(phi);
for (size_t i=0; i<_order; i++) {
// Shift filter kernel
alpha[i] = alpha[i]*std::exp(std::complex<double>(0, (2*M_PI*_Ff*i)/FreqShiftBase<Scalar>::sampleRate()));
// apply window function
alpha[i] *= (0.42 - 0.5*cos((2*M_PI*(i+1))/(_order+2)) +
0.08*cos((4*M_PI*(i+1))/(_order+2)));
// Calc norm
norm += std::abs(alpha[i]);
}
// Normalize filter coeffs and store in _kernel:
for (size_t i=0; i<_order; i++) {
_kernel[i] = ((double(1<<Traits<Scalar>::shift) * alpha[i]) / norm);
}
// free alpha
alpha.unref();
}
protected:
double _Ff;
double _width;
size_t _order;
size_t _sub_sample;
size_t _ring_offset;
size_t _sample_count;
CSScalar _last;
bool _shift_freq;
Buffer< CSScalar > _lut;
size_t _lut_inc;
size_t _lut_count;
Buffer<CSScalar> _kernel;
Buffer<SScalar> _ring;
Buffer<CScalar> _buffer;
protected:
static const size_t _lut_size=128;
};
}
#endif // __SDR_BASEBAND_HH__
sdr::BaseBand::CSScalar
FreqShiftBase< Scalar >::CSScalar CSScalar
The complex super scalar.
Definition: baseband.hh:313
sdr::BaseBand::~BaseBand
virtual ~BaseBand()
Destructor.
Definition: baseband.hh:352
sdr::Config
A collection of configuration information that is send by a source to all connected sinks to properga...
Definition: node.hh:35
sdr::FreqShiftBase::frequencyShift
double frequencyShift() const
Returns the frequency shift.
Definition: freqshift.hh:51
sdr::IQBaseBand::subSample
size_t subSample() const
Returns the sub sampling.
Definition: baseband.hh:103
sdr::IQBaseBand::_ring_offset
size_t _ring_offset
The current index of the ring buffer.
Definition: baseband.hh:280
sdr::IQBaseBand::_width
int32_t _width
The filter width.
Definition: baseband.hh:272
sdr::IQBaseBand::CSScalar
std::complex< SScalar > CSScalar
Complex SScalar type.
Definition: baseband.hh:31
sdr::BaseBand::_sample_count
size_t _sample_count
The current number of averages.
Definition: baseband.hh:506
sdr::IQBaseBand::filterFrequency
double filterFrequency() const
Returns the filter frequency.
Definition: baseband.hh:89
sdr::BaseBand::CScalar
FreqShiftBase< Scalar >::CScalar CScalar
The complex input scalar.
Definition: baseband.hh:309
sdr::IQBaseBand::setOrder
void setOrder(size_t o)
(Re-) Sets the filter order.
Definition: baseband.hh:69
sdr::FreqShiftBase::setSampleRate
virtual void setSampleRate(double Fs)
Sets the sample rate and updates the LUT.
Definition: freqshift.hh:46
sdr::Source::send
virtual void send(const RawBuffer &buffer, bool allow_overwrite=false)
Sends the given buffer to all connected sinks.
Definition: node.cc:67
sdr::IQBaseBand::_sub_sample
size_t _sub_sample
The number of sample averages for the sub sampling.
Definition: baseband.hh:276
sdr::IQBaseBand
This class performs several operations on the complex (integral) input stream, it first filters out s...
Definition: baseband.hh:22
sdr::IQBaseBand::IQBaseBand
IQBaseBand(double Fc, double width, size_t order, size_t sub_sample, double oFs=0.0)
Constructor, the filter center frequency Ff equals the given center frequency Fc. ...
Definition: baseband.hh:35
sdr::BaseBand::_process
void _process(const Buffer< Scalar > &in, const Buffer< CScalar > &out)
Performs the actual procssing.
Definition: baseband.hh:425
sdr::Sink
Typed sink.
Definition: node.hh:192
sdr
Definition: autocast.hh:8
sdr::IQBaseBand::centerFrequency
double centerFrequency() const
Returns the center frequency.
Definition: baseband.hh:82
sdr::RawBuffer::isEmpty
bool isEmpty() const
Returns true if the buffer is invalid/empty.
Definition: buffer.hh:77
std
Definition: operators.hh:9
sdr::IQBaseBand::setCenterFrequency
void setCenterFrequency(double Fc)
Resets the center frequency.
Definition: baseband.hh:84
sdr::FreqShiftBase::setFrequencyShift
virtual void setFrequencyShift(double F)
Sets the frequency shift and updates the LUT.
Definition: freqshift.hh:53
sdr::Config::hasSampleRate
bool hasSampleRate() const
If true, the configuration has a sample rate.
Definition: node.hh:75
sdr::IQBaseBand::order
size_t order() const
Returns the order of the band-pass filter.
Definition: baseband.hh:67
sdr::BaseBand::_filter_ring
CSScalar _filter_ring()
Applies the filter on the data stored in the ring buffer.
Definition: baseband.hh:450
sdr::IQBaseBand::_reconfigure
void _reconfigure()
Reconfigures the node.
Definition: baseband.hh:156
sdr::Source
Generic source class.
Definition: node.hh:213
sdr::BaseBand::_shift_freq
bool _shift_freq
If true, Fc!=0.
Definition: baseband.hh:511
sdr::FreqShiftBase::sampleRate
double sampleRate() const
Returns the sample rate.
Definition: freqshift.hh:44
sdr::IQBaseBand::setOutputSampleRate
void setOutputSampleRate(double Fs)
Resets the output sample rate.
Definition: baseband.hh:110
sdr::FreqShiftBase::CSScalar
std::complex< SScalar > CSScalar
The complex compute (super) scalar of the input type.
Definition: freqshift.hh:22
sdr::Buffer::size
size_t size() const
Returns the number of elements of type T in this buffer.
Definition: buffer.hh:166
sdr::Config::hasType
bool hasType() const
If true, the configuration has a type.
Definition: node.hh:69
sdr::IQBaseBand::_sourceBs
size_t _sourceBs
Buffer size of the source.
Definition: baseband.hh:286
sdr::IQBaseBand::_Fs
int32_t _Fs
The input sample rate.
Definition: baseband.hh:270
sdr::BaseBand::_ring_offset
size_t _ring_offset
The current index of the ring buffer.
Definition: baseband.hh:503
sdr::IQBaseBand::SScalar
int32_t SScalar
The (real) computation scalar type (super scalar), the computations are performed with this scalar ty...
Definition: baseband.hh:29
sdr::BaseBand::setSampleRate
virtual void setSampleRate(double Fs)
Sets the sample rate and updates the LUT.
Definition: baseband.hh:400
sdr::IQBaseBand::_update_filter_kernel
void _update_filter_kernel()
Updates the band-pass filter kernel.
Definition: baseband.hh:239
sdr::Source::setConfig
virtual void setConfig(const Config &config)
Stores the configuration and propergates it if the configuration has been changed.
Definition: node.cc:98
sdr::IQBaseBand::_oFs
double _oFs
Holds the desired output sample rate, _sub_sample will be adjusted accordingly.
Definition: baseband.hh:278
sdr::IQBaseBand::_order
size_t _order
The order of the filter.
Definition: baseband.hh:274
sdr::BaseBand::BaseBand
BaseBand(double Fc, double width, size_t order, size_t sub_sample)
Constructs a new BaseBand instance.
Definition: baseband.hh:322
sdr::BaseBand::_last
CSScalar _last
The current sum of the last _sample_count samples.
Definition: baseband.hh:508
sdr::IQBaseBand::_buffer
Buffer< CScalar > _buffer
The output buffer.
Definition: baseband.hh:293
sdr::IQBaseBand::IQBaseBand
IQBaseBand(double Fc, double Ff, double width, size_t order, size_t sub_sample, double oFs=0.0)
Constructor.
Definition: baseband.hh:47
sdr::Buffer::head
Buffer< T > head(size_t n) const
Returns a new view on this buffer.
Definition: buffer.hh:237
sdr::IQBaseBand::_process
void _process(const Buffer< CScalar > &in, const Buffer< CScalar > &out)
Performs the base-band selection, frequency shift and sub-sampling.
Definition: baseband.hh:198
sdr::FreqShiftBase::CScalar
std::complex< Scalar > CScalar
The complex input signal.
Definition: freqshift.hh:18
sdr::IQBaseBand::~IQBaseBand
virtual ~IQBaseBand()
Destructor.
Definition: baseband.hh:59
sdr::IQBaseBand::_Ff
int32_t _Ff
The center frequency of the base band.
Definition: baseband.hh:268
sdr::BaseBand::_update_filter_kernel
void _update_filter_kernel()
Calculates or updates the filter kernel.
Definition: baseband.hh:463
sdr::Logger::log
void log(const LogMessage &message)
Logs a message.
Definition: logger.cc:100
sdr::IQBaseBand::setFilterFrequency
void setFilterFrequency(double Ff)
(Re-) Sets the filter frequency.
Definition: baseband.hh:91
sdr::Config::type
Type type() const
Returns the type.
Definition: node.hh:71
sdr::IQBaseBand::_ring
Buffer< CSScalar > _ring
A ring buffer of past values.
Definition: baseband.hh:291
sdr::BaseBand::process
virtual void process(const Buffer< Scalar > &buffer, bool allow_overwrite)
Processes the input buffer.
Definition: baseband.hh:407
sdr::FreqShiftBase::SScalar
Traits< Scalar >::SScalar SScalar
The compute (super) scalar of the input type.
Definition: freqshift.hh:20
sdr::Logger::get
static Logger & get()
Returns the singleton instance of the logger.
Definition: logger.cc:89
sdr::IQBaseBand::_sample_count
size_t _sample_count
Holds the current number of samples averaged.
Definition: baseband.hh:282
sdr::BaseBand::_buffer
Buffer< CScalar > _buffer
The output buffer.
Definition: baseband.hh:524
sdr::FreqShiftBase
A performant implementation of a frequency-shift operation on integer signals.
Definition: freqshift.hh:14
sdr::IQBaseBand::_Fc
int32_t _Fc
The frequency shift of the base band.
Definition: baseband.hh:266
sdr::IQBaseBand::config
virtual void config(const Config &src_cfg)
Configures the BaseBand node.
Definition: baseband.hh:115
sdr::BaseBand::_order
size_t _order
The order of the band pass filter.
Definition: baseband.hh:499
sdr::ConfigError
The configuration error class.
Definition: exception.hh:24
sdr::BaseBand::_lut
Buffer< CSScalar > _lut
look-up table
Definition: baseband.hh:513
sdr::LogMessage
A log message.
Definition: logger.hh:22
sdr::Config::bufferSize
size_t bufferSize() const
Returns the max.
Definition: node.hh:83
sdr::IQBaseBand::CScalar
std::complex< Scalar > CScalar
The complex type of the input stream.
Definition: baseband.hh:26
sdr::IQBaseBand::setSubsample
void setSubsample(size_t sub_sample)
Resets the sub sampling.
Definition: baseband.hh:105
sdr::BaseBand::_lut_count
size_t _lut_count
The current LUT index times (1<<4).
Definition: baseband.hh:517
sdr::BaseBand::_lut_size
static const size_t _lut_size
Size of the look-up table.
Definition: baseband.hh:528
sdr::BaseBand::SScalar
FreqShiftBase< Scalar >::SScalar SScalar
The real super scalar.
Definition: baseband.hh:311
sdr::BaseBand
This class performs several operations on the real input stream, It first filters out some part of th...
Definition: baseband.hh:305
sdr::FreqShiftBase::applyFrequencyShift
CSScalar applyFrequencyShift(CSScalar value)
Performs the frequency shift on a single sample.
Definition: freqshift.hh:58
sdr::BaseBand::_sub_sample
size_t _sub_sample
The number of averages taken for subsampling.
Definition: baseband.hh:501
sdr::BaseBand::_Ff
double _Ff
The center frequency of the band pass filter.
Definition: baseband.hh:495
sdr::RawBuffer::unref
void unref()
Dereferences the buffer.
Definition: buffer.cc:63
sdr::RawBuffer::isUnused
bool isUnused() const
We assume here that buffers are owned by one object: A buffer is therefore "unused" if the owner hold...
Definition: buffer.hh:87
sdr::BaseBand::BaseBand
BaseBand(double Fc, double Ff, double width, size_t order, size_t sub_sample)
Constructs a new BaseBand instance.
Definition: baseband.hh:340
sdr::Traits
Forward declaration of type tratis template.
Definition: traits.hh:20
sdr::IQBaseBand::_kernel
Buffer< CSScalar > _kernel
The filter kernel of order _order.
Definition: baseband.hh:289
sdr::IQBaseBand::process
virtual void process(const Buffer< std::complex< Scalar > > &buffer, bool allow_overwrite)
Processes the given buffer.
Definition: baseband.hh:136
sdr::IQBaseBand::_last
CSScalar _last
Holds the current sum of the last _sample_count samples.
Definition: baseband.hh:284
sdr::IQBaseBand::filterWidth
double filterWidth() const
Returns the filter width.
Definition: baseband.hh:96
sdr::BaseBand::_width
double _width
The width of the band pass filter.
Definition: baseband.hh:497
sdr::BaseBand::_lut_inc
size_t _lut_inc
The LUT index increment per (1<<4) samples.
Definition: baseband.hh:515
sdr::BaseBand::_kernel
Buffer< CSScalar > _kernel
The filter kernel of order _order.
Definition: baseband.hh:520
sdr::IQBaseBand::_filter_ring
CSScalar _filter_ring() const
Applies the filter on the data stored in the ring buffer.
Definition: baseband.hh:226
sdr::BaseBand::_ring
Buffer< SScalar > _ring
A ring buffer of past values.
Definition: baseband.hh:522
sdr::Buffer< CSScalar >
sdr::Config::hasBufferSize
bool hasBufferSize() const
If true, the configuration has a buffer size.
Definition: node.hh:81
sdr::Config::sampleRate
double sampleRate() const
Returns the sample rate.
Definition: node.hh:77
sdr::IQBaseBand::setFilterWidth
void setFilterWidth(double width)
Sets the filter width.
Definition: baseband.hh:98
sdr::BaseBand::config
virtual void config(const Config &src_cfg)
Configures the base band node.
Definition: baseband.hh:360