Added persistant settings to recorder module

pull/40/head
Ryzerth 2020-12-09 19:45:32 +01:00
rodzic 9b1c9e9e29
commit 2c729bf646
4 zmienionych plików z 40 dodań i 10 usunięć

Wyświetl plik

@ -5,6 +5,8 @@
#include <imutils.h>
#include <algorithm>
#include <spdlog/spdlog.h>
float COLOR_MAP[][3] = {
{0x00, 0x00, 0x20},
{0x00, 0x00, 0x30},
@ -152,9 +154,6 @@ namespace ImGui {
for (int i = 1; i < dataWidth; i++) {
double aPos = widgetPos.y + fftHeight + 10 - ((latestFFT[i - 1] - fftMin) * scaleFactor);
double bPos = widgetPos.y + fftHeight + 10 - ((latestFFT[i] - fftMin) * scaleFactor);
if (aPos < fftMin && bPos < fftMin) {
continue;
}
aPos = std::clamp<double>(aPos, widgetPos.y + 10, widgetPos.y + fftHeight + 10);
bPos = std::clamp<double>(bPos, widgetPos.y + 10, widgetPos.y + fftHeight + 10);
window->DrawList->AddLine(ImVec2(widgetPos.x + 49 + i, roundf(aPos)),

Wyświetl plik

@ -25,6 +25,8 @@ SDRPP_MOD_INFO {
// TODO: Fix this and finish module
ConfigManager config;
std::string genFileName(std::string prefix) {
time_t now = time(0);
tm *ltm = localtime(&now);
@ -54,7 +56,17 @@ public:
selectedStreamName = "";
selectedStreamId = 0;
lastNameList = "";
strcpy(path, "%ROOT%/recordings");
config.aquire();
if (!config.conf.contains(name)) {
config.conf[name]["recMode"] = 1;
config.conf[name]["directory"] = "%ROOT%/recordings";
}
recMode = config.conf[name]["recMode"];
std::string recPath = config.conf[name]["directory"];
strcpy(path, recPath.c_str());
config.release(true);
gui::menu.registerEntry(name, menuHandler, this);
}
@ -122,6 +134,9 @@ private:
}
else {
_this->pathValid = true;
config.aquire();
config.conf[_this->name]["directory"] = _this->path;
config.release(true);
}
}
if (!lastPathValid) {
@ -133,10 +148,16 @@ private:
ImGui::Columns(2, CONCAT("RecordModeColumns##_", _this->name), false);
if (ImGui::RadioButton(CONCAT("Baseband##_", _this->name), _this->recMode == 0) && _this->recMode != 0) {
_this->recMode = 0;
config.aquire();
config.conf[_this->name]["recMode"] = _this->recMode;
config.release(true);
}
ImGui::NextColumn();
if (ImGui::RadioButton(CONCAT("Audio##_", _this->name), _this->recMode == 1) && _this->recMode != 1) {
_this->recMode = 1;
config.aquire();
config.conf[_this->name]["recMode"] = _this->recMode;
config.release(true);
}
if (_this->recording) { style::endDisabled(); }
ImGui::Columns(1, CONCAT("EndRecordModeColumns##_", _this->name), false);
@ -275,7 +296,7 @@ private:
uint64_t samplesWritten;
float sampleRate;
float vfoSampleRate = 200000;
int recMode = 0;
int recMode = 1;
};
@ -284,7 +305,10 @@ struct RecorderContext_t {
};
MOD_EXPORT void _INIT_() {
// Nothing here
json def = json({});
config.setPath(ROOT_DIR "/recorder_config.json");
config.load(def);
config.enableAutoSave();
}
MOD_EXPORT ModuleManager::Instance* _CREATE_INSTANCE_(std::string name) {
@ -296,5 +320,6 @@ MOD_EXPORT void _DELETE_INSTANCE_(ModuleManager::Instance* inst) {
}
MOD_EXPORT void _END_(RecorderContext_t* ctx) {
config.disableAutoSave();
config.save();
}

Wyświetl plik

@ -3,7 +3,7 @@
"bandPlanEnabled": true,
"centerTuning": false,
"fftHeight": 300,
"frequency": 99808000,
"frequency": 99716000,
"max": 0.0,
"maximized": false,
"menuOrder": [
@ -17,7 +17,7 @@
"Display"
],
"menuWidth": 300,
"min": -70.0,
"min": -65.44117736816406,
"moduleInstances": {
"Audio Sink": "audio_sink",
"PlutoSDR Source": "plutosdr_source",
@ -41,7 +41,7 @@
"Radio": {
"muted": false,
"sink": "Audio",
"volume": 0.41326531767845154
"volume": 0.4285714328289032
},
"Radio 1": {
"muted": false,

Wyświetl plik

@ -0,0 +1,6 @@
{
"Recorder": {
"directory": "%ROOT%/recordings",
"recMode": 1
}
}