SatDump 2.0.0-alpha-520736c72
Loading...
Searching...
No Matches
rational_resampler.h
1#pragma once
2
3#include "common/dsp/complex.h"
4#include "common/dsp/resamp/polyphase_bank.h"
5#include "dsp/block.h"
6#include "dsp/block_simple.h"
7
8namespace satdump
9{
10 namespace ndsp
11 {
12 template <typename T>
13 class RationalResamplerBlock : public BlockSimple<T, T>
14 {
15 public:
16 float p_interpolation = 1;
17 float p_decimation = 2;
18 std::vector<float> p_taps = {};
19
20 bool needs_reinit = false;
21
22 private:
23 // Buffer
24 T *buffer = nullptr;
25 uint32_t in_buffer = 0;
26
27 // Settings
28 int d_interpolation;
29 int d_decimation;
30 int d_ctr;
31
32 int inc = 0, outc = 0;
33
34 // Taps
35 dsp::PolyphaseBank pfb;
36
37 public:
38 uint32_t process(T *input, uint32_t nsamples, T *output);
39
40 public:
41 RationalResamplerBlock();
42 ~RationalResamplerBlock();
43
44 void init();
45
46 nlohmann::ordered_json get_cfg_list()
47 {
48 nlohmann::ordered_json p;
49 add_param_simple(p, "interpolation", "float");
50 add_param_simple(p, "decimation", "float");
51 return p;
52 }
53
54 nlohmann::json get_cfg(std::string key)
55 {
56 if (key == "interpolation")
57 return p_interpolation;
58 else if (key == "decimation")
59 return p_decimation;
60 else
61 throw satdump_exception(key);
62 }
63
64 Block::cfg_res_t set_cfg(std::string key, nlohmann::json v)
65 {
66 if (key == "interpolation")
67 {
68 p_interpolation = v;
69 needs_reinit = true;
70 }
71 else if (key == "decimation")
72 {
73 p_decimation = v;
74 needs_reinit = true;
75 }
76 else
77 throw satdump_exception(key);
78 return Block::RES_OK;
79 }
80 };
81 } // namespace ndsp
82} // namespace satdump
cfg_res_t
set_cfg status.
Definition block.h:241
uint32_t process(T *input, uint32_t nsamples, T *output)
Simplified "work" function, called automatically by work(). This takes away all boilerplate work usua...
Definition rational_resampler.cpp:59
nlohmann::json get_cfg(std::string key)
Get parameters of the block as JSON.
Definition rational_resampler.h:54
nlohmann::ordered_json get_cfg_list()
Get parameters LIST of the block's parameters. This does not contain actual values,...
Definition rational_resampler.h:46
void init()
Applies current parameters to the block. This is called automatically once in start(),...
Definition rational_resampler.cpp:26
Block::cfg_res_t set_cfg(std::string key, nlohmann::json v)
Set parameters of the block from JSON, including potentially IO configurations for blocks that may ha...
Definition rational_resampler.h:64