72 template<
class T1,
class T2,
class T3>
251 template<
class T1,
class T2,
class T3>
256 upsampling_factor = 0;
260 template<
class T1,
class T2,
class T3>
263 set_pulse_shape(impulse_response, upsampling_factor);
266 template<
class T1,
class T2,
class T3>
269 it_error_if(impulse_response_in.
size() == 0,
"Pulse_Shape: impulse response is zero length");
270 it_error_if(upsampling_factor_in < 1,
"Pulse_Shape: incorrect upsampling factor");
272 pulse_length = (impulse_response_in.
size() - 1) / upsampling_factor_in;
273 upsampling_factor = upsampling_factor_in;
275 impulse_response = impulse_response_in;
276 shaping_filter.set_coeffs(impulse_response);
277 shaping_filter.
clear();
281 template<
class T1,
class T2,
class T3>
284 return impulse_response;
287 template<
class T1,
class T2,
class T3>
290 return upsampling_factor;
293 template<
class T1,
class T2,
class T3>
299 template<
class T1,
class T2,
class T3>
302 return impulse_response.size();
305 template<
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));
318 template<
class T1,
class T2,
class T3>
321 it_assert(setup_done,
"Pulse_Shape must be set up before using");
323 shape_symbols(input, temp);
327 template<
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);
340 template<
class T1,
class T2,
class T3>
343 it_assert(setup_done,
"Pulse_Shape must be set up before using");
345 shape_samples(input, temp);
349 template<
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);
367 it_error_if(roll_off_factor_in < 0 || roll_off_factor_in > 1,
"Raised_Cosine: roll-off out of range");
368 roll_off_factor = roll_off_factor_in;
374 this->upsampling_factor = upsampling_factor_in;
375 this->pulse_length = filter_length;
376 this->impulse_response.set_size(filter_length * upsampling_factor_in + 1,
379 for (i = 0; i < this->impulse_response.size(); i++) {
381 t = (double)(i - filter_length * upsampling_factor_in / 2)
382 / upsampling_factor_in;
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);
425 it_error_if(roll_off_factor_in <= 0 || roll_off_factor_in > 1,
426 "Root_Raised_Cosine: roll-off out of range");
427 roll_off_factor = roll_off_factor_in;
430 "Root_Raised_Cosine: Filter length not even");
433 double t, num, den, tmp_arg;
434 this->upsampling_factor = upsampling_factor_in;
435 this->pulse_length = filter_length;
436 this->impulse_response.set_size(filter_length * upsampling_factor_in + 1,
439 for (i = 0; i < this->impulse_response.size(); i++) {
441 t = (double)(i - filter_length * upsampling_factor_in / 2)
442 / upsampling_factor_in;
443 den = 1 -
sqr(4 * roll_off_factor * t);
445 this->impulse_response(i) = 1 + (4 * roll_off_factor /
pi)
449 tmp_arg =
pi / (4 * roll_off_factor);
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);
460 this->impulse_response /=
std::sqrt(
double(upsampling_factor_in));
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> >;
495 #endif // #ifndef PULSE_SHAPE_H