From 3421aae9a262dce6fd242eb6978dcd30f895b28e Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Mon, 26 Sep 2022 14:57:06 +0200 Subject: [PATCH] more work on recorder --- misc_modules/recorder/src/main.cpp | 32 +++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/misc_modules/recorder/src/main.cpp b/misc_modules/recorder/src/main.cpp index 4ed8e0b5..77bec880 100644 --- a/misc_modules/recorder/src/main.cpp +++ b/misc_modules/recorder/src/main.cpp @@ -76,6 +76,12 @@ public: } config.release(); + // Init audio path + splitter.init(NULL); + splitter.bindStream(&meterStream); + meter.init(&meterStream); + meter.start(); + // Init sinks basebandSink.init(NULL, complexHandler, this); stereoSink.init(NULL, stereoHandler, this); @@ -85,6 +91,9 @@ public: } ~RecorderModule() { + stop(); + deselectStream(); + meter.stop(); gui::menu.removeEntry(name); } @@ -170,6 +179,22 @@ public: recording = false; } + void selectStream(std::string name) { + deselectStream(); + audioStream = sigpath::sinkManager.bindStream(name); + if (!audioStream) { return; } + splitter.setInput(audioStream); + splitter.start(); + } + + void deselectStream() { + if (selectedStreamName.empty() || !audioStream) { return; } + splitter.stop(); + sigpath::sinkManager.unbindStream(selectedStreamName, audioStream); + selectedStreamName = ""; + audioStream = NULL; + } + private: static void menuHandler(void* ctx) { RecorderModule* _this = (RecorderModule*)ctx; @@ -241,7 +266,7 @@ private: if (_this->recording) { style::beginDisabled(); } if (ImGui::Checkbox(CONCAT("Stereo##_recorder_stereo_", _this->name), &_this->stereo)) { - config.acquire(); + config.acquire();audioStream config.conf[_this->name]["stereo"] = _this->stereo; config.release(true); } @@ -344,6 +369,11 @@ private: dsp::sink::Handler stereoSink; dsp::sink::Handler monoSink; + dsp::stream* audioStream = NULL; + dsp::routing::Splitter splitter; + dsp::stream meterStream; + dsp::bench::PeakLevelMeter meter; + uint64_t samplerate = 48000; };