satdump/src-interface/recorder/recorder.cpp

901 lines
36 KiB
C++
Raw Permalink Normal View History

2022-05-02 11:58:05 +02:00
#include "recorder.h"
#include "common/utils.h"
#include "common/widgets/frequency_input.h"
#include "common/widgets/stepped_slider.h"
#include "core/config.h"
#include "core/plugin.h"
#include "core/style.h"
2025-07-08 17:42:18 +01:00
#include "handlers/handler.h"
#include "imgui/imgui.h"
2022-05-03 17:00:43 +02:00
#include "imgui/imgui_stdlib.h"
#include "logger.h"
2024-09-11 09:48:07 +02:00
#include <math.h>
2022-05-03 17:00:43 +02:00
#include "main_ui.h"
2022-05-02 11:58:05 +02:00
2022-05-06 17:02:51 +02:00
#include "imgui/imgui_internal.h"
#include "core/resources.h"
2025-07-08 17:42:18 +01:00
#include "pipeline/pipeline.h"
2022-11-29 20:15:06 +01:00
2022-05-02 11:58:05 +02:00
namespace satdump
{
2025-07-08 17:42:18 +01:00
RecorderApplication::RecorderApplication() : handlers::Handler(), pipeline_selector(true)
2022-05-02 11:58:05 +02:00
{
2025-06-08 16:57:37 +02:00
automated_live_output_dir = satdump_cfg.main_cfg["satdump_directories"]["live_processing_autogen"]["value"].get<bool>();
processing_modules_floating_windows = satdump_cfg.main_cfg["user_interface"]["recorder_floating_windows"]["value"].get<bool>();
remaining_disk_space_time = satdump_cfg.main_cfg["user_interface"]["remaining_disk_space_time"]["value"].get<int>();
2024-09-19 21:15:53 -04:00
load_rec_path_data();
2024-09-16 13:35:46 -04:00
dsp::registerAllSources();
sources = dsp::getAllAvailableSources();
for (dsp::SourceDescriptor src : sources)
{
logger->debug("Device " + src.name);
sdr_select_string += src.name + '\0';
}
// First, check to see if a source was passed via command line
2025-06-08 16:57:37 +02:00
if (satdump::satdump_cfg.main_cfg.contains("cli") && satdump::satdump_cfg.main_cfg["cli"].contains("source"))
{
2025-06-08 16:57:37 +02:00
auto &cli_settings = satdump::satdump_cfg.main_cfg["cli"];
std::string source = cli_settings["source"];
for (int i = 0; i < (int)sources.size(); i++)
{
if (sources[i].source_type == source)
{
2024-05-01 16:26:07 +02:00
if (cli_settings.contains("source_id") && cli_settings["source_id"].get<std::string>() != sources[i].unique_id)
continue;
try
{
source_ptr = dsp::getSourceFromDescriptor(sources[i]);
source_ptr->open();
sdr_select_id = i;
break;
}
2024-01-19 00:29:42 +01:00
catch (std::runtime_error &e)
{
logger->error(e.what());
}
}
}
}
// If not, or it failed to open, revert to last used SDR
2025-06-08 16:57:37 +02:00
if (sdr_select_id == -1 && satdump_cfg.main_cfg["user"]["recorder_sdr_settings"].contains("last_used_sdr"))
{
2025-06-08 16:57:37 +02:00
std::string last_used_sdr = satdump_cfg.main_cfg["user"]["recorder_sdr_settings"]["last_used_sdr"].get<std::string>();
for (int i = 0; i < (int)sources.size(); i++)
{
if (sources[i].name != last_used_sdr)
continue;
try
{
source_ptr = dsp::getSourceFromDescriptor(sources[i]);
source_ptr->open();
sdr_select_id = i;
break;
}
2024-01-19 00:29:42 +01:00
catch (std::runtime_error &e)
{
logger->error(e.what());
break;
}
}
}
2024-01-19 00:29:42 +01:00
// If no source has been opened yet, open the first possible one
for (int i = 0; sdr_select_id == -1 && i < (int)sources.size(); i++)
2022-07-28 01:05:30 +02:00
{
try
{
source_ptr = dsp::getSourceFromDescriptor(sources[i]);
source_ptr->open();
sdr_select_id = i;
}
catch (std::runtime_error &e)
{
logger->error(e.what());
}
}
2022-11-29 20:15:06 +01:00
// Load waterfall palettes
{
waterfall_palettes_str = "";
std::filesystem::recursive_directory_iterator paletteIterator(resources::getResourcePath("waterfall"));
std::error_code iteratorError;
while (paletteIterator != std::filesystem::recursive_directory_iterator())
{
if (!std::filesystem::is_directory(paletteIterator->path()))
{
auto map = colormaps::loadMap(paletteIterator->path().string());
waterfall_palettes.push_back(map);
waterfall_palettes_str += map.name + " [" + map.author + "]" + '\0';
}
paletteIterator.increment(iteratorError);
if (iteratorError)
logger->critical(iteratorError.message());
}
}
2023-12-18 14:53:28 -05:00
set_frequency(frequency_hz);
2022-10-11 21:14:56 +02:00
try_load_sdr_settings();
2022-05-02 20:04:54 +02:00
splitter = std::make_shared<dsp::SplitterBlock>(source_ptr->output_stream);
2023-02-19 18:19:01 +01:00
splitter->add_output("record");
splitter->add_output("live");
2022-05-02 20:04:54 +02:00
2022-08-15 12:38:39 +02:00
fft = std::make_shared<dsp::FFTPanBlock>(splitter->output_stream);
2023-01-23 17:58:03 +01:00
fft->set_fft_settings(fft_size, get_samplerate(), fft_rate);
2023-12-13 15:42:08 +01:00
fft->avg_num = 10;
2022-05-02 20:04:54 +02:00
fft->start();
2023-02-19 18:19:01 +01:00
file_sink = std::make_shared<dsp::FileSinkBlock>(splitter->get_output("record"));
2022-05-02 22:05:54 +02:00
file_sink->start();
fft_plot = std::make_shared<widgets::FFTPlot>(fft->output_stream->writeBuf, fft_size, -150, 150, 10);
2023-12-18 14:53:28 -05:00
fft_plot->frequency = frequency_hz;
2023-02-11 01:35:26 +01:00
waterfall_plot = std::make_shared<widgets::WaterfallPlot>(fft_sizes_lut[0], 500);
2023-02-11 01:07:39 +01:00
fft->on_fft = [this](float *v) { waterfall_plot->push_fft(v); };
2022-10-11 21:39:41 +02:00
// Load config
2025-06-08 16:57:37 +02:00
if (satdump_cfg.main_cfg["user"].contains("recorder_state"))
deserialize_config(satdump_cfg.main_cfg["user"]["recorder_state"]);
2024-08-19 14:57:16 -04:00
file_sink->set_output_sample_type(baseband_format);
fft_plot->set_size(fft_size);
waterfall_plot->set_size(fft_size);
waterfall_plot->set_rate(fft_rate, waterfall_rate);
// Attempt to apply provided CLI settings
2025-06-08 16:57:37 +02:00
if (satdump_cfg.main_cfg.contains("cli"))
{
2025-06-08 16:57:37 +02:00
auto &cli_settings = satdump_cfg.main_cfg["cli"];
2023-11-09 12:04:09 +01:00
if (source_ptr)
{
if (cli_settings.contains("samplerate"))
source_ptr->set_samplerate(cli_settings["samplerate"].get<uint64_t>());
source_ptr->set_settings(cli_settings);
}
2023-11-09 12:04:09 +01:00
if (cli_settings.contains("start_recorder_device") && cli_settings["start_recorder_device"].get<bool>())
{
logger->warn("Recorder was asked to autostart!");
start();
}
2023-11-09 12:04:09 +01:00
if (cli_settings.contains("engage_autotrack") && cli_settings["engage_autotrack"].get<bool>())
2024-01-06 08:24:56 -05:00
{
tracking_started_cli = true;
2023-11-09 12:04:09 +01:00
try_init_tracking_widget();
2024-01-06 08:24:56 -05:00
}
2023-11-09 12:04:09 +01:00
}
2024-03-03 14:12:12 +01:00
//////////////////////////////////////////////////////////////////////////////////////////////////////////
eventBus->register_handler<RecorderSetFrequencyEvent>([this](const RecorderSetFrequencyEvent &evt) { set_frequency(evt.frequency); });
eventBus->register_handler<RecorderStartDeviceEvent>([this](const RecorderStartDeviceEvent &) { start(); });
eventBus->register_handler<RecorderStopDeviceEvent>([this](const RecorderStopDeviceEvent &) { stop(); });
eventBus->register_handler<RecorderSetDeviceSamplerateEvent>([this](const RecorderSetDeviceSamplerateEvent &evt) { source_ptr->set_samplerate(evt.samplerate); });
eventBus->register_handler<RecorderSetDeviceDecimationEvent>([this](const RecorderSetDeviceDecimationEvent &evt) { current_decimation = evt.decimation; });
eventBus->register_handler<RecorderSetDeviceLoOffsetEvent>([this](const RecorderSetDeviceLoOffsetEvent &evt) { xconverter_frequency = evt.offset; });
eventBus->register_handler<RecorderStartProcessingEvent>(
[this](const RecorderStartProcessingEvent &evt)
{
pipeline_selector.select_pipeline(evt.pipeline_id);
start_processing();
});
eventBus->register_handler<RecorderStopProcessingEvent>([this](const RecorderStopProcessingEvent &) { stop_processing(); });
eventBus->register_handler<RecorderSetFFTSettingsEvent>(
[this](const RecorderSetFFTSettingsEvent &evt)
{
if (evt.fft_min != -1)
fft_plot->scale_min = waterfall_plot->scale_min = evt.fft_min;
if (evt.fft_max != -1)
fft_plot->scale_max = waterfall_plot->scale_max = evt.fft_max;
if (evt.fft_avgn != -1)
fft->avg_num = evt.fft_avgn;
if (evt.fft_size != -1 || evt.fft_rate != -1 || evt.waterfall_rate != -1)
{
if (evt.fft_size != -1)
fft_size = evt.fft_size;
if (evt.fft_rate != -1)
fft_rate = evt.fft_rate;
if (evt.waterfall_rate != -1)
waterfall_rate = evt.waterfall_rate;
fft->set_fft_settings(fft_size, get_samplerate(), fft_rate);
waterfall_plot->set_rate(fft_rate, waterfall_rate);
waterfall_plot->set_size(fft_size);
fft_plot->set_size(fft_size);
for (int i = 0; i < (int)fft_sizes_lut.size(); i++)
if (fft_sizes_lut[i] == fft_size)
selected_fft_size = i;
}
});
2022-05-02 11:58:05 +02:00
}
RecorderApplication::~RecorderApplication()
{
save_settings();
2024-01-19 00:29:42 +01:00
retry_vfo:
for (auto &vfo : vfo_list)
{
del_vfo(vfo.id);
goto retry_vfo;
}
2022-12-17 16:55:11 +01:00
stop_processing();
2022-12-17 15:55:06 +01:00
if (is_started)
2023-01-23 18:02:26 +01:00
stop();
2022-05-07 00:24:30 +02:00
source_ptr->close();
2022-07-30 20:19:55 +02:00
splitter->input_stream = std::make_shared<dsp::stream<complex_t>>();
2022-05-07 00:24:30 +02:00
splitter->stop();
fft->stop();
file_sink->stop();
2023-07-22 21:23:38 +02:00
if (tracking_widget != nullptr)
delete tracking_widget;
if (constellation_debug != nullptr)
delete constellation_debug;
2022-05-02 11:58:05 +02:00
}
2025-07-08 17:42:18 +01:00
void RecorderApplication::drawMenu()
2022-05-02 11:58:05 +02:00
{
2025-07-08 17:42:18 +01:00
bool assume_started = is_started;
if (ImGui::CollapsingHeader("Device", tracking_started_cli ? ImGuiTreeNodeFlags_None : ImGuiTreeNodeFlags_DefaultOpen))
{
2025-07-08 17:42:18 +01:00
ImGui::Spacing();
if (assume_started)
style::beginDisabled();
if (ImGui::Combo("##Source", &sdr_select_id, sdr_select_string.c_str()))
{
2025-07-08 17:42:18 +01:00
// Try to open a device, if it doesn't work, we re-open a device we can
try
{
2025-07-08 17:42:18 +01:00
source_ptr.reset();
source_ptr = getSourceFromDescriptor(sources[sdr_select_id]);
source_ptr->open();
}
catch (std::runtime_error &e)
{
logger->error("Could not open device! %s", e.what());
for (int i = 0; i < (int)sources.size(); i++)
2022-07-28 01:05:30 +02:00
{
2023-01-22 22:23:43 +01:00
try
2022-07-28 01:05:30 +02:00
{
source_ptr.reset();
2025-07-08 17:42:18 +01:00
source_ptr = dsp::getSourceFromDescriptor(sources[i]);
2023-01-22 22:23:43 +01:00
source_ptr->open();
2025-07-08 17:42:18 +01:00
sdr_select_id = i;
break;
2023-01-22 22:23:43 +01:00
}
catch (std::runtime_error &e)
{
2025-07-08 17:42:18 +01:00
logger->error(e.what());
2022-07-28 01:05:30 +02:00
}
}
2025-07-08 17:42:18 +01:00
}
2022-05-12 23:30:42 +02:00
2025-07-08 17:42:18 +01:00
set_frequency(frequency_hz);
try_load_sdr_settings();
}
ImGui::SameLine();
if (ImGui::Button(u8" \uead2 "))
{
sources = dsp::getAllAvailableSources();
2022-05-12 23:30:42 +02:00
2025-07-08 17:42:18 +01:00
sdr_select_string.clear();
for (dsp::SourceDescriptor src : sources)
{
logger->debug("Device " + src.name);
sdr_select_string += src.name + '\0';
}
2023-01-22 22:23:43 +01:00
2025-07-08 17:42:18 +01:00
while (sdr_select_id >= (int)sources.size())
sdr_select_id--;
2025-07-08 17:42:18 +01:00
source_ptr = getSourceFromDescriptor(sources[sdr_select_id]);
source_ptr->open();
set_frequency(frequency_hz);
try_load_sdr_settings();
}
/*
if (ImGui::IsItemHovered())
{
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::TextUnformatted("Refresh source list");
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
*/
2022-09-07 19:52:02 +02:00
2025-07-08 17:42:18 +01:00
ImGui::InputInt("Decimation##recorderdecimation", &current_decimation);
if (current_decimation < 1)
current_decimation = 1;
2025-07-08 17:42:18 +01:00
bool disableLO = satdump_cfg.main_cfg["user_interface"]["lock_xconverter_input"]["value"];
if (assume_started && !disableLO)
style::endDisabled();
2025-07-08 17:42:18 +01:00
bool pushed_color_xconv = xconverter_frequency != 0;
if (pushed_color_xconv)
ImGui::PushStyleColor(ImGuiCol_Text, style::theme.green.Value);
2025-07-08 17:42:18 +01:00
if (ImGui::InputDouble("MHz (LO offset)##downupconverter", &xconverter_frequency))
set_frequency(frequency_hz);
2025-07-08 17:42:18 +01:00
if (pushed_color_xconv)
ImGui::PopStyleColor();
2025-07-08 17:42:18 +01:00
if (assume_started && disableLO)
style::endDisabled();
2025-07-08 17:42:18 +01:00
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
2022-12-05 12:22:45 +01:00
2025-07-08 17:42:18 +01:00
if (widgets::FrequencyInput("Hz##mainfreq", &frequency_hz))
set_frequency(frequency_hz);
2022-12-05 12:22:45 +01:00
2025-07-08 17:42:18 +01:00
ImGui::Spacing();
source_ptr->drawControlUI();
2023-11-29 21:30:55 -05:00
2025-07-08 17:42:18 +01:00
if (!assume_started)
{
if (ImGui::Button("Start"))
start();
}
else
{
if (ImGui::Button("Stop"))
stop();
}
2025-07-08 17:42:18 +01:00
sdr_error.draw();
}
2022-11-29 00:01:26 +01:00
2025-07-08 17:42:18 +01:00
if (ImGui::CollapsingHeader("FFT", tracking_started_cli ? ImGuiTreeNodeFlags_None : ImGuiTreeNodeFlags_DefaultOpen))
{
if (ImGui::Combo("FFT Size", &selected_fft_size,
"131072\0"
"65536\0"
"32768\0"
"16384\0"
"8192\0"
"4096\0"
"2048\0"
"1024\0"))
{
fft_size = fft_sizes_lut[selected_fft_size];
2022-11-29 00:01:26 +01:00
2025-07-08 17:42:18 +01:00
fft->set_fft_settings(fft_size, get_samplerate(), fft_rate);
fft_plot->set_size(fft_size);
waterfall_plot->set_size(fft_size);
2025-07-08 17:42:18 +01:00
logger->info("Set FFT size to %d", fft_size);
}
int old_rate = fft_rate;
if (ImGui::InputInt("FFT Rate", &fft_rate))
{
if (fft_rate <= 0)
fft_rate = old_rate;
else
2022-12-05 13:10:29 +01:00
{
2025-07-08 17:42:18 +01:00
fft_size = fft_sizes_lut[selected_fft_size];
fft->set_fft_settings(fft_size, get_samplerate(), fft_rate);
waterfall_plot->set_rate(fft_rate, waterfall_rate);
logger->info("Set FFT rate to %d", fft_rate);
2023-01-22 22:23:43 +01:00
}
2025-07-08 17:42:18 +01:00
}
if (ImGui::IsItemDeactivatedAfterEdit() && fft_rate < waterfall_rate)
{
waterfall_rate = fft_rate;
waterfall_plot->set_rate(fft_rate, waterfall_rate);
logger->info("Set Waterfall rate to %d", waterfall_rate);
}
old_rate = waterfall_rate;
if (ImGui::InputInt("Waterfall Rate", &waterfall_rate))
{
if (waterfall_rate <= 0)
waterfall_rate = old_rate;
2023-01-22 22:23:43 +01:00
else
{
2025-07-08 17:42:18 +01:00
waterfall_plot->set_rate(fft_rate, waterfall_rate);
logger->info("Set Waterfall rate to %d", waterfall_rate);
2022-12-05 13:10:29 +01:00
}
2025-07-08 17:42:18 +01:00
}
if (ImGui::IsItemDeactivatedAfterEdit() && waterfall_rate > fft_rate)
{
fft_rate = waterfall_rate;
fft->set_fft_settings(fft_size, get_samplerate(), fft_rate);
waterfall_plot->set_rate(fft_rate, waterfall_rate);
logger->info("Set FFT rate to %d", fft_rate);
}
widgets::SteppedSliderFloat("FFT Max", &fft_plot->scale_max, -160, 150);
widgets::SteppedSliderFloat("FFT Min", &fft_plot->scale_min, -160, 150);
widgets::SteppedSliderFloat("Avg Num", &fft->avg_num, 1, 500, 1);
if (ImGui::Combo("Palette", &selected_waterfall_palette, waterfall_palettes_str.c_str()))
waterfall_plot->set_palette(waterfall_palettes[selected_waterfall_palette]);
ImGui::Checkbox("Show Waterfall", &show_waterfall);
ImGui::Checkbox("Frequency Scale", &fft_plot->enable_freq_scale);
}
if (fft_plot->scale_max < fft_plot->scale_min)
{
fft_plot->scale_min = waterfall_plot->scale_min;
fft_plot->scale_max = waterfall_plot->scale_max;
}
else if (fft_plot->scale_min > fft_plot->scale_max)
{
fft_plot->scale_min = waterfall_plot->scale_min;
fft_plot->scale_max = waterfall_plot->scale_max;
}
else
{
waterfall_plot->scale_min = fft_plot->scale_min;
waterfall_plot->scale_max = fft_plot->scale_max;
}
2022-05-02 19:49:40 +02:00
2025-07-08 17:42:18 +01:00
if (ImGui::CollapsingHeader("Processing"))
{
// Settings & Selection menu
bool assume_processing = is_processing;
if (assume_processing)
style::beginDisabled();
pipeline_selector.renderSelectionBox(ImGui::GetContentRegionAvail().x);
if (!automated_live_output_dir)
pipeline_selector.drawMainparamsLive();
pipeline_selector.renderParamTable();
if (assume_processing)
style::endDisabled();
// Preset Menu
if (pipeline_selector.selected_pipeline.preset.frequencies.size() > 0)
{
if (ImGui::BeginCombo("Freq###presetscombo", pipeline_selector.selected_pipeline.preset.frequencies[pipeline_preset_id].second == frequency_hz
? pipeline_selector.selected_pipeline.preset.frequencies[pipeline_preset_id].first.c_str()
: ""))
2022-06-10 22:21:22 +02:00
{
2025-07-08 17:42:18 +01:00
for (int n = 0; n < (int)pipeline_selector.selected_pipeline.preset.frequencies.size(); n++)
2022-06-10 22:21:22 +02:00
{
2025-07-08 17:42:18 +01:00
const bool is_selected = (pipeline_preset_id == n);
if (ImGui::Selectable(pipeline_selector.selected_pipeline.preset.frequencies[n].first.c_str(), is_selected))
2022-06-10 22:21:22 +02:00
{
2025-07-08 17:42:18 +01:00
pipeline_preset_id = n;
if (pipeline_selector.selected_pipeline.preset.frequencies[pipeline_preset_id].second != 0)
2022-06-12 16:17:30 +02:00
{
2025-07-08 17:42:18 +01:00
frequency_hz = pipeline_selector.selected_pipeline.preset.frequencies[pipeline_preset_id].second;
set_frequency(frequency_hz);
2023-01-22 22:23:43 +01:00
}
2022-06-10 22:21:22 +02:00
}
2025-07-08 17:42:18 +01:00
if (is_selected)
ImGui::SetItemDefaultFocus();
2022-06-10 22:21:22 +02:00
}
2025-07-08 17:42:18 +01:00
ImGui::EndCombo();
}
}
2022-06-10 22:21:22 +02:00
2025-07-08 17:42:18 +01:00
if (!assume_started)
style::beginDisabled();
2022-06-10 22:21:22 +02:00
2025-07-08 17:42:18 +01:00
bool assume_stopping_processing = is_stopping_processing;
if (!assume_processing)
{
if (ImGui::Button("Start###startprocessing"))
start_processing();
}
else if (assume_stopping_processing)
{
style::beginDisabled();
ImGui::Button("Stopping...##stoppingprocessing");
style::endDisabled();
}
else
{
if (ImGui::Button("Stop##stopprocessing"))
ui_thread_pool.push([=](int) { stop_processing(); });
}
2022-05-03 17:00:43 +02:00
2025-07-08 17:42:18 +01:00
error.draw();
2022-05-06 00:26:21 +02:00
2025-07-08 17:42:18 +01:00
if (!assume_started)
style::endDisabled();
}
2022-05-02 22:05:54 +02:00
2025-07-08 17:42:18 +01:00
if (ImGui::CollapsingHeader("Recording"))
{
bool assume_recording = is_recording;
if (assume_recording)
style::beginDisabled();
2024-08-19 14:57:16 -04:00
2025-07-08 17:42:18 +01:00
if (baseband_format.draw_record_combo("Format##basebandrecordformat"))
file_sink->set_output_sample_type(baseband_format);
2025-07-08 17:42:18 +01:00
if (assume_recording)
style::endDisabled();
2022-05-02 22:05:54 +02:00
2025-07-08 17:42:18 +01:00
uint64_t file_written = file_sink->get_written();
uint64_t estimated_available = 0;
if (file_written <= disk_available)
estimated_available = disk_available - file_written;
2024-09-19 21:15:53 -04:00
2025-07-08 17:42:18 +01:00
if (file_written < 1e9)
ImGui::Text("Size : %.2f MB", file_written / 1e6);
else
ImGui::Text("Size : %.2f GB", file_written / 1e9);
2024-09-19 21:15:53 -04:00
2025-07-08 17:42:18 +01:00
ImGui::Text("Free Space: %.2f GB", estimated_available / pow(1024, 3));
2024-09-16 13:35:46 -04:00
2025-07-08 17:42:18 +01:00
int timeleft;
switch (baseband_format)
{
case dsp::CF_32:
case dsp::CS_32:
timeleft = estimated_available / (8 * get_samplerate());
break;
case dsp::CS_16:
case dsp::WAV_16:
timeleft = estimated_available / (4 * get_samplerate());
break;
case dsp::CS_8:
case dsp::CU_8:
timeleft = estimated_available / (2 * get_samplerate());
break;
default:
// Silence GCC warns
timeleft = 0;
break;
}
2024-09-16 13:53:25 -04:00
#ifdef BUILD_ZIQ
2025-07-08 17:42:18 +01:00
if (baseband_format != dsp::ZIQ)
2024-09-16 13:53:25 -04:00
#endif
2025-07-08 17:42:18 +01:00
{
2024-09-16 13:53:25 -04:00
#ifdef BUILD_ZIQ2
2025-07-08 17:42:18 +01:00
if (baseband_format != dsp::ZIQ2)
2024-09-16 13:53:25 -04:00
#endif
2025-07-08 17:42:18 +01:00
{
if (is_recording && remaining_disk_space_time > timeleft && !been_warned)
{
logger->warn("!!!!WARNING - LOW AMOUNT OF FREE DISK SPACE!!!!");
been_warned = true;
}
2024-09-16 06:28:44 +02:00
2025-07-08 17:42:18 +01:00
int day = timeleft / (24 * 3600);
2024-09-11 09:48:07 +02:00
2025-07-08 17:42:18 +01:00
timeleft = timeleft % (24 * 3600);
int hour = timeleft / 3600;
2024-09-11 09:48:07 +02:00
2025-07-08 17:42:18 +01:00
timeleft %= 3600;
int minutes = timeleft / 60;
2024-09-16 13:53:25 -04:00
2025-07-08 17:42:18 +01:00
timeleft %= 60;
int seconds = timeleft;
ImGui::Text("Time left: %02d:%02d:%02d:%02d", day, hour, minutes, seconds);
}
}
2022-05-04 00:37:34 +02:00
#ifdef BUILD_ZIQ
2025-07-08 17:42:18 +01:00
if (baseband_format == dsp::ZIQ)
{
if (file_sink->get_written_raw() < 1e9)
ImGui::Text("Size (raw) : %.2f MB", file_sink->get_written_raw() / 1e6);
else
ImGui::Text("Size (raw) : %.2f GB", file_sink->get_written_raw() / 1e9);
}
2022-05-04 00:37:34 +02:00
#endif
2025-07-08 17:42:18 +01:00
ImGui::Text("File : %s", recorder_filename.c_str());
2022-05-02 22:05:54 +02:00
2025-07-08 17:42:18 +01:00
ImGui::Spacing();
2022-05-02 22:05:54 +02:00
2025-07-08 17:42:18 +01:00
if (!assume_recording)
ImGui::TextColored(style::theme.red, "IDLE");
else
ImGui::TextColored(style::theme.green, "RECORDING");
2022-05-02 22:05:54 +02:00
2025-07-08 17:42:18 +01:00
ImGui::Spacing();
2022-05-02 22:05:54 +02:00
2025-07-08 17:42:18 +01:00
if (!assume_recording)
{
if (ImGui::Button("Start###startrecording"))
start_recording();
}
else
{
if (ImGui::Button("Stop##stoprecording"))
stop_recording();
}
}
2023-07-17 23:11:13 +02:00
2025-07-08 17:42:18 +01:00
show_tracking = ImGui::CollapsingHeader("Tracking", tracking_started_cli ? ImGuiTreeNodeFlags_DefaultOpen : ImGuiTreeNodeFlags_None);
if (show_tracking)
{
try_init_tracking_widget();
tracking_widget->render();
}
2025-07-08 17:42:18 +01:00
if (ImGui::CollapsingHeader("VFOs"))
{
vfos_mtx.lock();
std::string to_delete = "";
if (vfo_list.size() == 0)
{
const char *no_vfo_text = "No Active VFOs";
ImGui::SetCursorPosX(ImGui::GetContentRegionAvail().x / 2 - ImGui::CalcTextSize(no_vfo_text).x / 2);
ImGui::TextDisabled("%s", no_vfo_text);
}
else
{
for (auto &vfo : vfo_list)
2024-01-19 00:29:42 +01:00
{
2025-07-08 17:42:18 +01:00
ImGui::PushStyleColor(ImGuiCol_Text, style::theme.green.Value);
ImGui::SeparatorText(vfo.name.c_str());
ImGui::PopStyleColor();
ImGui::BulletText("Frequency: %s", format_notated(vfo.freq, "Hz").c_str());
if (vfo.selected_pipeline.id != "")
2024-01-21 22:41:52 -05:00
{
2025-07-08 17:42:18 +01:00
ImGui::BulletText("Pipeline: %s", vfo.selected_pipeline.id.c_str());
ImGui::BulletText("Directory: %s", vfo.output_dir.c_str());
2024-01-21 22:41:52 -05:00
}
2025-07-08 17:42:18 +01:00
else if (vfo.file_sink)
2024-01-21 22:41:52 -05:00
{
2025-07-08 17:42:18 +01:00
if (vfo.file_sink->get_written() < 1e9)
ImGui::BulletText("IQ Size: %.2f MB", vfo.file_sink->get_written() / 1e6);
else
ImGui::BulletText("IQ Size: %.2f GB", vfo.file_sink->get_written() / 1e9);
2024-01-21 22:41:52 -05:00
}
2025-07-08 17:42:18 +01:00
ImGui::Spacing();
if (ImGui::Button(std::string("Stop##" + vfo.id).c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0)))
to_delete = vfo.id;
}
}
vfos_mtx.unlock();
if (to_delete != "")
del_vfo(to_delete);
2024-01-21 13:37:02 +01:00
#if 0
2025-07-08 17:42:18 +01:00
if (ImGui::Button("Add Test"))
{
int idp = 0;
for (int n = 0; n < (int)pipeline::pipelines.size(); n++)
{
if ("meteor_m2-x_lrpt" == pipeline::pipelines[n].id)
idp = n;
}
2024-01-19 00:29:42 +01:00
2025-07-08 17:42:18 +01:00
add_vfo_live("meteor_test", "Meteor Test", 137.9e6, pipeline::pipelines[idp], {});
}
2024-01-19 00:29:42 +01:00
2025-07-08 17:42:18 +01:00
if (ImGui::Button("Del Test"))
{
del_vfo("meteor_test");
}
2024-01-19 00:29:42 +01:00
#endif
2025-07-08 17:42:18 +01:00
}
2024-01-19 00:29:42 +01:00
2025-07-08 17:42:18 +01:00
if (ImGui::CollapsingHeader("Debug"))
{
if (constellation_debug == nullptr)
constellation_debug = new widgets::ConstellationViewer();
if (is_started)
constellation_debug->pushComplex(source_ptr->output_stream->readBuf, 256);
constellation_debug->draw();
}
2024-03-03 14:12:12 +01:00
2025-07-08 17:42:18 +01:00
eventBus->fire_event<RecorderDrawPanelEvent>({});
}
void RecorderApplication::drawContents(ImVec2 win_size)
{
float right_width = win_size.x;
float wf_size = win_size.y;
float left_width = ImGui::GetCursorPosX();
float recorder_size_x = right_width;
float _live_height = 250;
2025-07-08 17:42:18 +01:00
float wf_size_offset = 0;
if (is_processing && !processing_modules_floating_windows)
wf_size_offset = _live_height * ui_scale;
if (vfo_list.size() > 0)
{
wf_size_offset = 270 * ui_scale;
_live_height = 270;
}
wf_size = win_size.y - wf_size_offset; // + 13 * ui_scale;
// float wf_size_offset = 0;
// if (is_processing && !processing_modules_floating_windows)
// wf_size_offset = 250 * ui_scale;
// if (vfo_list.size() > 0)
// wf_size_offset = 270 * ui_scale;
// ImVec2 recorder_size = ImGui::GetContentRegionAvail();
// float wf_size_offset = 0;
// if (is_processing && !processing_modules_floating_windows)
// wf_size_offset = 250 * ui_scale;
// if (vfo_list.size() > 0)
// wf_size_offset = 270 * ui_scale;
// float wf_size = recorder_size.y - wf_size_offset; // + 13 * ui_scale;
{
ImGui::BeginChild("RecorderFFT", {right_width, wf_size}, false, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
2022-05-08 13:42:52 +02:00
{
2023-01-22 22:23:43 +01:00
float fft_height = wf_size * (show_waterfall ? waterfall_ratio : 1.0);
2023-01-23 19:44:44 +01:00
float wf_height = wf_size * (1 - waterfall_ratio) + 15 * ui_scale;
2023-11-09 20:30:55 +01:00
float wfft_widht = right_width - 9 * ui_scale;
2023-01-22 22:23:43 +01:00
bool t = true;
2023-01-23 13:45:04 +01:00
#ifdef __ANDROID__
int offset = 8;
#else
int offset = 30;
#endif
ImGui::SetNextWindowSizeConstraints(ImVec2((right_width + offset * ui_scale), 50), ImVec2((right_width + offset * ui_scale), wf_size));
ImGui::SetNextWindowSize(ImVec2((right_width + offset * ui_scale), show_waterfall ? waterfall_ratio * wf_size : wf_size));
ImGui::SetNextWindowPos(ImVec2(left_width, 25 * ui_scale));
if (ImGui::Begin("#fft", &t,
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoScrollbar |
ImGuiWindowFlags_NoScrollWithMouse))
2022-05-08 13:42:52 +02:00
{
2025-07-08 17:42:18 +01:00
// ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 2 * ui_scale);
2023-11-09 20:30:55 +01:00
fft_plot->draw({float(wfft_widht), fft_height});
2023-01-22 23:40:56 +01:00
if (show_waterfall && ImGui::IsMouseDragging(ImGuiMouseButton_Left))
waterfall_ratio = ImGui::GetWindowHeight() / wf_size;
2023-02-09 17:51:07 +01:00
if (ImGui::IsWindowHovered())
{
2023-01-23 17:39:04 +01:00
ImVec2 mouse_pos = ImGui::GetMousePos();
2023-10-04 20:39:45 -04:00
float ratio = (mouse_pos.x - left_width - 16 * ui_scale) / (right_width - 9 * ui_scale) - 0.5;
ImGui::SetTooltip(
"%s",
((ratio >= 0 ? "" : "- ") + format_notated(abs(ratio) * get_samplerate(), "Hz\n") + format_notated(source_ptr->get_frequency() + ratio * get_samplerate(), "Hz")).c_str());
2023-01-23 17:39:04 +01:00
}
2025-07-08 17:42:18 +01:00
ImGui::EndChild();
2022-05-08 13:42:52 +02:00
}
2025-07-08 17:42:18 +01:00
if (show_waterfall)
2022-05-08 13:42:52 +02:00
{
2025-07-08 17:42:18 +01:00
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 8 * ui_scale);
2023-01-22 23:40:56 +01:00
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 15 * ui_scale);
2023-11-09 20:30:55 +01:00
waterfall_plot->draw({wfft_widht, wf_height}, is_started);
2022-05-08 13:42:52 +02:00
}
}
2023-01-22 22:23:43 +01:00
ImGui::EndChild();
2022-05-08 14:47:56 +02:00
}
2024-01-19 21:49:44 +01:00
if (vfo_list.size() > 0)
2024-01-19 00:29:42 +01:00
{
2024-01-19 21:49:44 +01:00
if (ImGui::BeginTabBar("VFO TabBar", ImGuiTabBarFlags_None))
2024-01-19 00:29:42 +01:00
{
if (is_processing)
{
2024-01-26 22:45:55 -05:00
if (ImGui::BeginTabItem("Live Processing"))
2024-01-19 00:29:42 +01:00
{
2025-07-08 17:42:18 +01:00
float y_pos = ImGui::GetCursorPosY(); //+ 35 * ui_scale;
float live_width = recorder_size_x + 16 * ui_scale;
float live_height = _live_height * ui_scale;
2024-01-19 00:29:42 +01:00
float winwidth = live_pipeline->modules.size() > 0 ? live_width / live_pipeline->modules.size() : live_width;
2025-07-08 17:42:18 +01:00
float currentPos = ImGui::GetCursorPosX();
2024-01-19 00:29:42 +01:00
ImGui::PushStyleColor(ImGuiCol_TitleBgActive, ImGui::GetStyleColorVec4(ImGuiCol_TitleBg));
for (std::shared_ptr<pipeline::ProcessingModule> &module : live_pipeline->modules)
2024-01-19 00:29:42 +01:00
{
ImGui::SetNextWindowPos({currentPos, y_pos});
ImGui::SetNextWindowSize({(float)winwidth, (float)live_height});
module->drawUI(false);
currentPos += winwidth;
// if (ImGui::GetCurrentContext()->last_window != NULL)
// currentPos += ImGui::GetCurrentContext()->last_window->Size.x;
// logger->info(ImGui::GetCurrentContext()->last_window->Name);
}
ImGui::PopStyleColor();
ImGui::EndTabItem();
}
}
vfos_mtx.lock();
for (auto &vfo : vfo_list)
{
2024-01-19 21:49:44 +01:00
if (ImGui::BeginTabItem(vfo.name.c_str()))
2024-01-19 00:29:42 +01:00
{
2025-06-11 17:38:30 +02:00
if (vfo.selected_pipeline.id != "")
2024-01-19 00:29:42 +01:00
{
2025-07-08 17:42:18 +01:00
float y_pos = ImGui::GetCursorPosY(); //+ 35 * ui_scale;
float live_width = recorder_size_x + 16 * ui_scale;
float live_height = _live_height * ui_scale;
2024-01-21 22:58:56 +01:00
float winwidth = vfo.live_pipeline->modules.size() > 0 ? live_width / vfo.live_pipeline->modules.size() : live_width;
2025-07-08 17:42:18 +01:00
float currentPos = ImGui::GetCursorPosX();
;
2024-01-21 22:58:56 +01:00
ImGui::PushStyleColor(ImGuiCol_TitleBgActive, ImGui::GetStyleColorVec4(ImGuiCol_TitleBg));
for (std::shared_ptr<pipeline::ProcessingModule> &module : vfo.live_pipeline->modules)
2024-01-21 22:58:56 +01:00
{
ImGui::SetNextWindowPos({currentPos, y_pos});
ImGui::SetNextWindowSize({(float)winwidth, (float)live_height});
module->drawUI(false);
currentPos += winwidth;
// if (ImGui::GetCurrentContext()->last_window != NULL)
// currentPos += ImGui::GetCurrentContext()->last_window->Size.x;
// logger->info(ImGui::GetCurrentContext()->last_window->Name);
}
ImGui::PopStyleColor();
2024-01-19 00:29:42 +01:00
}
ImGui::EndTabItem();
}
}
vfos_mtx.unlock();
ImGui::EndTabBar();
}
}
else if (is_processing)
2022-05-05 23:55:05 +02:00
{
if (processing_modules_floating_windows)
2022-05-05 23:55:05 +02:00
{
for (std::shared_ptr<pipeline::ProcessingModule> &module : live_pipeline->modules)
module->drawUI(true);
}
else
{
2025-07-08 17:42:18 +01:00
float y_pos = ImGui::GetCursorPosY(); //+ 35 * ui_scale;
float live_width = recorder_size_x + 16 * ui_scale;
float live_height = _live_height * ui_scale;
float winwidth = live_pipeline->modules.size() > 0 ? live_width / live_pipeline->modules.size() : live_width;
2025-07-08 17:42:18 +01:00
float currentPos = ImGui::GetCursorPosX();
2023-11-20 14:18:52 -05:00
ImGui::PushStyleColor(ImGuiCol_TitleBgActive, ImGui::GetStyleColorVec4(ImGuiCol_TitleBg));
for (std::shared_ptr<pipeline::ProcessingModule> &module : live_pipeline->modules)
{
ImGui::SetNextWindowPos({currentPos, y_pos});
ImGui::SetNextWindowSize({(float)winwidth, (float)live_height});
module->drawUI(false);
currentPos += winwidth;
// if (ImGui::GetCurrentContext()->last_window != NULL)
// currentPos += ImGui::GetCurrentContext()->last_window->Size.x;
// logger->info(ImGui::GetCurrentContext()->last_window->Name);
}
ImGui::PopStyleColor();
2022-05-05 23:55:05 +02:00
}
}
// Keyboard shortcuts
{
// FFT
if (ImGui::IsKeyDown(ImGuiKey_ModShift) && ImGui::IsKeyDown(ImGuiKey_X))
{
if (ImGui::IsKeyDown(ImGuiKey_DownArrow))
fft_plot->scale_max -= 0.5;
else if (ImGui::IsKeyDown(ImGuiKey_UpArrow))
fft_plot->scale_max += 0.5;
else if (ImGui::IsKeyDown(ImGuiKey_LeftArrow))
fft_plot->scale_min -= 0.5;
else if (ImGui::IsKeyDown(ImGuiKey_RightArrow))
fft_plot->scale_min += 0.5;
2023-12-13 15:42:08 +01:00
#if 0
else if (ImGui::IsKeyDown(ImGuiKey_PageUp))
fft->avg_rate += 0.001;
else if (ImGui::IsKeyDown(ImGuiKey_PageDown))
fft->avg_rate -= 0.001;
if (fft->avg_rate > 0.99)
fft->avg_rate = 0.99;
else if (fft->avg_rate < 0.01)
fft->avg_rate = 0.01;
2023-12-13 15:42:08 +01:00
#endif
}
}
2022-05-02 11:58:05 +02:00
}
}; // namespace satdump