diff --git a/src-core/dsp/utils/delay_one_imag.cpp b/src-core/dsp/utils/delay_one_imag.cpp new file mode 100644 index 000000000..a01dda960 --- /dev/null +++ b/src-core/dsp/utils/delay_one_imag.cpp @@ -0,0 +1,45 @@ +#include "delay_one_imag.h" + +namespace satdump +{ + namespace ndsp + { + DelayOneImagBlock::DelayOneImagBlock() : Block("delay_one_imag_cc", {{"in", DSP_SAMPLE_TYPE_CF32}}, {{"out", DSP_SAMPLE_TYPE_CF32}}) {} + + DelayOneImagBlock::~DelayOneImagBlock() {} + + bool DelayOneImagBlock::work() + { + DSPBuffer iblk; + inputs[0].fifo->wait_dequeue(iblk); + + if (iblk.isTerminator()) + { + if (iblk.terminatorShouldPropagate()) + outputs[0].fifo->wait_enqueue(DSPBuffer::newBufferTerminator()); + iblk.free(); + return true; + } + + auto oblk = DSPBuffer::newBufferSamples(iblk.max_size); + complex_t *ibuf = iblk.getSamples(); + complex_t *obuf = iblk.getSamples(); + + for (uint32_t i = 0; i < iblk.size; i++) + { + float imag = i == 0 ? lastSamp : ibuf[i - 1].imag; + float real = ibuf[i].real; + obuf[i] = complex_t(real, imag); + } + + lastSamp = ibuf[iblk.size - 1].imag; + + oblk.size = iblk.size; + outputs[0].fifo->wait_enqueue(oblk); + iblk.free(); + return false; + } + + }; // namespace ndsp + +} // namespace satdump diff --git a/src-core/dsp/utils/delay_one_imag.h b/src-core/dsp/utils/delay_one_imag.h new file mode 100644 index 000000000..103869850 --- /dev/null +++ b/src-core/dsp/utils/delay_one_imag.h @@ -0,0 +1,40 @@ +#pragma once + +#include "common/dsp/complex.h" +#include "dsp/block.h" + +namespace satdump +{ + namespace ndsp + { + class DelayOneImagBlock : public Block + { + private: + // + + private: + float lastSamp; + // complex_t tmp_val; + + bool work(); + + public: + DelayOneImagBlock(); + ~DelayOneImagBlock(); + + void init() {} + + nlohmann::json get_cfg(std::string key) + { + throw satdump_exception(key); + } + + cfg_res_t set_cfg(std::string key, nlohmann::json v) + { + throw satdump_exception(key); + return RES_OK; + } + }; + + } // namespace ndsp +} // namespace satdump