summaryrefslogtreecommitdiff
path: root/gr-digital/lib/symbol_sync_ff_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital/lib/symbol_sync_ff_impl.cc')
-rw-r--r--gr-digital/lib/symbol_sync_ff_impl.cc72
1 files changed, 33 insertions, 39 deletions
diff --git a/gr-digital/lib/symbol_sync_ff_impl.cc b/gr-digital/lib/symbol_sync_ff_impl.cc
index 82493f565c..1df9a437c4 100644
--- a/gr-digital/lib/symbol_sync_ff_impl.cc
+++ b/gr-digital/lib/symbol_sync_ff_impl.cc
@@ -47,21 +47,28 @@ symbol_sync_ff::sptr symbol_sync_ff::make(enum ted_type detector_type,
}
symbol_sync_ff_impl::symbol_sync_ff_impl(enum ted_type detector_type,
- float sps,
- float loop_bw,
- float damping_factor,
- float ted_gain,
- float max_deviation,
- int osps,
+ const float sps,
+ const float loop_bw,
+ const float damping_factor,
+ const float ted_gain,
+ const float max_deviation,
+ const int osps,
constellation_sptr slicer,
- ir_type interp_type,
- int n_filters,
+ const ir_type interp_type,
+ const int n_filters,
const std::vector<float>& taps)
: block("symbol_sync_ff",
io_signature::make(1, 1, sizeof(float)),
io_signature::makev(1, 4, std::vector<int>(4, sizeof(float)))),
- d_ted(NULL),
- d_interp(NULL),
+ d_ted(timing_error_detector::make(detector_type, slicer)),
+ d_clock(loop_bw,
+ sps + max_deviation,
+ sps - max_deviation,
+ sps,
+ damping_factor,
+ ted_gain),
+ d_interp(interpolating_resampler_fff::make(
+ interp_type, d_ted->needs_derivative(), n_filters, taps)),
d_inst_output_period(sps / static_cast<float>(osps)),
d_inst_clock_period(sps),
d_avg_clock_period(sps),
@@ -85,15 +92,11 @@ symbol_sync_ff_impl::symbol_sync_ff_impl(enum ted_type detector_type,
if (osps < 1)
throw std::out_of_range("output samples per symbol must be > 0");
- // Timing Error Detector
- d_ted = timing_error_detector::make(detector_type, slicer);
- if (d_ted == NULL)
+ if (d_ted == nullptr)
throw std::runtime_error("unable to create timing_error_detector");
// Interpolating Resampler
- d_interp = interpolating_resampler_fff::make(
- interp_type, d_ted->needs_derivative(), n_filters, taps);
- if (d_interp == NULL)
+ if (d_interp == nullptr)
throw std::runtime_error("unable to create interpolating_resampler_fff");
// Block Internal Clocks
@@ -116,10 +119,6 @@ symbol_sync_ff_impl::symbol_sync_ff_impl(enum ted_type detector_type,
"increasing sps") %
d_interps_per_symbol % sps);
- // Symbol Clock Tracking and Estimation
- d_clock = new clock_tracking_loop(
- loop_bw, sps + max_deviation, sps - max_deviation, sps, damping_factor, ted_gain);
-
// Timing Error Detector
d_ted->sync_reset();
@@ -134,12 +133,7 @@ symbol_sync_ff_impl::symbol_sync_ff_impl(enum ted_type detector_type,
set_output_multiple(d_osps_n);
}
-symbol_sync_ff_impl::~symbol_sync_ff_impl()
-{
- delete d_ted;
- delete d_interp;
- delete d_clock;
-}
+symbol_sync_ff_impl::~symbol_sync_ff_impl() {}
//
// Block Internal Clocks
@@ -225,7 +219,7 @@ bool symbol_sync_ff_impl::find_sync_tag(uint64_t nitems_rd,
// got a time_est tag
timing_offset = static_cast<float>(pmt::to_double(t->value));
// next instantaneous clock period estimate will be nominal
- clock_period = d_clock->get_nom_avg_period();
+ clock_period = d_clock.get_nom_avg_period();
// Look for a clock_est tag at the same offset,
// as we prefer clock_est tags
@@ -380,11 +374,11 @@ void symbol_sync_ff_impl::forecast(int noutput_items,
// least one output sample, even if the main loop decides it has to
// revert one computed sample and wait for the next call to
// general_work().
- // The d_clock->get_max_avg_period() is also an effort to do the same,
+ // The d_clock.get_max_avg_period() is also an effort to do the same,
// in case we have the worst case allowable clock timing deviation on
// input.
const int answer = static_cast<int>(ceilf(static_cast<float>(noutput_items + 2) *
- d_clock->get_max_avg_period() / d_osps)) +
+ d_clock.get_max_avg_period() / d_osps)) +
static_cast<int>(d_interp->ntaps());
for (unsigned i = 0; i < ninputs; i++)
@@ -447,7 +441,7 @@ int symbol_sync_ff_impl::general_work(int noutput_items,
// We must interpolate ahead to the *next* ted_input_clock, so the
// ted will compute the error for *this* symbol.
d_interp->next_phase(d_interps_per_ted_input *
- (d_clock->get_inst_period() / d_interps_per_symbol),
+ (d_clock.get_inst_period() / d_interps_per_symbol),
look_ahead_phase,
look_ahead_phase_n,
look_ahead_phase_wrapped);
@@ -483,10 +477,10 @@ int symbol_sync_ff_impl::general_work(int noutput_items,
if (symbol_clock()) {
// Symbol Clock Tracking and Estimation
- d_clock->advance_loop(error);
- d_inst_clock_period = d_clock->get_inst_period();
- d_avg_clock_period = d_clock->get_avg_period();
- d_clock->phase_wrap();
+ d_clock.advance_loop(error);
+ d_inst_clock_period = d_clock.get_inst_period();
+ d_avg_clock_period = d_clock.get_avg_period();
+ d_clock.phase_wrap();
// Symbol Clock and Interpolator Positioning & Alignment
d_inst_interp_period = d_inst_clock_period / d_interps_per_symbol;
@@ -517,7 +511,7 @@ int symbol_sync_ff_impl::general_work(int noutput_items,
// Revert the actions we took in the loop so far, and bail out.
// Symbol Clock Tracking and Estimation
- d_clock->revert_loop();
+ d_clock.revert_loop();
// Timing Error Detector
d_ted->revert();
@@ -561,10 +555,10 @@ int symbol_sync_ff_impl::general_work(int noutput_items,
1) +
sync_timing_offset - d_interp->phase_wrapped();
- d_clock->set_inst_period(d_inst_clock_period);
- d_clock->set_avg_period(sync_clock_period);
- d_avg_clock_period = d_clock->get_avg_period();
- d_clock->set_phase(0.0f);
+ d_clock.set_inst_period(d_inst_clock_period);
+ d_clock.set_avg_period(sync_clock_period);
+ d_avg_clock_period = d_clock.get_avg_period();
+ d_clock.set_phase(0.0f);
// Symbol Clock and Interpolator Positioning & Alignment
d_inst_interp_period = d_inst_clock_period;