mirror of
https://github.com/SatDump/SatDump
synced 2026-08-13 17:47:30 -04:00
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:
parent
82755bc885
commit
007fb07bf9
2 changed files with 85 additions and 0 deletions
45
src-core/dsp/utils/delay_one_imag.cpp
Normal file
45
src-core/dsp/utils/delay_one_imag.cpp
Normal 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
|
||||
40
src-core/dsp/utils/delay_one_imag.h
Normal file
40
src-core/dsp/utils/delay_one_imag.h
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue