SatDump 2.0.0-alpha-520736c72
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 {
22 template <typename Ti, typename To>
23 class BlockSimple : public Block
24 {
25 protected:
26 float output_buffer_size_ratio = 1;
27
28 private:
29 bool work()
30 {
31 DSPBuffer iblk = inputs[0].fifo->wait_dequeue();
32
33 if (iblk.isTerminator())
34 {
36 outputs[0].fifo->wait_enqueue(outputs[0].fifo->newBufferTerminator());
37 inputs[0].fifo->free(iblk);
38 return true;
39 }
40
41 DSPBuffer oblk = outputs[0].fifo->newBufferSamples(ceil(iblk.max_size * output_buffer_size_ratio), sizeof(To));
42
43 oblk.size = process(iblk.getSamples<Ti>(), iblk.size, oblk.getSamples<To>());
44
45 if (oblk.size > 0)
46 outputs[0].fifo->wait_enqueue(oblk);
47 inputs[0].fifo->free(iblk);
48
49 return false;
50 }
51
52 public:
53 BlockSimple(std::string id, std::vector<BlockIO> in = {}, std::vector<BlockIO> out = {}) : Block(id, in, out) {}
54
67 virtual uint32_t process(Ti *input, uint32_t nsamples, To *output) = 0;
68 };
69 } // namespace ndsp
70} // 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:208
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