More bugfix + folder selection in recorder

This commit is contained in:
Ryzerth 2020-12-05 22:42:12 +01:00
parent 92b77904f6
commit 9b8c1a3072
17 changed files with 76 additions and 30 deletions

View File

@ -10,7 +10,7 @@
#include <gui/icons.h> #include <gui/icons.h>
#include <version.h> #include <version.h>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <gui/bandplan.h> #include <gui/widgets/bandplan.h>
#include <module.h> #include <module.h>
#include <stb_image.h> #include <stb_image.h>
#include <config.h> #include <config.h>

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <gui/waterfall.h> #include <gui/widgets/waterfall.h>
#include <gui/frequency_select.h> #include <gui/widgets/frequency_select.h>
#include <gui/menu.h> #include <gui/widgets/menu.h>
#include <gui/dialogs/loading_screen.h> #include <gui/dialogs/loading_screen.h>
#include <module.h> #include <module.h>

View File

@ -9,12 +9,12 @@
#include <imgui_plot.h> #include <imgui_plot.h>
#include <thread> #include <thread>
#include <complex> #include <complex>
#include <gui/waterfall.h> #include <gui/widgets/waterfall.h>
#include <gui/frequency_select.h> #include <gui/widgets/frequency_select.h>
#include <fftw3.h> #include <fftw3.h>
#include <signal_path/dsp.h> #include <signal_path/dsp.h>
#include <gui/icons.h> #include <gui/icons.h>
#include <gui/bandplan.h> #include <gui/widgets/bandplan.h>
#include <watcher.h> #include <watcher.h>
#include <module.h> #include <module.h>
#include <signal_path/vfo_manager.h> #include <signal_path/vfo_manager.h>
@ -122,12 +122,13 @@ void windowInit() {
displaymenu::init(); displaymenu::init();
// TODO for 0.2.5 // TODO for 0.2.5
// Add a loading screen // Add "select folder" option for the file source
// Add "select folder" option for the recorder module // Fix SSB demod
// Add squelsh // FIX AUDIO ISSUE ON BOTH LINUX AND SOMETIMES WINDOWS (probly the ring buffer, though double buffering could help)
// CW and RAW modes; // Rewrite radio module with CW and RAW modes
// Bring VFO to a visible place when changing sample rate if it's smaller // Add default main config to avoid having to ship one
// Use DUK_USE_DATE_NOW_WINDOWS for windows 7 support // Have a good directory system on both linux and windows
// Switch to double buffering
// TODO for 0.2.6 // TODO for 0.2.6
// And a module add/remove/change order menu // And a module add/remove/change order menu

View File

@ -1,5 +1,5 @@
#include <gui/menus/bandplan.h> #include <gui/menus/bandplan.h>
#include <gui/bandplan.h> #include <gui/widgets/bandplan.h>
#include <gui/gui.h> #include <gui/gui.h>
#include <core.h> #include <core.h>

View File

@ -1,4 +1,4 @@
#include <gui/bandplan.h> #include <gui/widgets/bandplan.h>
#include <fstream> #include <fstream>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <filesystem> #include <filesystem>

View File

@ -1,4 +1,4 @@
#include <gui/frequency_select.h> #include <gui/widgets/frequency_select.h>
#include <config.h> #include <config.h>
#include <gui/style.h> #include <gui/style.h>

View File

@ -1,4 +1,4 @@
#include <gui/menu.h> #include <gui/widgets/menu.h>
#include <imgui/imgui.h> #include <imgui/imgui.h>
Menu::Menu() { Menu::Menu() {

View File

@ -1,4 +1,4 @@
#include <gui/waterfall.h> #include <gui/widgets/waterfall.h>
#include <imgui.h> #include <imgui.h>
#include <imgui_internal.h> #include <imgui_internal.h>
#include <GL/glew.h> #include <GL/glew.h>
@ -564,6 +564,14 @@ namespace ImGui {
double currentRatio = viewBandwidth / wholeBandwidth; double currentRatio = viewBandwidth / wholeBandwidth;
wholeBandwidth = bandWidth; wholeBandwidth = bandWidth;
setViewBandwidth(bandWidth * currentRatio); setViewBandwidth(bandWidth * currentRatio);
for (auto const& [name, vfo] : vfos) {
if (vfo->lowerOffset < -(bandWidth / 2)) {
vfo->setCenterOffset(-(bandWidth / 2));
}
if (vfo->upperOffset > (bandWidth / 2)) {
vfo->setCenterOffset(bandWidth / 2);
}
}
updateAllVFOs(); updateAllVFOs();
} }

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <vector> #include <vector>
#include <mutex> #include <mutex>
#include <gui/bandplan.h> #include <gui/widgets/bandplan.h>
#include <imgui/imgui.h> #include <imgui/imgui.h>
#include <imgui/imgui_internal.h> #include <imgui/imgui_internal.h>
#include <GL/glew.h> #include <GL/glew.h>

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <dsp/vfo.h> #include <dsp/vfo.h>
#include <gui/waterfall.h> #include <gui/widgets/waterfall.h>
#include <gui/gui.h> #include <gui/gui.h>
class VFOManager { class VFOManager {

View File

@ -7,8 +7,11 @@
#include <thread> #include <thread>
#include <ctime> #include <ctime>
#include <gui/gui.h> #include <gui/gui.h>
#include <filesystem>
#include <signal_path/signal_path.h> #include <signal_path/signal_path.h>
#include <config.h> #include <config.h>
#include <gui/style.h>
#include <regex>
#define CONCAT(a, b) ((std::string(a) + b).c_str()) #define CONCAT(a, b) ((std::string(a) + b).c_str())
@ -30,6 +33,11 @@ void sampleRateChanged(void* ctx, double sampleRate, int blockSize) {
} }
std::string expandString(std::string input) {
input = std::regex_replace(input, std::regex("%ROOT%"), ROOT_DIR);
return std::regex_replace(input, std::regex("//"), "/");
}
class RecorderModule { class RecorderModule {
public: public:
RecorderModule(std::string name) { RecorderModule(std::string name) {
@ -38,6 +46,7 @@ public:
selectedStreamName = ""; selectedStreamName = "";
selectedStreamId = 0; selectedStreamId = 0;
lastNameList = ""; lastNameList = "";
strcpy(path, "%ROOT%/recordings");
gui::menu.registerEntry(name, menuHandler, this); gui::menu.registerEntry(name, menuHandler, this);
} }
@ -77,6 +86,27 @@ private:
} }
ImGui::BeginGroup(); ImGui::BeginGroup();
if (_this->recording) { style::beginDisabled(); }
ImGui::SetNextItemWidth(menuColumnWidth);
bool lastPathValid = _this->pathValid;
if (!lastPathValid) {
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.0f, 0.0f, 1.0f));
}
if (ImGui::InputText(CONCAT("##_recorder_path_", _this->name), _this->path, 4095)) {
std::string expandedPath = expandString(_this->path);
if (!std::filesystem::exists(expandedPath)) {
_this->pathValid = false;
}
else if (!std::filesystem::is_directory(expandedPath)) {
_this->pathValid = false;
}
else {
_this->pathValid = true;
}
}
if (!lastPathValid) {
ImGui::PopStyleColor();
}
// TODO: Change VFO ref in signal path // TODO: Change VFO ref in signal path
// TODO: Add VFO record // TODO: Add VFO record
@ -88,6 +118,7 @@ private:
if (ImGui::RadioButton(CONCAT("Audio##_", _this->name), _this->recMode == 1) && _this->recMode != 1) { if (ImGui::RadioButton(CONCAT("Audio##_", _this->name), _this->recMode == 1) && _this->recMode != 1) {
_this->recMode = 1; _this->recMode = 1;
} }
if (_this->recording) { style::endDisabled(); }
ImGui::Columns(1, CONCAT("EndRecordModeColumns##_", _this->name), false); ImGui::Columns(1, CONCAT("EndRecordModeColumns##_", _this->name), false);
ImGui::EndGroup(); ImGui::EndGroup();
@ -95,16 +126,19 @@ private:
if (_this->recMode == 0) { if (_this->recMode == 0) {
ImGui::PushItemWidth(menuColumnWidth); ImGui::PushItemWidth(menuColumnWidth);
if (!_this->recording) { if (!_this->recording) {
if (!_this->pathValid) { style::beginDisabled(); }
if (ImGui::Button("Record", ImVec2(menuColumnWidth, 0))) { if (ImGui::Button("Record", ImVec2(menuColumnWidth, 0))) {
std::string expandedPath = expandString(std::string(_this->path) + genFileName("/baseband_"));
_this->samplesWritten = 0; _this->samplesWritten = 0;
_this->sampleRate = sigpath::signalPath.getSampleRate(); _this->sampleRate = sigpath::signalPath.getSampleRate();
_this->writer = new WavWriter(ROOT_DIR "/recordings/" + genFileName("baseband_"), 16, 2, _this->sampleRate); _this->writer = new WavWriter(expandedPath, 16, 2, _this->sampleRate);
_this->iqStream = new dsp::stream<dsp::complex_t>; _this->iqStream = new dsp::stream<dsp::complex_t>;
sigpath::signalPath.bindIQStream(_this->iqStream); sigpath::signalPath.bindIQStream(_this->iqStream);
_this->workerThread = std::thread(_iqWriteWorker, _this); _this->workerThread = std::thread(_iqWriteWorker, _this);
_this->recording = true; _this->recording = true;
_this->startTime = time(0); _this->startTime = time(0);
} }
if (!_this->pathValid) { style::endDisabled(); }
ImGui::TextColored(ImGui::GetStyleColorVec4(ImGuiCol_Text), "Idle --:--:--"); ImGui::TextColored(ImGui::GetStyleColorVec4(ImGuiCol_Text), "Idle --:--:--");
} }
else { else {
@ -140,15 +174,18 @@ private:
ImGui::PopStyleColor(3); ImGui::PopStyleColor(3);
} }
if (!_this->recording) { if (!_this->recording) {
if (!_this->pathValid) { style::beginDisabled(); }
if (ImGui::Button("Record", ImVec2(menuColumnWidth, 0))) { if (ImGui::Button("Record", ImVec2(menuColumnWidth, 0))) {
std::string expandedPath = expandString(std::string(_this->path) + genFileName("/audio_"));
_this->samplesWritten = 0; _this->samplesWritten = 0;
_this->sampleRate = sigpath::sinkManager.getStreamSampleRate(_this->selectedStreamName); _this->sampleRate = sigpath::sinkManager.getStreamSampleRate(_this->selectedStreamName);
_this->writer = new WavWriter(ROOT_DIR "/recordings/" + genFileName("audio_"), 16, 2, _this->sampleRate); _this->writer = new WavWriter(expandedPath, 16, 2, _this->sampleRate);
_this->audioStream = sigpath::sinkManager.bindStream(_this->selectedStreamName); _this->audioStream = sigpath::sinkManager.bindStream(_this->selectedStreamName);
_this->workerThread = std::thread(_audioWriteWorker, _this); _this->workerThread = std::thread(_audioWriteWorker, _this);
_this->recording = true; _this->recording = true;
_this->startTime = time(0); _this->startTime = time(0);
} }
if (!_this->pathValid) { style::endDisabled(); }
ImGui::TextColored(ImGui::GetStyleColorVec4(ImGuiCol_Text), "Idle --:--:--"); ImGui::TextColored(ImGui::GetStyleColorVec4(ImGuiCol_Text), "Idle --:--:--");
} }
else { else {
@ -202,6 +239,8 @@ private:
} }
std::string name; std::string name;
char path[4096];
bool pathValid = true;
dsp::stream<dsp::stereo_t>* audioStream; dsp::stream<dsp::stereo_t>* audioStream;
dsp::stream<dsp::complex_t>* iqStream; dsp::stream<dsp::complex_t>* iqStream;
WavWriter* writer; WavWriter* writer;

View File

@ -21,11 +21,10 @@
"fftHeight": 296, "fftHeight": 296,
"frequency": 99000000, "frequency": 99000000,
"max": 0.0, "max": 0.0,
"maximized": true, "maximized": false,
"menuOrder": [ "menuOrder": [
"Source", "Source",
"Radio 1", "Radio",
"Radio 2",
"Recorder", "Recorder",
"Sinks", "Sinks",
"Audio", "Audio",
@ -34,10 +33,10 @@
"Display" "Display"
], ],
"menuWidth": 300, "menuWidth": 300,
"min": -53.676475524902344, "min": -72.05882263183594,
"offset": 0.0, "offset": 0.0,
"showWaterfall": true, "showWaterfall": true,
"source": "SoapySDR", "source": "PlutoSDR",
"sourceSettings": {}, "sourceSettings": {},
"streams": { "streams": {
"Radio": { "Radio": {

View File

@ -1,6 +1,5 @@
{ {
"Radio 1": "./radio/Release/radio.dll", "Radio": "./radio/Release/radio.dll",
"Radio 2": "./radio/Release/radio.dll",
"Recorder": "./recorder/Release/recorder.dll", "Recorder": "./recorder/Release/recorder.dll",
"Soapy": "./soapy/Release/soapy.dll", "Soapy": "./soapy/Release/soapy.dll",
"RTLTCPSource": "./rtl_tcp_source/Release/rtl_tcp_source.dll", "RTLTCPSource": "./rtl_tcp_source/Release/rtl_tcp_source.dll",

View File

@ -2,5 +2,5 @@
"IP": "192.168.2.1", "IP": "192.168.2.1",
"gain": 0.0, "gain": 0.0,
"gainMode": 2, "gainMode": 2,
"sampleRate": 4000000.0 "sampleRate": 2000000.0
} }