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

Performs a frequency shift on a complex input signal, by multiplying it with $e^{i\omega t}$. More...

#include <utils.hh>

Inheritance diagram for sdr::FreqShift< Scalar >:
sdr::Sink< std::complex< Scalar > > sdr::Source sdr::SinkBase

Public Member Functions

 FreqShift (double shift, Scalar scale=1.0)
 Constructs a frequency shift node with optional scaleing of the result. More...
 
virtual ~FreqShift ()
 Destructor. More...
 
double shift () const
 Returns the frequency shift. More...
 
void setShift (double shift)
 Sets the frequency shift. More...
 
virtual void config (const Config &src_cfg)
 Configures the frequency shift node. More...
 
virtual void process (const Buffer< std::complex< Scalar > > &buffer, bool allow_overwrite)
 Performs the frequency shift. 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...
 

Protected Attributes

Buffer< std::complex< Scalar > > _buffer
 The output buffer. More...
 
double _shift
 The frequency shift $f$ in Hz ( $\omega=2\pi f$). More...
 
Scalar _scale
 The optional scale. More...
 
std::complex< double > _factor
 The current exponental factor, gets updated for every sample. More...
 
double _sample_rate
 The current sample rate. More...
 
std::complex< double > _delta
 $\exp(i\omega t)$. 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...
 

Additional Inherited Members

- 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...
 

Detailed Description

template<class Scalar>
class sdr::FreqShift< Scalar >

Performs a frequency shift on a complex input signal, by multiplying it with $e^{i\omega t}$.

Please note, this node performs not optimal in cases, where the input scalar is an integer, as the computation is performed using double precision floating point numbers.

Deprecated:
Implement a more efficient variant using FreqShiftBase.

Constructor & Destructor Documentation

template<class Scalar >
sdr::FreqShift< Scalar >::FreqShift ( double  shift,
Scalar  scale = 1.0 
)
inline

Constructs a frequency shift node with optional scaleing of the result.

template<class Scalar >
virtual sdr::FreqShift< Scalar >::~FreqShift ( )
inlinevirtual

Destructor.

Member Function Documentation

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

Configures the frequency shift node.

Implements sdr::SinkBase.

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

Performs the frequency shift.

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

template<class Scalar >
void sdr::FreqShift< Scalar >::setShift ( double  shift)
inline

Sets the frequency shift.

template<class Scalar >
double sdr::FreqShift< Scalar >::shift ( ) const
inline

Returns the frequency shift.

Member Data Documentation

template<class Scalar >
Buffer< std::complex<Scalar> > sdr::FreqShift< Scalar >::_buffer
protected

The output buffer.

template<class Scalar >
std::complex<double> sdr::FreqShift< Scalar >::_delta
protected

$\exp(i\omega t)$.

template<class Scalar >
std::complex<double> sdr::FreqShift< Scalar >::_factor
protected

The current exponental factor, gets updated for every sample.

template<class Scalar >
double sdr::FreqShift< Scalar >::_sample_rate
protected

The current sample rate.

template<class Scalar >
Scalar sdr::FreqShift< Scalar >::_scale
protected

The optional scale.

template<class Scalar >
double sdr::FreqShift< Scalar >::_shift
protected

The frequency shift $f$ in Hz ( $\omega=2\pi f$).


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