more work on recorder

This commit is contained in:
AlexandreRouma 2022-09-26 14:57:06 +02:00
parent 5b8b344142
commit 3421aae9a2

View File

@ -76,6 +76,12 @@ public:
} }
config.release(); config.release();
// Init audio path
splitter.init(NULL);
splitter.bindStream(&meterStream);
meter.init(&meterStream);
meter.start();
// Init sinks // Init sinks
basebandSink.init(NULL, complexHandler, this); basebandSink.init(NULL, complexHandler, this);
stereoSink.init(NULL, stereoHandler, this); stereoSink.init(NULL, stereoHandler, this);
@ -85,6 +91,9 @@ public:
} }
~RecorderModule() { ~RecorderModule() {
stop();
deselectStream();
meter.stop();
gui::menu.removeEntry(name); gui::menu.removeEntry(name);
} }
@ -170,6 +179,22 @@ public:
recording = false; 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: private:
static void menuHandler(void* ctx) { static void menuHandler(void* ctx) {
RecorderModule* _this = (RecorderModule*)ctx; RecorderModule* _this = (RecorderModule*)ctx;
@ -241,7 +266,7 @@ private:
if (_this->recording) { style::beginDisabled(); } if (_this->recording) { style::beginDisabled(); }
if (ImGui::Checkbox(CONCAT("Stereo##_recorder_stereo_", _this->name), &_this->stereo)) { if (ImGui::Checkbox(CONCAT("Stereo##_recorder_stereo_", _this->name), &_this->stereo)) {
config.acquire(); config.acquire();audioStream
config.conf[_this->name]["stereo"] = _this->stereo; config.conf[_this->name]["stereo"] = _this->stereo;
config.release(true); config.release(true);
} }
@ -344,6 +369,11 @@ private:
dsp::sink::Handler<dsp::stereo_t> stereoSink; dsp::sink::Handler<dsp::stereo_t> stereoSink;
dsp::sink::Handler<float> monoSink; dsp::sink::Handler<float> monoSink;
dsp::stream<dsp::stereo_t>* audioStream = NULL;
dsp::routing::Splitter<dsp::stereo_t> splitter;
dsp::stream<dsp::stereo_t> meterStream;
dsp::bench::PeakLevelMeter<dsp::stereo_t> meter;
uint64_t samplerate = 48000; uint64_t samplerate = 48000;
}; };