libsdr  0.1.0
A simple SDR library
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
sdr::BaseBand< Scalar > Class Template Reference

This class performs several operations on the real input stream, It first filters out some part of the input stream using a FIR band pass filter then shifts the center frequency to 0 and finally sub-samples the resulting stream such that the selected base-band is well represented. More...

#include <baseband.hh>

Inheritance diagram for sdr::BaseBand< Scalar >:
sdr::Sink< Scalar > sdr::Source sdr::FreqShiftBase< Scalar > sdr::SinkBase

Public Types

typedef FreqShiftBase< Scalar >::CScalar CScalar
 The complex input scalar. More...
 
typedef FreqShiftBase< Scalar >::SScalar SScalar
 The real super scalar. More...
 
typedef FreqShiftBase< Scalar >::CSScalar CSScalar
 The complex super scalar. 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< SScalarCSScalar
 The complex compute (super) scalar of the input type. More...
 

Public Member Functions

 BaseBand (double Fc, double width, size_t order, size_t sub_sample)
 Constructs a new BaseBand instance. More...
 
 BaseBand (double Fc, double Ff, double width, size_t order, size_t sub_sample)
 Constructs a new BaseBand instance. More...
 
virtual ~BaseBand ()
 Destructor. More...
 
virtual void config (const Config &src_cfg)
 Configures the base band node. More...
 
virtual void setSampleRate (double Fs)
 Sets the sample rate and updates the LUT. More...
 
virtual void process (const Buffer< Scalar > &buffer, bool allow_overwrite)
 Processes the input buffer. More...
 
- Public Member Functions inherited from sdr::Sink< 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...
 
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 _process (const Buffer< Scalar > &in, const Buffer< CScalar > &out)
 Performs the actual procssing. More...
 
CSScalar _filter_ring ()
 Applies the filter on the data stored in the ring buffer. More...
 
void _update_filter_kernel ()
 Calculates or updates the 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

double _Ff
 The center frequency of the band pass filter. More...
 
double _width
 The width of the band pass filter. More...
 
size_t _order
 The order of the band pass filter. More...
 
size_t _sub_sample
 The number of averages taken for subsampling. More...
 
size_t _ring_offset
 The current index of the ring buffer. More...
 
size_t _sample_count
 The current number of averages. More...
 
CSScalar _last
 The current sum of the last _sample_count samples. More...
 
bool _shift_freq
 If true, Fc!=0. More...
 
Buffer< CSScalar_lut
 $\exp(i\phi)$ look-up table
 
size_t _lut_inc
 The LUT index increment per (1<<4) samples. More...
 
size_t _lut_count
 The current LUT index times (1<<4). More...
 
Buffer< CSScalar_kernel
 The filter kernel of order _order. More...
 
Buffer< SScalar_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...
 

Static Protected Attributes

static const size_t _lut_size =128
 Size of the look-up table. More...
 
- 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::BaseBand< Scalar >

This class performs several operations on the real input stream, It first filters out some part of the input stream using a FIR band pass filter then shifts the center frequency to 0 and finally sub-samples the resulting stream such that the selected base-band is well represented.

Member Typedef Documentation

template<class Scalar >
typedef FreqShiftBase<Scalar>::CScalar sdr::BaseBand< Scalar >::CScalar

The complex input scalar.

template<class Scalar >
typedef FreqShiftBase<Scalar>::CSScalar sdr::BaseBand< Scalar >::CSScalar

The complex super scalar.

template<class Scalar >
typedef FreqShiftBase<Scalar>::SScalar sdr::BaseBand< Scalar >::SScalar

The real super scalar.

Constructor & Destructor Documentation

template<class Scalar >
sdr::BaseBand< Scalar >::BaseBand ( double  Fc,
double  width,
size_t  order,
size_t  sub_sample 
)
inline

Constructs a new BaseBand instance.

