From 1675ee99a45371f1195927d5b4ff3f02cdf3cf17 Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Fri, 2 Apr 2021 00:35:05 +0200 Subject: [PATCH] added throttle block --- core/src/dsp/routing.h | 41 +++++++++++++++++++++++++++++++++ meteor_demodulator/src/main.cpp | 4 ++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/core/src/dsp/routing.h b/core/src/dsp/routing.h index 3cd4fd65..a3970494 100644 --- a/core/src/dsp/routing.h +++ b/core/src/dsp/routing.h @@ -180,4 +180,45 @@ namespace dsp { }; + + template + class Splitter : public generic_block> { + public: + Splitter() {} + + Splitter(stream* in) { init(in); } + + void init(stream* in) { + _in = in; + generic_block::registerInput(_in); + } + + void setInput(stream* in) { + std::lock_guard lck(generic_block::ctrlMtx); + generic_block::tempStop(); + generic_block::unregisterInput(_in); + _in = in; + generic_block::registerInput(_in); + generic_block::tempStart(); + } + + stream out; + + private: + int run() { + // TODO: If too slow, buffering might be necessary + int count = _in->read(); + if (count < 0) { return -1; } + + auto now = std::chrono::high_resolution_clock::now(); + + _in->flush(); + out.swap(count); + return count; + } + + std::chrono::time_point last; + + stream* _in; + }; } \ No newline at end of file diff --git a/meteor_demodulator/src/main.cpp b/meteor_demodulator/src/main.cpp index c38524cc..ca3bf3ad 100644 --- a/meteor_demodulator/src/main.cpp +++ b/meteor_demodulator/src/main.cpp @@ -48,7 +48,7 @@ public: writeBuffer = new int8_t[STREAM_BUFFER_SIZE]; - vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 150000, INPUT_SAMPLE_RATE, 1); + vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 120000, INPUT_SAMPLE_RATE, 1); demod.init(vfo->output, INPUT_SAMPLE_RATE, 72000.0f, 32, 0.6f, 0.1f, 0.005f); split.init(demod.out); split.bindStream(&symSinkStream); @@ -71,7 +71,7 @@ public: } void enable() { - vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 150000, INPUT_SAMPLE_RATE, 1); + vfo = sigpath::vfoManager.createVFO(name, ImGui::WaterfallVFO::REF_CENTER, 0, 120000, INPUT_SAMPLE_RATE, 1); demod.setInput(vfo->output);