From 1dbc86c66f60242effdf46cbac3b8394d5ba67f7 Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Wed, 16 Jul 2025 12:00:49 +0200 Subject: [PATCH] use a shorter guard interval got rid of 8k and 16k sample rates. we can resample if needed. --- decode.cc | 12 +++--------- encode.cc | 16 +++++----------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/decode.cc b/decode.cc index 8de1b91..4a441f2 100644 --- a/decode.cc +++ b/decode.cc @@ -37,9 +37,9 @@ struct Decoder : Common typedef int16_t code_type; typedef SIMD mesg_type; typedef DSP::Const Const; - static const int guard_len = rate / 100; - static const int symbol_len = guard_len * 16; - static const int filter_len = (((21 * rate) / 8000) & ~3) | 1; + static const int guard_len = rate / 300; + static const int symbol_len = guard_len * 40; + static const int filter_len = 129; static const int extended_len = symbol_len + guard_len; static const int buffer_len = 5 * extended_len; static const int search_pos = extended_len; @@ -423,12 +423,6 @@ int main(int argc, char **argv) std::cerr << std::fixed << std::setprecision(1); int output_count = argc - 2; switch (input_file.rate()) { - case 8000: - delete new Decoder(&input_file, argv+2, output_count); - break; - case 16000: - delete new Decoder(&input_file, argv+2, output_count); - break; case 44100: delete new Decoder(&input_file, argv+2, output_count); break; diff --git a/encode.cc b/encode.cc index 856c3ed..77af814 100644 --- a/encode.cc +++ b/encode.cc @@ -28,8 +28,8 @@ template struct Encoder : public Common { typedef int8_t code_type; - static const int guard_len = rate / 100; - static const int symbol_len = guard_len * 16; + static const int guard_len = rate / 300; + static const int symbol_len = guard_len * 40; DSP::WritePCM *pcm; DSP::FastFourierTransform fwd; DSP::FastFourierTransform bwd; @@ -316,8 +316,8 @@ int main(int argc, char **argv) int output_chan = std::atoi(argv[4]); int freq_off = std::atoi(argv[5]); - if (freq_off % 100) { - std::cerr << "Frequency offset must be divisible by 100." << std::endl; + if (freq_off % 300) { + std::cerr << "Frequency offset must be divisible by 300." << std::endl; return 1; } int input_count = argc - 7; @@ -326,7 +326,7 @@ int main(int argc, char **argv) std::cerr << "Unsupported operation mode." << std::endl; return 1; } - int band_width = 2000; + int band_width = 2400; if ((output_chan == 1 && freq_off < band_width / 2) || freq_off < band_width / 2 - output_rate / 2 || freq_off > output_rate / 2 - band_width / 2) { std::cerr << "Unsupported frequency offset." << std::endl; return 1; @@ -337,12 +337,6 @@ int main(int argc, char **argv) DSP::WriteWAV output_file(output_name, output_rate, output_bits, output_chan); output_file.silence(output_rate); switch (output_rate) { - case 8000: - delete new Encoder(&output_file, argv+7, input_count, freq_off, oper_mode); - break; - case 16000: - delete new Encoder(&output_file, argv+7, input_count, freq_off, oper_mode); - break; case 44100: delete new Encoder(&output_file, argv+7, input_count, freq_off, oper_mode); break;