From ec4e5b66a416c003f80266297e7aa4db7aa6986c Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Thu, 10 Jul 2025 08:04:57 +0200 Subject: [PATCH] made current operation mode accessible --- common.hh | 6 ++++-- decode.cc | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/common.hh b/common.hh index e64f26c..7a1eb4f 100644 --- a/common.hh +++ b/common.hh @@ -36,6 +36,7 @@ struct Common int data_bits; int data_bytes; int code_order; + int oper_mode; int tone_off; int pilot_off; int reserved_off; @@ -44,9 +45,9 @@ struct Common Common() : crc0(0x8F6E37A0) {} - void setup(int oper_mode) + void setup(int mode) { - switch (oper_mode) { + switch (mode) { case 0: mod_bits = 1; symbol_count = 8; @@ -274,6 +275,7 @@ struct Common default: return; } + oper_mode = mode; data_bytes = data_bits / 8; } }; diff --git a/decode.cc b/decode.cc index 559b06c..f84fa5d 100644 --- a/decode.cc +++ b/decode.cc @@ -234,11 +234,12 @@ struct Decoder : Common auto clamp = [](int v){ return v < -127 ? -127 : v > 127 ? 127 : v; }; for (int i = 0; i < pilot_tones; ++i) meta[i] = clamp(std::nearbyint(127 * demod_or_erase(fdom[bin(i*block_length+first_pilot+tone_off)], chan[i*block_length+first_pilot]).real() * nrz(seq1()))); - int oper_mode = hadamard_decoder(meta); - if (oper_mode < 0 || oper_mode > 27) { - std::cerr << "operation mode " << oper_mode << " unsupported." << std::endl; + int mode = hadamard_decoder(meta); + if (mode < 0 || mode > 27) { + std::cerr << "operation mode " << mode << " unsupported." << std::endl; continue; } + oper_mode = mode; std::cerr << "oper mode: " << oper_mode << std::endl; if (oper_mode >= 10) { for (int i = 0; i < tone_count; ++i)