sdr::IQBaseBand< Scalar > Class Template Reference
Filter and signal processing nodes.

This class performs several operations on the complex (integral) input stream, it first filters out some part of the input stream using a FIR band pass (band pass is centerred around `Ff` with width `width`) then shifts the center frequency `Fc` to 0 and finally sub-samples the resulting stream. More...

`#include <baseband.hh>`

Inheritance diagram for sdr::IQBaseBand< Scalar >:

## Public Types

typedef std::complex< Scalar > | CScalar
| The complex type of the input stream. More...
typedef int32_t | SScalar
| The (real) computation scalar type (super scalar), the computations are performed with this scalar type. More...
typedef std::complex< SScalar > | CSScalar
| Complex `SScalar` type. More...
Public Types inherited from sdr::FreqShiftBase< Scalar >
typedef std::complex< Scalar > | CScalar
| The complex input signal. More...
typedef Traits< Scalar >::SScalar | SScalar
| The compute (super) scalar of the input type. More...
typedef std::complex< SScalar > | CSScalar
| The complex compute (super) scalar of the input type. More...

## Public Member Functions

| 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`. More...
| IQBaseBand (double Fc, double Ff, double width, size_t order, size_t sub_sample, double oFs=0.0)
| Constructor. More...
virtual | ~IQBaseBand ()
| Destructor. More...
size_t | order () const
| Returns the order of the band-pass filter. More...
void | setOrder (size_t o)
| (Re-) Sets the filter order. More...
double | centerFrequency () const
| Returns the center frequency. More...
void | setCenterFrequency (double Fc)
| Resets the center frequency. More...
double | filterFrequency () const
| Returns the filter frequency. More...
void | setFilterFrequency (double Ff)
| (Re-) Sets the filter frequency. More...
double | filterWidth () const
| Returns the filter width. More...
void | setFilterWidth (double width)
| Sets the filter width. More...
size_t | subSample () const
| Returns the sub sampling. More...
void | setSubsample (size_t sub_sample)
| Resets the sub sampling. More...
void | setOutputSampleRate (double Fs)
| Resets the output sample rate. More...
virtual void | config (const Config &src_cfg)
| Configures the BaseBand node. More...
virtual void | process (const Buffer< std::complex< Scalar > > &buffer, bool allow_overwrite)
| Processes the given buffer. More...
Public Member Functions inherited from sdr::Sink< std::complex< Scalar > >
| Sink ()
| Constructor. More...
virtual | ~Sink ()
| Drestructor. More...
virtual void | handleBuffer (const RawBuffer &buffer, bool allow_overwrite)
| Re-implemented from `SinkBase`. More...
Public Member Functions inherited from sdr::SinkBase
| SinkBase ()
| Constructor. More...
virtual | ~SinkBase ()
| Destructor. More...
Public Member Functions inherited from sdr::Source
| Source ()
| Constructor. More...
virtual | ~Source ()
| Destructor. More...
virtual void | send (const RawBuffer &buffer, bool allow_overwrite=false)
| Sends the given buffer to all connected sinks. More...
void | connect (SinkBase *sink, bool direct=false)
| Connect this source to a sink. More...
void | disconnect (SinkBase *sink)
| Disconnect a sink again. More...
virtual void | setConfig (const Config &config)
| Stores the configuration and propergates it if the configuration has been changed. More...
virtual double | sampleRate () const
| Returns the configured sample rate or `0` otherwise. More...
virtual Config::Type | type () const
| Returns the configured source type or `Config::Type_UNDEFINED` otherwise. More...
template<class T >
void | addEOS (T *instance, void(T::*function)())
| Adds a callback to the end-of-stream signal of the source. More...
Public Member Functions inherited from sdr::FreqShiftBase< Scalar >
| FreqShiftBase (double F, double Fs)
| Constructor. More...
virtual | ~FreqShiftBase ()
| Destructor. More...
double | sampleRate () const
| Returns the sample rate. More...
virtual void | setSampleRate (double Fs)
| Sets the sample rate and updates the LUT. More...
double | frequencyShift () const
| Returns the frequency shift. More...
virtual void | setFrequencyShift (double F)
| Sets the frequency shift and updates the LUT. More...
CSScalar | applyFrequencyShift (CSScalar value)
| Performs the frequency shift on a single sample. More...

## Protected Member Functions

void | _reconfigure ()
| Reconfigures the node. More...
void | _process (const Buffer< CScalar > &in, const Buffer< CScalar > &out)
| Performs the base-band selection, frequency shift and sub-sampling. More...
CSScalar | _filter_ring () const
| Applies the filter on the data stored in the ring buffer. More...
void | _update_filter_kernel ()
| Updates the band-pass filter kernel. More...
Protected Member Functions inherited from sdr::Source
void | signalEOS ()
| Signals the EOS. More...
void | propagateConfig (const Config &config)
| Propagates the given configuration to all connected sinks. More...
Protected Member Functions inherited from sdr::FreqShiftBase< Scalar >
void | _update_lut_incr ()
| Updates the multiplier LUT. More...

## Protected Attributes

int32_t | _Fc
| The frequency shift of the base band. More...
int32_t | _Ff
| The center frequency of the base band. More...
int32_t | _Fs
| The input sample rate. More...
int32_t | _width
| The filter width. More...
size_t | _order
| The order of the filter. More...
size_t | _sub_sample
| The number of sample averages for the sub sampling. More...
double | _oFs
| Holds the desired output sample rate, _sub_sample will be adjusted accordingly. More...
size_t | _ring_offset
| The current index of the ring buffer. More...
size_t | _sample_count
| Holds the current number of samples averaged. More...
CSScalar | _last
| Holds the current sum of the last `_sample_count` samples. More...
size_t | _sourceBs
| Buffer size of the source. More...
Buffer< CSScalar > | _kernel
| The filter kernel of order _order. More...
Buffer< CSScalar > | _ring
| A ring buffer of past values. More...
Buffer< CScalar > | _buffer
| The output buffer. More...
Protected Attributes inherited from sdr::Source
Config | _config
| Holds the source configuration, this can be updated by calling `setConfig`. More...
std::map< SinkBase *, bool > | _sinks
| The connected sinks. More...
std::list< DelegateInterface * > | _eos
| The connected EOS singal handlers. More...
Protected Attributes inherited from sdr::FreqShiftBase< Scalar >
double | _freq_shift
| The current frequency shift. More...
double | _Fs
| The current sample rate. More...
size_t | _lut_inc
| The LUT increment. More...
size_t | _lut_count
| The LUT index counter. More...
Buffer< CSScalar > | _lut
| The LUT. More...

## Additional Inherited Members

Static Protected Attributes inherited from sdr::FreqShiftBase< Scalar >
static const size_t | _lut_size = 128
| The size of the LUT. More...

## Detailed Description

### template<class Scalar>
class sdr::IQBaseBand< Scalar >

This class performs several operations on the complex (integral) input stream, it first filters out some part of the input stream using a FIR band pass (band pass is centerred around `Ff` with width `width`) then shifts the center frequency `Fc` to 0 and finally sub-samples the resulting stream.

This node can be used to select a portion of the input spectrum and for the reduction of the stream rate, allowing for some more expensive operations to be performed on the output stream.

## Member Typedef Documentation

template<class Scalar >

typedef std::complex<Scalar> sdr::IQBaseBand< Scalar >::CScalar

The complex type of the input stream.

template<class Scalar >

typedef std::complex<SScalar> sdr::IQBaseBand< Scalar >::CSScalar

Complex `SScalar` type.

template<class Scalar >

typedef int32_t sdr::IQBaseBand< Scalar >::SScalar

The (real) computation scalar type (super scalar), the computations are performed with this scalar type.

## Constructor & Destructor Documentation

template<class Scalar >

sdr::IQBaseBand< Scalar >::IQBaseBand | ( | double | Fc,
|  | double | width,
|  | size_t | order,
|  | size_t | sub_sample,
|  | double | oFs = `0.0`
| ) |  |

inline

Constructor, the filter center frequency `Ff` equals the given center frequency `Fc`.

template<class Scalar >

sdr::IQBaseBand< Scalar >::IQBaseBand | ( | double | Fc,
|  | double | Ff,
|  | double | width,
|  | size_t | order,
|  | size_t | sub_sample,
|  | double | oFs = `0.0`
| ) |  |

inline

Constructor.

template<class Scalar >

virtual sdr::IQBaseBand< Scalar >::~IQBaseBand | ( |  | ) |

inlinevirtual

Destructor.

## Member Function Documentation

template<class Scalar >

CSScalar sdr::IQBaseBand< Scalar >::_filter_ring | ( |  | ) | const

inlineprotected

Applies the filter on the data stored in the ring buffer.

template<class Scalar >

void sdr::IQBaseBand< Scalar >::_process | ( | const Buffer< CScalar > & | in,
|  | const Buffer< CScalar > & | out
| ) |  |

inlineprotected

Performs the base-band selection, frequency shift and sub-sampling.

Stores the results into `out`. The input and output buffer may overlapp.

template<class Scalar >

void sdr::IQBaseBand< Scalar >::_reconfigure | ( |  | ) |

inlineprotected

Reconfigures the node.

template<class Scalar >

void sdr::IQBaseBand< Scalar >::_update_filter_kernel | ( |  | ) |

inlineprotected

Updates the band-pass filter kernel.

template<class Scalar >

double sdr::IQBaseBand< Scalar >::centerFrequency | ( |  | ) | const

inline

Returns the center frequency.

template<class Scalar >

virtual void sdr::IQBaseBand< Scalar >::config | ( | const Config & | src_cfg | ) |

inlinevirtual

Configures the BaseBand node.

Implements sdr::SinkBase.

template<class Scalar >

double sdr::IQBaseBand< Scalar >::filterFrequency | ( |  | ) | const

inline

Returns the filter frequency.

template<class Scalar >

double sdr::IQBaseBand< Scalar >::filterWidth | ( |  | ) | const

inline

Returns the filter width.

template<class Scalar >

size_t sdr::IQBaseBand< Scalar >::order | ( |  | ) | const

inline

Returns the order of the band-pass filter.

template<class Scalar >

virtual void sdr::IQBaseBand< Scalar >::process | ( | const Buffer< std::complex< Scalar > > & | buffer,
|  | bool | allow_overwrite
| ) |  |

inlinevirtual

Processes the given buffer.

Implements sdr::Sink< std::complex< Scalar > >.

template<class Scalar >

void sdr::IQBaseBand< Scalar >::setCenterFrequency | ( | double | Fc | ) |

inline

Resets the center frequency.

template<class Scalar >

void sdr::IQBaseBand< Scalar >::setFilterFrequency | ( | double | Ff | ) |

inline

(Re-) Sets the filter frequency.

template<class Scalar >

void sdr::IQBaseBand< Scalar >::setFilterWidth | ( | double | width | ) |

inline

Sets the filter width.

template<class Scalar >

void sdr::IQBaseBand< Scalar >::setOrder | ( | size_t | o | ) |

inline

(Re-) Sets the filter order.

template<class Scalar >

void sdr::IQBaseBand< Scalar >::setOutputSampleRate | ( | double | Fs | ) |

inline

Resets the output sample rate.

The sub-sampling will be adjusted accordingly. Please note the the resulting output sample rate will be rounded up to be an integral fraction of the input sample rate.

template<class Scalar >

void sdr::IQBaseBand< Scalar >::setSubsample | ( | size_t | sub_sample | ) |

inline

Resets the sub sampling.

Please note that the Queue needs to be stopped before calling this function!

template<class Scalar >

size_t sdr::IQBaseBand< Scalar >::subSample | ( |  | ) | const

inline

Returns the sub sampling.

## Member Data Documentation

template<class Scalar >

Buffer<CScalar> sdr::IQBaseBand< Scalar >::_buffer

protected

The output buffer.

template<class Scalar >

int32_t sdr::IQBaseBand< Scalar >::_Fc

protected

The frequency shift of the base band.

The filter result will be shifted by `-_Fc`.

template<class Scalar >

int32_t sdr::IQBaseBand< Scalar >::_Ff

protected

The center frequency of the base band.

template<class Scalar >

int32_t sdr::IQBaseBand< Scalar >::_Fs

protected

The input sample rate.

template<class Scalar >

Buffer<CSScalar> sdr::IQBaseBand< Scalar >::_kernel

protected

The filter kernel of order _order.

template<class Scalar >

CSScalar sdr::IQBaseBand< Scalar >::_last

protected

Holds the current sum of the last `_sample_count` samples.

template<class Scalar >

double sdr::IQBaseBand< Scalar >::_oFs

protected

Holds the desired output sample rate, _sub_sample will be adjusted accordingly.

template<class Scalar >

size_t sdr::IQBaseBand< Scalar >::_order

protected

The order of the filter.

Must be greater that 0.

template<class Scalar >

Buffer<CSScalar> sdr::IQBaseBand< Scalar >::_ring

protected

A ring buffer of past values.

The band-pass filtering is performed on this buffer.

template<class Scalar >

size_t sdr::IQBaseBand< Scalar >::_ring_offset

protected

The current index of the ring buffer.

template<class Scalar >

size_t sdr::IQBaseBand< Scalar >::_sample_count

protected

Holds the current number of samples averaged.

template<class Scalar >

size_t sdr::IQBaseBand< Scalar >::_sourceBs

protected

Buffer size of the source.

template<class Scalar >

size_t sdr::IQBaseBand< Scalar >::_sub_sample

protected

The number of sample averages for the sub sampling.

`_sub_sample==1` means no subsampling.

template<class Scalar >

int32_t sdr::IQBaseBand< Scalar >::_width

protected

The filter width.

The documentation for this class was generated from the following file:

- /Users/hannes/Uni/Elektronik/sdr/libsdr/src/baseband.hh