SatDump 2.0.0-alpha-520736c72
Loading...
Searching...
No Matches
float_to_char.h
1#pragma once
2
3#include "common/dsp/complex.h"
4#include "dsp/block_simple.h"
5
6namespace satdump
7{
8 namespace ndsp
9 {
10 class FloatToCharBlock : public BlockSimple<float, int8_t>
11 {
12 private:
13 float scale = 1.0;
14
15 public:
16 uint32_t process(float *input, uint32_t nsamples, int8_t *output);
17
18 public:
19 FloatToCharBlock();
20 ~FloatToCharBlock();
21
22 void init() {}
23
24 nlohmann::ordered_json get_cfg_list()
25 {
26 nlohmann::ordered_json p;
27 add_param_simple(p, "scale", "float");
28 return p;
29 }
30
31 nlohmann::json get_cfg(std::string key)
32 {
33 if (key == "scale")
34 return scale;
35 else
36 throw satdump_exception(key);
37 }
38
39 cfg_res_t set_cfg(std::string key, nlohmann::json v)
40 {
41 if (key == "scale")
42 scale = v;
43 else
44 throw satdump_exception(key);
45 return RES_OK;
46 }
47 };
48 } // namespace ndsp
49} // namespace satdump
cfg_res_t
set_cfg status.
Definition block.h:241
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 float_to_char.h:39
nlohmann::json get_cfg(std::string key)
Get parameters of the block as JSON.
Definition float_to_char.h:31
uint32_t process(float *input, uint32_t nsamples, int8_t *output)
Simplified "work" function, called automatically by work(). This takes away all boilerplate work usua...
Definition float_to_char.cpp:13
void init()
Applies current parameters to the block. This is called automatically once in start(),...
Definition float_to_char.h:22
nlohmann::ordered_json get_cfg_list()
Get parameters LIST of the block's parameters. This does not contain actual values,...
Definition float_to_char.h:24