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

Generic FIR filter class. More...

#include <firfilter.hh>

Inheritance diagram for sdr::FIRFilter< Scalar, FilterCoeffs >:
sdr::Sink< Scalar > sdr::Source sdr::SinkBase

Public Member Functions

 FIRFilter (size_t order, double Fl, double Fu)
 Constructor. More...
 
virtual ~FIRFilter ()
 Destructor. More...
 
bool enabled () const
 Returns true if the filter is enabled. More...
 
void enable (bool enable)
 Enable/Disable the filter. More...
 
size_t order () const
 Returns the order of the filter. More...
 
virtual void setOrder (size_t order)
 Sets the order of the filter and updates the filter coefficients. More...
 
double lowerFreq () const
 Returns the lower edge frequency. More...
 
void setLowerFreq (double Fl)
 Sets the lower edge frequency. More...
 
double uppertFreq () const
 Returns the upper edge frequency. More...
 
void setUpperFreq (double Fu)
 Sets the upper edge frequency. More...
 
virtual void config (const Config &src_cfg)
 Configures the filter. More...
 
virtual void process (const Buffer< Scalar > &buffer, bool allow_overwrite)
 Performs the filtering. 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...
 

Protected Member Functions

void _process (const Buffer< Scalar > &in, const Buffer< Scalar > &out)
 performs the actual computation
 
- 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 Attributes

bool _enabled
 If true, the filtering is enabled. More...
 
size_t _order
 The order of the filter. More...
 
double _Fl
 The lower edge frequency. More...
 
double _Fu
 The upper edge frequency. More...
 
double _Fs
 Current sample rate. More...
 
std::vector< double > _alpha
 The current filter coefficients. More...
 
Buffer< Scalar > _ring
 A "ring-buffer" used to perform the filtering. More...
 
size_t _ring_offset
 Offset of the "ring-buffer". More...
 
Buffer< Scalar > _buffer
 The output buffer, unused if filtering is performed in-place. 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...
 

Detailed Description

template<class Scalar, class FilterCoeffs>
class sdr::FIRFilter< Scalar, FilterCoeffs >

Generic FIR filter class.

Use one of the specializations below for a low-, high- or band-pass filter.

Constructor & Destructor Documentation

template<class Scalar, class FilterCoeffs>
sdr::FIRFilter< Scalar, FilterCoeffs >::FIRFilter ( size_t  order,
double  Fl,
double  Fu 
)
inline

Constructor.

template<class Scalar, class FilterCoeffs>
virtual sdr::FIRFilter< Scalar, FilterCoeffs >::~FIRFilter ( )
inlinevirtual

Destructor.

Member Function Documentation

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

Configures the filter.

Implements sdr::SinkBase.

template<class Scalar, class FilterCoeffs>
void sdr::FIRFilter< Scalar, FilterCoeffs >::enable ( bool  enable)
inline

Enable/Disable the filter.

template<class Scalar, class FilterCoeffs>
bool sdr::FIRFilter< Scalar, FilterCoeffs >::enabled ( ) const
inline

Returns true if the filter is enabled.

template<class Scalar, class FilterCoeffs>
double sdr::FIRFilter< Scalar, FilterCoeffs >::lowerFreq ( ) const
inline

Returns the lower edge frequency.

template<class Scalar, class FilterCoeffs>
size_t sdr::FIRFilter< Scalar, FilterCoeffs >::order ( ) const
inline

Returns the order of the filter.

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

Performs the filtering.

Implements sdr::Sink< Scalar >.

template<class Scalar, class FilterCoeffs>
void sdr::FIRFilter< Scalar, FilterCoeffs >::setLowerFreq ( double  Fl)
inline

Sets the lower edge frequency.

template<class Scalar, class FilterCoeffs>
virtual void sdr::FIRFilter< Scalar, FilterCoeffs >::setOrder ( size_t  order)
inlinevirtual

Sets the order of the filter and updates the filter coefficients.

template<class Scalar, class FilterCoeffs>
void sdr::FIRFilter< Scalar, FilterCoeffs >::setUpperFreq ( double  Fu)
inline

Sets the upper edge frequency.

template<class Scalar, class FilterCoeffs>
double sdr::FIRFilter< Scalar, FilterCoeffs >::uppertFreq ( ) const
inline

Returns the upper edge frequency.

Member Data Documentation

template<class Scalar, class FilterCoeffs>
std::vector<double> sdr::FIRFilter< Scalar, FilterCoeffs >::_alpha
protected

The current filter coefficients.

template<class Scalar, class FilterCoeffs>
Buffer<Scalar> sdr::FIRFilter< Scalar, FilterCoeffs >::_buffer
protected

The output buffer, unused if filtering is performed in-place.

template<class Scalar, class FilterCoeffs>
bool sdr::FIRFilter< Scalar, FilterCoeffs >::_enabled
protected

If true, the filtering is enabled.

template<class Scalar, class FilterCoeffs>
double sdr::FIRFilter< Scalar, FilterCoeffs >::_Fl
protected

The lower edge frequency.

template<class Scalar, class FilterCoeffs>
double sdr::FIRFilter< Scalar, FilterCoeffs >::_Fs
protected

Current sample rate.

template<class Scalar, class FilterCoeffs>
double sdr::FIRFilter< Scalar, FilterCoeffs >::_Fu
protected

The upper edge frequency.

template<class Scalar, class FilterCoeffs>
size_t sdr::FIRFilter< Scalar, FilterCoeffs >::_order
protected

The order of the filter.

template<class Scalar, class FilterCoeffs>
Buffer<Scalar> sdr::FIRFilter< Scalar, FilterCoeffs >::_ring
protected

A "ring-buffer" used to perform the filtering.

template<class Scalar, class FilterCoeffs>
size_t sdr::FIRFilter< Scalar, FilterCoeffs >::_ring_offset
protected

Offset of the "ring-buffer".


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