72template<
class T1,
class T2,
class T3>
251template<
class T1,
class T2,
class T3>
256 upsampling_factor = 0;
260template<
class T1,
class T2,
class T3>
263 set_pulse_shape(impulse_response, upsampling_factor);
266template<
class T1,
class T2,
class T3>
276 shaping_filter.set_coeffs(impulse_response);
277 shaping_filter.clear();
281template<
class T1,
class T2,
class T3>
284 return impulse_response;
287template<
class T1,
class T2,
class T3>
290 return upsampling_factor;
293template<
class T1,
class T2,
class T3>
299template<
class T1,
class T2,
class T3>
302 return impulse_response.
size();
305template<
class T1,
class T2,
class T3>
308 it_assert(setup_done,
"Pulse_Shape must be set up before using");
309 it_error_if(pulse_length == 0,
"Pulse_Shape: impulse response is zero length");
312 if (upsampling_factor > 1)
313 output = shaping_filter(upsample(input, upsampling_factor));
318template<
class T1,
class T2,
class T3>
321 it_assert(setup_done,
"Pulse_Shape must be set up before using");
323 shape_symbols(input,
temp);
327template<
class T1,
class T2,
class T3>
330 it_assert(setup_done,
"Pulse_Shape must be set up before using");
331 it_error_if(pulse_length == 0,
"Pulse_Shape: impulse response is zero length");
334 if (upsampling_factor > 1)
335 output = shaping_filter(input);
340template<
class T1,
class T2,
class T3>
343 it_assert(setup_done,
"Pulse_Shape must be set up before using");
345 shape_samples(input,
temp);
349template<
class T1,
class T2,
class T3>
352 it_assert(setup_done,
"Pulse_Shape must be set up before using");
353 shaping_filter.clear();
361 set_pulse_shape(roll_off_factor, filter_length, upsampling_factor);
375 this->pulse_length = filter_length;
379 for (
i = 0;
i < this->impulse_response.
size();
i++) {
383 den = 1 -
sqr(2 * roll_off_factor * t);
389 this->impulse_response(
i) =
sinc(t) *
pi / 4;
392 this->impulse_response(
i) = std::cos(roll_off_factor *
pi * t)
402 this->shaping_filter.set_coeffs(this->impulse_response);
403 this->shaping_filter.clear();
404 this->setup_done =
true;
410 it_assert(this->setup_done,
"Pulse_Shape must be set up before using");
411 return roll_off_factor;
419 set_pulse_shape(roll_off_factor, filter_length, upsampling_factor);
426 "Root_Raised_Cosine: roll-off out of range");
430 "Root_Raised_Cosine: Filter length not even");
435 this->pulse_length = filter_length;
439 for (
i = 0;
i < this->impulse_response.
size();
i++) {
443 den = 1 -
sqr(4 * roll_off_factor * t);
445 this->impulse_response(
i) = 1 + (4 * roll_off_factor /
pi)
450 this->impulse_response(
i) = roll_off_factor / std::sqrt(2.0)
454 num = std::sin(
pi * (1 - roll_off_factor) * t)
455 + std::cos(
pi * (1 + roll_off_factor) * t) * 4 * roll_off_factor * t;
456 this->impulse_response(
i) =
num / (
pi * t *
den);
461 this->shaping_filter.set_coeffs(this->impulse_response);
462 this->shaping_filter.clear();
463 this->setup_done =
true;
469 it_assert(this->setup_done,
"Pulse_Shape must be set up before using");
470 return roll_off_factor;
481 std::complex<double> >;
483 std::complex<double> >;
int size() const
Returns the number of data elements in the array object.
void set_size(int n, bool copy=false)
Resizing an Array<T>.
Vec< T3 > shape_samples(const Vec< T1 > &input)
Shape the input symbols already upsampled.
Vec< T2 > get_pulse_shape(void) const
Get the pulse shape.
void set_pulse_shape(const Vec< T2 > &impulse_response, int upsampling_factor)
Set the general impulse response of the FIR filter.
int upsampling_factor
Samples per input symbol.
void shape_samples(const Vec< T1 > &input, Vec< T3 > &output)
Shape the input samples already upsampled.
Pulse_Shape()
Constructor.
int get_filter_length() const
Get the length of the internal FIR filter.
int get_upsampling_factor() const
Get the over sampling factor.
void shape_symbols(const Vec< T1 > &input, Vec< T3 > &output)
Shape the input symbols performing upsampling.
MA_Filter< T1, T2, T3 > shaping_filter
The pulse shaping filter.
int get_pulse_length() const
Get the length of the pulse in number of symbols.
virtual ~Pulse_Shape()
Destructor.
Pulse_Shape(const Vec< T2 > &impulse_response, int upsampling_factor)
Constructor.
int pulse_length
Length in symbols.
Vec< T2 > impulse_response
The impulse resounse of the pulse shaping filter.
Vec< T3 > shape_symbols(const Vec< T1 > &input)
Shape the input symbols performing upsampling.
bool setup_done
Ensures that setup is called before any other member function.
void clear(void)
Clear internal states.
Raised Cosine (RC) Pulse Shaper.
Raised_Cosine()
Constructor.
double roll_off_factor
The roll off factor (i.e. alpha)
double get_roll_off(void) const
Get the roll-off factor.
virtual ~Raised_Cosine()
Destructor.
void set_pulse_shape(double roll_off_factor, int filter_length=6, int upsampling_factor=8)
Set pulse shape (roll_off_factor between 0 and 1, filter_length even)
(Square) Root Raised Cosine (RRC) Pulse Shaper
virtual ~Root_Raised_Cosine()
Destructor.
void set_pulse_shape(double roll_off_factor, int filter_length=6, int upsampling_factor=8)
Set pulse_shape, roll_off_factor between 0 and 1, filter_length even.
double roll_off_factor
The roll off factor (i.e. alpha)
double get_roll_off(void) const
Get the Roll-off factor.
Root_Raised_Cosine()
Constructor.
Definitions of Filter classes and functions.
#define it_error_if(t, s)
Abort if t is true.
#define it_assert(t, s)
Abort if t is not true.
bool is_even(int x)
Return true if x is an even integer.
vec sqr(const cvec &data)
Absolute square of elements.
double sinc(double x)
Sinc function: sinc(x) = sin(pi*x)/pi*x.
Various functions on vectors and matrices - header file.
const double pi
Constant Pi.
Resampling functions - header file.
Trigonometric and hyperbolic functions - header file.
Templated Vector Class Definitions.