NDSP Work

Add delay one imaginary block to NDSP

Not 100% sure if this is the best way to implement it*
This commit is contained in:
juliasat 2025-05-04 05:38:23 -03:00
parent 82755bc885
commit 007fb07bf9
No known key found for this signature in database
GPG key ID: 07D779B4888EAB01
2 changed files with 85 additions and 0 deletions

View file

@ -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<complex_t>(iblk.max_size);
complex_t *ibuf = iblk.getSamples<complex_t>();
complex_t *obuf = iblk.getSamples<complex_t>();
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

View file

@ -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