added throttle block

This commit is contained in:
Ryzerth 2021-04-02 00:35:05 +02:00
parent f88e2312b8
commit 1675ee99a4
2 changed files with 43 additions and 2 deletions

View File

@ -180,4 +180,45 @@ namespace dsp {
}; };
template <class T>
class Splitter : public generic_block<Splitter<T>> {
public:
Splitter() {}
Splitter(stream<T>* in) { init(in); }
void init(stream<T>* in) {
_in = in;
generic_block<Splitter>::registerInput(_in);
}
void setInput(stream<T>* in) {
std::lock_guard<std::mutex> lck(generic_block<Splitter>::ctrlMtx);
generic_block<Splitter>::tempStop();
generic_block<Splitter>::unregisterInput(_in);
_in = in;
generic_block<Splitter>::registerInput(_in);
generic_block<Splitter>::tempStart();
}
stream<T> 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<std::chrono::high_resolution_clock> last;
stream<T>* _in;
};
} }

View File

@ -48,7 +48,7 @@ public:
writeBuffer = new int8_t[STREAM_BUFFER_SIZE]; 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); demod.init(vfo->output, INPUT_SAMPLE_RATE, 72000.0f, 32, 0.6f, 0.1f, 0.005f);
split.init(demod.out); split.init(demod.out);
split.bindStream(&symSinkStream); split.bindStream(&symSinkStream);
@ -71,7 +71,7 @@ public:
} }
void enable() { 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); demod.setInput(vfo->output);