From 853ca2ef53889b4ac52cb9f0b15a03671901633f Mon Sep 17 00:00:00 2001 From: Brumi-2021 <86470699+Brumi-2021@users.noreply.github.com> Date: Sat, 12 Aug 2023 16:20:15 +0200 Subject: [PATCH] Solve_quality_problem_low_bit_rate_100k_150k_REC_Capture_App (#1367) * Solve_low_bit_rate_150k_Capture_App * Applying review comments. * format issues * Adding back requested previous low bit rates --- firmware/application/apps/capture_app.cpp | 2 +- firmware/application/freqman_db.cpp | 2 +- firmware/application/ui/ui_spectrum.cpp | 2 +- firmware/application/ui_record_view.cpp | 2 +- firmware/baseband/proc_capture.cpp | 4 ++-- firmware/common/message.hpp | 6 ++++++ firmware/common/oversample.hpp | 8 +++++--- 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/firmware/application/apps/capture_app.cpp b/firmware/application/apps/capture_app.cpp index 37a9919d..faa3c7ce 100644 --- a/firmware/application/apps/capture_app.cpp +++ b/firmware/application/apps/capture_app.cpp @@ -86,7 +86,7 @@ CaptureAppView::CaptureAppView(NavigationView& nav) }; receiver_model.enable(); - option_bandwidth.set_selected_index(7); // Preselected default option 500kHz. + option_bandwidth.set_by_value(500000); // better by_value than by option_bandwidth.set_selected_index(4), Preselected default option 500kHz. record_view.on_error = [&nav](std::string message) { nav.display_modal("Error", message); diff --git a/firmware/application/freqman_db.cpp b/firmware/application/freqman_db.cpp index c16b2b01..77f1b41a 100644 --- a/firmware/application/freqman_db.cpp +++ b/firmware/application/freqman_db.cpp @@ -76,10 +76,10 @@ options_t freqman_bandwidths[4] = { // SPEC -- TODO: these should be indexes. {"12k5", 12500}, {"16k", 16000}, - {"20k", 20000}, {"25k", 25000}, {"50k", 50000}, {"100k", 100000}, + {"150k", 150000}, {"250k", 250000}, {"500k", 500000}, /* Previous Limit bandwith Option with perfect micro SD write .C16 format operaton.*/ {"600k", 600000}, /* We doubled x2 previous REC BW limit , now extended BW from 600k to 1M with fast enough SD card in C16 or C8 format .*/ diff --git a/firmware/application/ui/ui_spectrum.cpp b/firmware/application/ui/ui_spectrum.cpp index ee8dccce..f3163f94 100644 --- a/firmware/application/ui/ui_spectrum.cpp +++ b/firmware/application/ui/ui_spectrum.cpp @@ -383,7 +383,7 @@ void WaterfallView::on_audio_spectrum() { // TODO: Comments below refer to a fixed oversample rate (8x), cleanup. uint32_t filter_bandwidth_for_sampling_rate(int32_t sampling_rate) { switch (sampling_rate) { // Use the var fs (sampling_rate) to set up BPF aprox < fs_max / 2 by Nyquist theorem. - case 0 ... 2'000'000: // BW Captured range (0 <= 250kHz max) fs = 8 x 250 kHz. + case 0 ... 3'000'000: // BW Captured range (0 <= 250kHz max) fs = 8 x 250 kHz., 16 x 150 khz, 32 x 75 khz, , 64 x 40 khz return 1'750'000; // Minimum BPF MAX2837 for all those lower BW options. case 4'000'000 ... 6'000'000: // BW capture range (500k...750kHz max) fs_max = 8 x 750kHz = 6Mhz diff --git a/firmware/application/ui_record_view.cpp b/firmware/application/ui_record_view.cpp index e6a09af4..c4484ffc 100644 --- a/firmware/application/ui_record_view.cpp +++ b/firmware/application/ui_record_view.cpp @@ -113,7 +113,7 @@ uint32_t RecordView::set_sampling_rate(uint32_t new_sampling_rate) { * They are ok as recorded spectrum indication, but they should not be used by Replay app. (the voice speed will be accelerated) * We keep original black background in all the correct IQ .C16 files BW's Options. */ - if (actual_sampling_rate > 8'000'000) { // Till fw 1.7.4 BW limit yellow REC button was >500khz, now BW >1Mhz (fs=8*BW), (>1Mhz ..2M75) + if ((actual_sampling_rate > 8'000'000) || (actual_sampling_rate <= 1'280'000)) { // yellow REC button means not ok for REC, BW >1Mhz , BW < 150khz button_record.set_background(ui::Color::yellow()); } else { button_record.set_background(ui::Color::black()); diff --git a/firmware/baseband/proc_capture.cpp b/firmware/baseband/proc_capture.cpp index f66effa0..8659605c 100644 --- a/firmware/baseband/proc_capture.cpp +++ b/firmware/baseband/proc_capture.cpp @@ -42,8 +42,8 @@ void CaptureProcessor::execute(const buffer_c8_t& buffer) { const auto decim_0_out = decim_0_execute(buffer, dst_buffer); // selectable 3 possible decim_0, (/4. /8 200k soft transition filter , /8 180k sharp ) const auto decim_1_out = baseband_fs < 4800'000 - ? decim_1.execute(decim_0_out, dst_buffer) // < 500khz double decim. stage - : decim_0_out; // > 500khz single decim. stage + ? decim_1.execute(decim_0_out, dst_buffer) // < 600khz double decim. stage , means 500khz and lower bit rates. + : decim_0_out; // >= 600khz single decim. stage , means 600khz and upper bit rates. const auto& decimator_out = decim_1_out; const auto& channel = decimator_out; diff --git a/firmware/common/message.hpp b/firmware/common/message.hpp index 4704b92f..a5ac3ef0 100644 --- a/firmware/common/message.hpp +++ b/firmware/common/message.hpp @@ -815,6 +815,12 @@ enum class OversampleRate : uint8_t { /* Oversample rate of 32 times the sample rate. */ x32 = 32, + + /* Oversample rate of 64 times the sample rate. */ + x64 = 64, + + /* Oversample rate of 128 times the sample rate. */ + x128 = 128, }; class SampleRateConfigMessage : public Message { diff --git a/firmware/common/oversample.hpp b/firmware/common/oversample.hpp index 9510f450..c2c8c698 100644 --- a/firmware/common/oversample.hpp +++ b/firmware/common/oversample.hpp @@ -46,10 +46,12 @@ * The oversample rate is used to increase the sample rate to improve SNR and quality. * This is also used as the interpolation rate when replaying captures. */ inline OversampleRate get_oversample_rate(uint32_t sample_rate) { - if (sample_rate < 25'000) return OversampleRate::x32; - if (sample_rate < 50'000) return OversampleRate::x16; + if (sample_rate < 50'000) return OversampleRate::x128; // 25kk ,16k, 12k5 + if (sample_rate < 100'000) return OversampleRate::x64; // 50k + if (sample_rate < 150'000) return OversampleRate::x32; // 100k + if (sample_rate < 250'000) return OversampleRate::x16; // 150k only - return OversampleRate::x8; + return OversampleRate::x8; // 250k .. 1Mhz } /* Gets the actual sample rate for a given sample rate.