Parameters
FcSpecifies the center frequency of the base band. The resulting signal will be shifted down by this frequency.
widthSpecifies the with of the band pass filter.
orderSpecifies the order of the FIR band pass filter.
sub_sampleSpecifies the sub-sampling of the resulting singnal.
template<class Scalar >
sdr::BaseBand< Scalar >::BaseBand ( double  Fc,
double  Ff,
double  width,
size_t  order,
size_t  sub_sample 
)
inline

Constructs a new BaseBand instance.

Parameters
FcSpecifies the frequency of the base band. The resulting signal will be shifted down by this frequency.
FfSpecifies the center frequency of the band pass filter.
widthSpecifies the with of the band pass filter.
orderSpecifies the order of the FIR band pass filter.
sub_sampleSpecifies the sub-sampling of the resulting singnal.
template<class Scalar >
virtual sdr::BaseBand< Scalar >::~BaseBand ( )
inlinevirtual

Destructor.

Member Function Documentation

template<class Scalar >
CSScalar sdr::BaseBand< Scalar >::_filter_ring ( )
inlineprotected

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

template<class Scalar >
void sdr::BaseBand< Scalar >::_process ( const Buffer< Scalar > &  in,
const Buffer< CScalar > &  out 
)
inlineprotected

Performs the actual procssing.

First, the bandpass filter is applied, then the filtered signal is shifted and finally the signal gets averaged over _sub_sample samples, implementing the averaging sub-sampling.

template<class Scalar >
void sdr::BaseBand< Scalar >::_update_filter_kernel ( )
inlineprotected

Calculates or updates the filter kernel.

template<class Scalar >
virtual void sdr::BaseBand< Scalar >::config ( const Config src_cfg)
inlinevirtual

Configures the base band node.

Implements the Sink interface.

Implements sdr::SinkBase.

template<class Scalar >
virtual void sdr::BaseBand< Scalar >::process ( const Buffer< Scalar > &  buffer,
bool  allow_overwrite 
)
inlinevirtual

Processes the input buffer.

Implements the Sink interface.

Implements sdr::Sink< Scalar >.

template<class Scalar >
virtual void sdr::BaseBand< Scalar >::setSampleRate ( double  Fs)
inlinevirtual

Sets the sample rate and updates the LUT.

Bug:
Also signal config change of the sourcce by setConfig()!

Reimplemented from sdr::FreqShiftBase< Scalar >.

Member Data Documentation

template<class Scalar >
Buffer<CScalar> sdr::BaseBand< Scalar >::_buffer
protected

The output buffer.

template<class Scalar >
double sdr::BaseBand< Scalar >::_Ff
protected

The center frequency of the band pass filter.

template<class Scalar >
Buffer<CSScalar> sdr::BaseBand< Scalar >::_kernel
protected

The filter kernel of order _order.

template<class Scalar >
CSScalar sdr::BaseBand< Scalar >::_last
protected

The current sum of the last _sample_count samples.

template<class Scalar >
size_t sdr::BaseBand< Scalar >::_lut_count
protected

The current LUT index times (1<<4).

template<class Scalar >
size_t sdr::BaseBand< Scalar >::_lut_inc
protected

The LUT index increment per (1<<4) samples.

template<class Scalar >
const size_t sdr::BaseBand< Scalar >::_lut_size =128
staticprotected

Size of the look-up table.

template<class Scalar >
size_t sdr::BaseBand< Scalar >::_order
protected

The order of the band pass filter.

template<class Scalar >
Buffer<SScalar> sdr::BaseBand< Scalar >::_ring
protected

A ring buffer of past values.

template<class Scalar >
size_t sdr::BaseBand< Scalar >::_ring_offset
protected

The current index of the ring buffer.

template<class Scalar >
size_t sdr::BaseBand< Scalar >::_sample_count
protected

The current number of averages.

template<class Scalar >
bool sdr::BaseBand< Scalar >::_shift_freq
protected

If true, Fc!=0.

template<class Scalar >
size_t sdr::BaseBand< Scalar >::_sub_sample
protected

The number of averages taken for subsampling.

template<class Scalar >
double sdr::BaseBand< Scalar >::_width
protected

The width of the band pass filter.


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