From 0ce4068061f6b8420a57890d61e282d99def2d4d Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Sun, 6 Jul 2025 12:58:58 +0200 Subject: [PATCH] average both synchronization symbols for a better channel estimate --- decode.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/decode.cc b/decode.cc index 99a1494..c35d2ea 100644 --- a/decode.cc +++ b/decode.cc @@ -163,6 +163,11 @@ struct Decoder : Common std::cerr << "coarse cfo: " << cfo_rad * (rate / Const::TwoPi()) << " Hz " << std::endl; osc.omega(-cfo_rad); + for (int i = 0; i < symbol_len; ++i) + tdom[i] = buf[i+symbol_pos] * osc(); + fwd(fdom, tdom); + for (int i = 0; i < tone_count; ++i) + chan[i] = fdom[bin(i+tone_off)]; for (int i = 0; i < symbol_len; ++i) tdom[i] = buf[i+symbol_pos+symbol_len] * osc(); for (int i = 0; i < guard_len; ++i) @@ -170,6 +175,17 @@ struct Decoder : Common fwd(fdom, tdom); for (int i = 0; i < tone_count; ++i) tone[i] = fdom[bin(i+tone_off)]; + for (int i = 0; i < tone_count; ++i) { + index[i] = tone_off + i; + phase[i] = arg(demod_or_erase(tone[i], chan[i])); + } + tse.compute(index, phase, tone_count); + //std::cerr << "Theil-Sen slope = " << tse.slope() << std::endl; + //std::cerr << "Theil-Sen yint = " << tse.yint() << std::endl; + for (int i = 0; i < tone_count; ++i) + chan[i] *= DSP::polar(1, tse(i+tone_off)); + for (int i = pilot_off; i < tone_count; i += block_length) + chan[i] = DSP::lerp(chan[i], tone[i], value(0.5)); CODE::MLS seq0(mls0_poly, mls0_seed); for (int i = 0; i < tone_count; ++i) chan[i] = nrz(seq0()) * tone[i];