1 #ifndef __SDR_SIGGEN_HH__
2 #define __SDR_SIGGEN_HH__
11 template <
class Scalar>
16 SigGen(
double samplerate,
size_t buffersize,
double tmax=-1)
20 switch (Config::typeId<Scalar>()) {
35 this->
setConfig(
Config(Config::typeId<Scalar>(), samplerate, buffersize, 1));
49 std::list< std::vector<double> >::iterator item =
_signals.begin();
50 for (; item !=
_signals.end(); item++) {
61 void addSine(
double freq,
double ampl=1,
double phase=0) {
62 std::vector<double> tmp(3); tmp[0] = freq; tmp[1] = ampl; tmp[2] = phase;
89 template <
class Scalar>
94 IQSigGen(
double samplerate,
size_t buffersize,
double tmax=-1)
98 switch (Config::typeId<Scalar>()) {
123 std::list< std::vector<double> >::iterator item =
_signals.begin();
124 for (; item !=
_signals.end(); item++) {
125 _buffer[i] += (
_scale*((*item)[1] * std::exp(std::complex<double>(0, 2*M_PI*(*item)[0]*
_t + (*item)[2])))/
double(
_signals.size()));
135 void addSine(
double freq,
double ampl=1,
double phase=0) {
136 std::vector<double> tmp(3); tmp[0] = freq; tmp[1] = ampl; tmp[2] = phase;
162 #endif // __SDR_SIGGEN_HH__
void addSine(double freq, double ampl=1, double phase=0)
Add a sine function to the function generator.
Definition: siggen.hh:61
Buffer< std::complex< Scalar > > _buffer
The output buffer.
Definition: siggen.hh:156
A collection of configuration information that is send by a source to all connected sinks to properga...
Definition: node.hh:35
std::list< std::vector< double > > _signals
A list of functions.
Definition: siggen.hh:78
size_t _bufferSize
The size of the output buffer.
Definition: siggen.hh:80
virtual ~SigGen()
Destructor.
Definition: siggen.hh:39
double _scale
The scaling of the signal.
Definition: siggen.hh:150
Real signed 16b ints.
Definition: node.hh:44
SigGen(double samplerate, size_t buffersize, double tmax=-1)
Constructs the function generator.
Definition: siggen.hh:16
virtual void send(const RawBuffer &buffer, bool allow_overwrite=false)
Sends the given buffer to all connected sinks.
Definition: node.cc:67
static Queue & get()
Get a reference to the global instance of the queue.
Definition: queue.cc:15
Complex (aka I/Q) type of unsigned 16b ints.
Definition: node.hh:49
Definition: autocast.hh:8
double _dt
The sample period.
Definition: siggen.hh:70
double _sampleRate
The sample rate of the function generator.
Definition: siggen.hh:142
Real signed 8b ints.
Definition: node.hh:42
void stop()
Signals the queue to stop processing.
Definition: queue.cc:64
void addSine(double freq, double ampl=1, double phase=0)
Add a sine function to the function generator.
Definition: siggen.hh:135
Generic source class.
Definition: node.hh:213
Real unsigned 8b ints.
Definition: node.hh:41
size_t _bufferSize
The size of the output buffer.
Definition: siggen.hh:154
double _t
The current time.
Definition: siggen.hh:146
double _scale
The scaling of the signal.
Definition: siggen.hh:76
Real unsigned 16b ints.
Definition: node.hh:43
virtual void setConfig(const Config &config)
Stores the configuration and propergates it if the configuration has been changed.
Definition: node.cc:98
double _dt
The sample period.
Definition: siggen.hh:144
Arbitrary function generator.
Definition: siggen.hh:90
double _tMax
The maximum time.
Definition: siggen.hh:148
double _t
The current time.
Definition: siggen.hh:72
double _sampleRate
The sample rate of the function generator.
Definition: siggen.hh:68
Buffer< Scalar > _buffer
The output buffer.
Definition: siggen.hh:82
static Type typeId()
Returns the type-id of the template type.
virtual ~IQSigGen()
Destructor.
Definition: siggen.hh:113
std::list< std::vector< double > > _signals
A list of functions.
Definition: siggen.hh:152
IQSigGen(double samplerate, size_t buffersize, double tmax=-1)
Constructs the function generator.
Definition: siggen.hh:94
double _tMax
The maximum time.
Definition: siggen.hh:74
void next()
Computes the next buffer.
Definition: siggen.hh:116
Complex (aka I/Q) type of signed 8b ints.
Definition: node.hh:48
Complex (aka I/Q) type of signed 16b ints.
Definition: node.hh:50
Complex (aka I/Q) type of unsigned 8b ints.
Definition: node.hh:47
Arbitrary function generator.
Definition: siggen.hh:12
void next()
Computes the next buffer.
Definition: siggen.hh:42