mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-01-26 17:44:44 +01:00
added saved config to recorder
This commit is contained in:
parent
ce389dfd79
commit
11766a2c41
@ -50,7 +50,22 @@ public:
|
|||||||
RecorderModule(std::string name) : folderSelect("%ROOT%/recordings") {
|
RecorderModule(std::string name) : folderSelect("%ROOT%/recordings") {
|
||||||
this->name = name;
|
this->name = name;
|
||||||
|
|
||||||
recPath = "%ROOT%/recordings";
|
// Load config
|
||||||
|
config.aquire();
|
||||||
|
bool created = false;
|
||||||
|
|
||||||
|
// Create config if it doesn't exist
|
||||||
|
if (!config.conf.contains(name)) {
|
||||||
|
config.conf[name]["mode"] = 1;
|
||||||
|
config.conf[name]["recPath"] = "%ROOT%/recordings";
|
||||||
|
config.conf[name]["audioStream"] = "Radio";
|
||||||
|
created = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
recMode = config.conf[name]["mode"];
|
||||||
|
folderSelect.setPath(config.conf[name]["recPath"]);
|
||||||
|
selectedStreamName = config.conf[name]["audioStream"];
|
||||||
|
config.release(created);
|
||||||
|
|
||||||
// Init audio path
|
// Init audio path
|
||||||
vol.init(&dummyStream, 1.0f);
|
vol.init(&dummyStream, 1.0f);
|
||||||
@ -92,6 +107,11 @@ public:
|
|||||||
private:
|
private:
|
||||||
void refreshStreams() {
|
void refreshStreams() {
|
||||||
std::vector<std::string> names = sigpath::sinkManager.getStreamNames();
|
std::vector<std::string> names = sigpath::sinkManager.getStreamNames();
|
||||||
|
|
||||||
|
// If there are no stream, cancel
|
||||||
|
if (names.size() == 0) { return; }
|
||||||
|
|
||||||
|
// List streams
|
||||||
streamNames.clear();
|
streamNames.clear();
|
||||||
streamNamesTxt = "";
|
streamNamesTxt = "";
|
||||||
for (auto const& name : names) {
|
for (auto const& name : names) {
|
||||||
@ -99,6 +119,7 @@ private:
|
|||||||
streamNamesTxt += name;
|
streamNamesTxt += name;
|
||||||
streamNamesTxt += '\0';
|
streamNamesTxt += '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedStreamName == "") {
|
if (selectedStreamName == "") {
|
||||||
selectStream(streamNames[0]);
|
selectStream(streamNames[0]);
|
||||||
}
|
}
|
||||||
@ -129,12 +150,18 @@ private:
|
|||||||
if (_this->recording) { style::beginDisabled(); }
|
if (_this->recording) { style::beginDisabled(); }
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
ImGui::Columns(2, CONCAT("AirspyGainModeColumns##_", _this->name), false);
|
ImGui::Columns(2, CONCAT("AirspyGainModeColumns##_", _this->name), false);
|
||||||
if (ImGui::RadioButton(CONCAT("Baseband##_recmode_", _this->name), !_this->recMode)) {
|
if (ImGui::RadioButton(CONCAT("Baseband##_recmode_", _this->name), _this->recMode == 0)) {
|
||||||
_this->recMode = false;
|
_this->recMode = 0;
|
||||||
|
config.aquire();
|
||||||
|
config.conf[_this->name]["mode"] = _this->recMode;
|
||||||
|
config.release(true);
|
||||||
}
|
}
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
if (ImGui::RadioButton(CONCAT("Audio##_recmode_", _this->name), _this->recMode)) {
|
if (ImGui::RadioButton(CONCAT("Audio##_recmode_", _this->name), _this->recMode == 1)) {
|
||||||
_this->recMode = true;
|
_this->recMode = 1;
|
||||||
|
config.aquire();
|
||||||
|
config.conf[_this->name]["mode"] = _this->recMode;
|
||||||
|
config.release(true);
|
||||||
}
|
}
|
||||||
ImGui::Columns(1, CONCAT("EndAirspyGainModeColumns##_", _this->name), false);
|
ImGui::Columns(1, CONCAT("EndAirspyGainModeColumns##_", _this->name), false);
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
@ -143,13 +170,14 @@ private:
|
|||||||
// Recording path
|
// Recording path
|
||||||
if (_this->folderSelect.render("##_recorder_fold_" + _this->name)) {
|
if (_this->folderSelect.render("##_recorder_fold_" + _this->name)) {
|
||||||
if (_this->folderSelect.pathIsValid()) {
|
if (_this->folderSelect.pathIsValid()) {
|
||||||
_this->recPath = _this->folderSelect.path;
|
config.aquire();
|
||||||
|
config.conf[_this->name]["recPath"] = _this->folderSelect.path;
|
||||||
|
config.release(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_this->pathValid = _this->folderSelect.pathIsValid();
|
|
||||||
|
|
||||||
// Mode specific menu
|
// Mode specific menu
|
||||||
if (_this->recMode) {
|
if (_this->recMode == 1) {
|
||||||
_this->audioMenu(menuColumnWidth);
|
_this->audioMenu(menuColumnWidth);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -158,11 +186,11 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void basebandMenu(float menuColumnWidth) {
|
void basebandMenu(float menuColumnWidth) {
|
||||||
if (!pathValid) { style::beginDisabled(); }
|
if (!folderSelect.pathIsValid()) { style::beginDisabled(); }
|
||||||
if (!recording) {
|
if (!recording) {
|
||||||
if (ImGui::Button(CONCAT("Record##_recorder_rec_", name), ImVec2(menuColumnWidth, 0))) {
|
if (ImGui::Button(CONCAT("Record##_recorder_rec_", name), ImVec2(menuColumnWidth, 0))) {
|
||||||
samplesWritten = 0;
|
samplesWritten = 0;
|
||||||
std::string expandedPath = expandString(recPath + genFileName("/baseband_", false));
|
std::string expandedPath = expandString(folderSelect.path + genFileName("/baseband_", false));
|
||||||
sampleRate = sigpath::signalPath.getSampleRate();
|
sampleRate = sigpath::signalPath.getSampleRate();
|
||||||
basebandWriter = new WavWriter(expandedPath, 16, 2, sigpath::signalPath.getSampleRate());
|
basebandWriter = new WavWriter(expandedPath, 16, 2, sigpath::signalPath.getSampleRate());
|
||||||
if (basebandWriter->isOpen()) {
|
if (basebandWriter->isOpen()) {
|
||||||
@ -190,14 +218,24 @@ private:
|
|||||||
tm *dtm = gmtime(&diff);
|
tm *dtm = gmtime(&diff);
|
||||||
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Recording %02d:%02d:%02d", dtm->tm_hour, dtm->tm_min, dtm->tm_sec);
|
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Recording %02d:%02d:%02d", dtm->tm_hour, dtm->tm_min, dtm->tm_sec);
|
||||||
}
|
}
|
||||||
if (!pathValid) { style::endDisabled(); }
|
if (!folderSelect.pathIsValid()) { style::endDisabled(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void audioMenu(float menuColumnWidth) {
|
void audioMenu(float menuColumnWidth) {
|
||||||
ImGui::PushItemWidth(menuColumnWidth);
|
ImGui::PushItemWidth(menuColumnWidth);
|
||||||
|
|
||||||
|
if (streamNames.size() == 0) {
|
||||||
|
refreshStreams();
|
||||||
|
ImGui::PopItemWidth();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (recording) { style::beginDisabled(); }
|
if (recording) { style::beginDisabled(); }
|
||||||
if (ImGui::Combo(CONCAT("##_recorder_strm_", name), &streamId, streamNamesTxt.c_str())) {
|
if (ImGui::Combo(CONCAT("##_recorder_strm_", name), &streamId, streamNamesTxt.c_str())) {
|
||||||
selectStream(streamNames[streamId]);
|
selectStream(streamNames[streamId]);
|
||||||
|
config.aquire();
|
||||||
|
config.conf[name]["audioStream"] = streamNames[streamId];
|
||||||
|
config.release(true);
|
||||||
}
|
}
|
||||||
if (recording) { style::endDisabled(); }
|
if (recording) { style::endDisabled(); }
|
||||||
|
|
||||||
@ -217,11 +255,11 @@ private:
|
|||||||
}
|
}
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
if (!pathValid || selectedStreamName == "") { style::beginDisabled(); }
|
if (!folderSelect.pathIsValid() || selectedStreamName == "") { style::beginDisabled(); }
|
||||||
if (!recording) {
|
if (!recording) {
|
||||||
if (ImGui::Button(CONCAT("Record##_recorder_rec_", name), ImVec2(menuColumnWidth, 0))) {
|
if (ImGui::Button(CONCAT("Record##_recorder_rec_", name), ImVec2(menuColumnWidth, 0))) {
|
||||||
samplesWritten = 0;
|
samplesWritten = 0;
|
||||||
std::string expandedPath = expandString(recPath + genFileName("/audio_", true, selectedStreamName));
|
std::string expandedPath = expandString(folderSelect.path + genFileName("/audio_", true, selectedStreamName));
|
||||||
sampleRate = sigpath::sinkManager.getStreamSampleRate(selectedStreamName);
|
sampleRate = sigpath::sinkManager.getStreamSampleRate(selectedStreamName);
|
||||||
audioWriter = new WavWriter(expandedPath, 16, 2, sigpath::sinkManager.getStreamSampleRate(selectedStreamName));
|
audioWriter = new WavWriter(expandedPath, 16, 2, sigpath::sinkManager.getStreamSampleRate(selectedStreamName));
|
||||||
if (audioWriter->isOpen()) {
|
if (audioWriter->isOpen()) {
|
||||||
@ -249,7 +287,7 @@ private:
|
|||||||
tm *dtm = gmtime(&diff);
|
tm *dtm = gmtime(&diff);
|
||||||
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Recording %02d:%02d:%02d", dtm->tm_hour, dtm->tm_min, dtm->tm_sec);
|
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Recording %02d:%02d:%02d", dtm->tm_hour, dtm->tm_min, dtm->tm_sec);
|
||||||
}
|
}
|
||||||
if (!pathValid || selectedStreamName == "") { style::endDisabled(); }
|
if (!folderSelect.pathIsValid() || selectedStreamName == "") { style::endDisabled(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _audioHandler(dsp::stereo_t *data, int count, void *ctx) {
|
static void _audioHandler(dsp::stereo_t *data, int count, void *ctx) {
|
||||||
@ -276,11 +314,8 @@ private:
|
|||||||
std::string name;
|
std::string name;
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
|
|
||||||
std::string recPath = "";
|
int recMode = 1;
|
||||||
|
|
||||||
bool recMode = 1;
|
|
||||||
bool recording = false;
|
bool recording = false;
|
||||||
bool pathValid = true;
|
|
||||||
|
|
||||||
float audioVolume = 1.0f;
|
float audioVolume = 1.0f;
|
||||||
|
|
||||||
@ -294,7 +329,7 @@ private:
|
|||||||
FolderSelect folderSelect;
|
FolderSelect folderSelect;
|
||||||
|
|
||||||
// Audio path
|
// Audio path
|
||||||
dsp::stream<dsp::stereo_t>* audioInput;
|
dsp::stream<dsp::stereo_t>* audioInput = NULL;
|
||||||
dsp::Volume<dsp::stereo_t> vol;
|
dsp::Volume<dsp::stereo_t> vol;
|
||||||
dsp::Splitter<dsp::stereo_t> audioSplit;
|
dsp::Splitter<dsp::stereo_t> audioSplit;
|
||||||
dsp::stream<dsp::stereo_t> meterStream;
|
dsp::stream<dsp::stereo_t> meterStream;
|
||||||
@ -331,7 +366,7 @@ MOD_EXPORT void _INIT_() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
json def = json({});
|
json def = json({});
|
||||||
config.setPath(options::opts.root + "/radio_config.json");
|
config.setPath(options::opts.root + "/recorder_config.json");
|
||||||
config.load(def);
|
config.load(def);
|
||||||
config.enableAutoSave();
|
config.enableAutoSave();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user