SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
block_simple.h
Go to the documentation of this file.
1#pragma once
2
6
7#include "dsp/block.h"
8
9namespace satdump
10{
11 namespace ndsp
12 {
18 template <typename Ti, typename To>
19 class BlockSimple : public Block
20 {
21 private:
22 bool work()
23 {
24 DSPBuffer iblk = inputs[0].fifo->wait_dequeue();
25
26 if (iblk.isTerminator())
27 {
29 outputs[0].fifo->wait_enqueue(outputs[0].fifo->newBufferTerminator());
30 inputs[0].fifo->free(iblk);
31 return true;
32 }
33
34 DSPBuffer oblk = outputs[0].fifo->newBufferSamples<To>(iblk.max_size);
35
36 oblk.size = process(iblk.getSamples<Ti>(), iblk.size, oblk.getSamples<To>());
37
38 outputs[0].fifo->wait_enqueue(oblk);
39 inputs[0].fifo->free(iblk);
40
41 return false;
42 }
43
44 public:
45 BlockSimple(std::string id, std::vector<BlockIO> in = {}, std::vector<BlockIO> out = {}) : Block(id, in, out) {}
46
59 virtual uint32_t process(Ti *input, uint32_t nsamples, To *output) = 0;
60 };
61 } // namespace ndsp
62} // namespace satdump
virtual uint32_t process(Ti *input, uint32_t nsamples, To *output)=0
Simplified "work" function, called automatically by work(). This takes away all boilerplate work usua...
virtual bool work()=0
The actual looping work function meant to handle all the DSP (well, in most blocks)
Block(std::string id, std::vector< BlockIO > in={}, std::vector< BlockIO > out={})
Generic constructor, to be overloaded.
Definition block.h:206
DSP Buffer class.
Definition dsp_buffer.h:52
bool terminatorShouldPropagate()
Checks if this buffer is a propagating terminator. If it is, a propagating terminator should be sent ...
Definition dsp_buffer.h:90
bool isTerminator()
Checks if this buffer is a terminator. This covers BOTH propagating and normal terminator markers.
Definition dsp_buffer.h:82
T * getSamples()
Get sample pointer.
Definition dsp_buffer.h:72